Added memory reinterpretation functions for int, long, float and double
git-svn-id: file:///srv/devel/repo-conversion/nusu@73 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
parent
1132bc5681
commit
bf5c8d4e19
3 changed files with 114 additions and 9 deletions
|
|
@ -59,8 +59,51 @@ namespace Nuclex.Support {
|
|||
);
|
||||
}
|
||||
|
||||
/// <summary>Tests the integer reinterpretation functions</summary>
|
||||
[Test]
|
||||
public void TestIntegerReinterpretation() {
|
||||
Assert.AreEqual(
|
||||
12345.0f,
|
||||
FloatHelper.ReinterpretAsFloat(FloatHelper.ReinterpretAsInt(12345.0f)),
|
||||
"Number hasn't changed after mirrored reinterpretation"
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>Tests the long reinterpretation functions</summary>
|
||||
[Test]
|
||||
public void TestLongReinterpretation() {
|
||||
Assert.AreEqual(
|
||||
12345.67890,
|
||||
FloatHelper.ReinterpretAsDouble(FloatHelper.ReinterpretAsLong(12345.67890)),
|
||||
"Number hasn't changed after mirrored reinterpretation"
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>Tests the floating point reinterpretation functions</summary>
|
||||
[Test]
|
||||
public void TestFloatReinterpretation() {
|
||||
Assert.AreEqual(
|
||||
12345,
|
||||
FloatHelper.ReinterpretAsInt(FloatHelper.ReinterpretAsFloat(12345)),
|
||||
"Number hasn't changed after mirrored reinterpretation"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Tests the double prevision floating point reinterpretation functions
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestDoubleReinterpretation() {
|
||||
Assert.AreEqual(
|
||||
1234567890,
|
||||
FloatHelper.ReinterpretAsLong(FloatHelper.ReinterpretAsDouble(1234567890)),
|
||||
"Number hasn't changed after mirrored reinterpretation"
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace Nuclex.Support
|
||||
|
||||
#endif // UNITTEST
|
||||
#endif // UNITTEST
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue