forked from CosmosOS/Cosmos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request CosmosOS#348 from fanoI/master
- Added Bitconverter tests (fails for Double)
- Loading branch information
Showing
5 changed files
with
81 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
Tests/Cosmos.Compiler.Tests.Bcl/System/BitConverterTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Cosmos.TestRunner; | ||
|
||
namespace Cosmos.Compiler.Tests.Bcl.System | ||
{ | ||
class BitConverterTest | ||
{ | ||
public static void Execute() | ||
{ | ||
String result; | ||
String expectedResult; | ||
|
||
int anInt = 1; | ||
|
||
byte[] intBytes = BitConverter.GetBytes(anInt); | ||
|
||
result = BitConverter.ToString(intBytes, 0); | ||
expectedResult = "01-00-00-00"; | ||
|
||
Assert.IsTrue((result == expectedResult), "BitConverter.ToString(intBytes) doesn't work: result " + result + " != " + expectedResult); | ||
|
||
long aLong = 1; | ||
|
||
byte[] longBytes = BitConverter.GetBytes(aLong); | ||
|
||
result = BitConverter.ToString(longBytes, 0); | ||
expectedResult = "01-00-00-00-00-00-00-00"; | ||
|
||
Assert.IsTrue((result == expectedResult), "BitConverter.ToString(longBytes) doesn't work: result " + result + " != " + expectedResult); | ||
|
||
ulong anULong = 1; | ||
|
||
byte[] ulongBytes = BitConverter.GetBytes(anULong); | ||
|
||
result = BitConverter.ToString(ulongBytes, 0); | ||
expectedResult = "01-00-00-00-00-00-00-00"; | ||
|
||
Assert.IsTrue((result == expectedResult), "BitConverter.ToString(ulongBytes) doesn't work: result " + result + " != " + expectedResult); | ||
|
||
// These tests fails bytes are screwed! | ||
|
||
float aFloat = 1.0f; | ||
|
||
byte[] floatBytes = BitConverter.GetBytes(aFloat); | ||
|
||
result = BitConverter.ToString(floatBytes, 0); | ||
expectedResult = "00-00-80-3F"; | ||
|
||
Assert.IsTrue((result == expectedResult), "BitConverter.ToString(floatBytes) doesn't work: result " + result + " != " + expectedResult); | ||
|
||
double aDouble = 1.0; | ||
|
||
byte[] doubleBytes = BitConverter.GetBytes(aDouble); | ||
|
||
result = BitConverter.ToString(doubleBytes, 0); | ||
expectedResult = "00-00-00-00-00-00-F0-3F"; | ||
|
||
Assert.IsTrue((result == expectedResult), "BitConverter.ToString(doubleBytes) doesn't work: result " + result + " != " + expectedResult); | ||
|
||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters