Fixed and Added Tests

Fixed tests for Int32 and Int64, so that they actually work.

Added tests for UInt32 and UInt64
This commit is contained in:
Quajak 2018-10-09 22:04:15 +02:00
parent 7e4f4fc3bc
commit 1a930e3181
4 changed files with 89 additions and 18 deletions

View file

@ -143,31 +143,37 @@ namespace Cosmos.Compiler.Tests.Bcl.System
ByRefTestMethod(ref value);
Assert.IsTrue(value == 61, "Passing an Int32 by ref to a method doesn't work");
//Test StackOverflow Exceptions
int val3o;
//Test Overflow Exceptions
int val3o = 10000;
efuse = false;
val3o = 10000;
try
{
val3o += 2147483647;
checked
{
val3o += 2147483647;
}
}
catch (OverflowException e)
catch (OverflowException)
{
efuse = true;
}
Assert.IsTrue(efuse, "Add_Ovf for Int32 doesn't work");
Assert.IsTrue(efuse, "Add_Ovf for Int32 doesn't work: " + val3o);
efuse = false;
val3o = -10000;
try
{
val3o -= 2147483647;
checked
{
val3o -= 2147483647;
}
}
catch (OverflowException e)
catch (OverflowException)
{
efuse = true;
}
Assert.IsTrue(efuse, "Sub_Ovf for Int32 doesn't work");
Assert.IsTrue(efuse, "Sub_Ovf for Int32 doesn't work: " + val3o);
Console.WriteLine("Finished Int32 Tests!");
}
public static int TestMethod(int aParam)

View file

@ -149,31 +149,36 @@ namespace Cosmos.Compiler.Tests.Bcl.System
ByRefTestMethod(ref value);
Assert.IsTrue(value == 61, "Passing an Int64 by ref to a method doesn't work");
//Test StackOverflow Exceptions
long val3o;
//Test Overflow Exceptions
long val3o = 1000000;
efuse = false;
val3o = 1000000;
try
{
val3o += long.MaxValue;
checked
{
val3o += long.MaxValue;
}
}
catch (OverflowException e)
catch (OverflowException)
{
efuse = true;
}
Assert.IsTrue(efuse, "Add_Ovf for Int16 doesn't work");
Assert.IsTrue(efuse, "Add_Ovf for Int64 doesn't work");
efuse = false;
val3o = -10000;
try
{
val3o -= long.MaxValue;
checked
{
val3o -= long.MaxValue;
}
}
catch (OverflowException e)
catch (OverflowException)
{
efuse = true;
}
Assert.IsTrue(efuse, "Sub_Ovf for Int16 doesn't work");
Assert.IsTrue(efuse, "Sub_Ovf for Int64 doesn't work");
}
public static long TestMethod(long aParam)

View file

@ -141,6 +141,35 @@ namespace Cosmos.Compiler.Tests.Bcl.System
ByRefTestMethod(ref value);
Assert.IsTrue(value == 61, "Passing an UInt32 by ref to a method doesn't work");
uint val3o = 10000;
bool efuse = false;
try
{
checked
{
val3o += uint.MaxValue;
}
}
catch (OverflowException)
{
efuse = true;
}
Assert.IsTrue(efuse, "Add_Ovf for UInt32 doesn't work: " + val3o);
efuse = false;
val3o = 10000;
try
{
checked
{
val3o -= 2147483647;
}
}
catch (OverflowException)
{
efuse = true;
}
Assert.IsTrue(efuse, "Sub_Ovf for UInt32 doesn't work: " + val3o);
}
public static uint TestMethod(uint aParam)

View file

@ -147,6 +147,37 @@ namespace Cosmos.Compiler.Tests.Bcl.System
ByRefTestMethod(ref value);
Assert.IsTrue(value == 61, "Passing an UInt64 by ref to a method doesn't work");
//Test Overflow Exceptions
ulong val3o = 10000;
bool efuse = false;
try
{
checked
{
val3o += ulong.MaxValue;
}
}
catch (OverflowException)
{
efuse = true;
}
Assert.IsTrue(efuse, "Add_Ovf for UInt64 doesn't work: " + val3o);
efuse = false;
val3o = 10000;
try
{
checked
{
val3o -= 2147483647;
}
}
catch (OverflowException)
{
efuse = true;
}
Assert.IsTrue(efuse, "Sub_Ovf for UInt64 doesn't work: " + val3o);
}
public static ulong TestMethod(ulong aParam)