Added tests for Convert.

Added back plugs for Decimal.
Plugged Int32.ToString(IFormatProvider).
This commit is contained in:
José Pedro 2018-02-26 00:22:06 +00:00
parent fc7771494e
commit 5e51301d5c
No known key found for this signature in database
GPG key ID: B8247B9301707B83
4 changed files with 34 additions and 8 deletions

View file

@ -45,6 +45,7 @@ namespace Cosmos.Compiler.Tests.Bcl
SingleTest.Execute();
DoubleTest.Execute();
MathTest.Execute();
ConvertTests.Execute();
//mDebugger.Send("Thread test start of 500 ms");
//ThreadTest.Execute();

View file

@ -0,0 +1,29 @@
using System;
using Cosmos.TestRunner;
namespace Cosmos.Compiler.Tests.Bcl.System
{
internal static class ConvertTests
{
public static void Execute()
{
var number = 5;
var numberToString = Convert.ToString(number);
Assert.IsTrue(numberToString == "5", $"Convert.ToString(Int32) doesn't work. Result: {numberToString}");
var numberToByte = Convert.ToByte(number);
Assert.IsTrue(numberToByte == 5, $"Convert.ToByte(Int32) doesn't work. Result: {numberToByte}");
var byteToSingle = Convert.ToSingle(numberToByte);
Assert.IsTrue(EqualityHelper.SinglesAreEqual(byteToSingle, 5.0f), $"Convert.ToSingle(Byte) doesn't work. Result: {byteToSingle}");
var numberToBase64 = Convert.ToBase64String(BitConverter.GetBytes(number));
Assert.IsTrue(numberToBase64 == "BQAAAA==", $"Convert.ToBase64String(byte[]) doesn't work. Result: {numberToBase64}");
}
}
}

View file

@ -1,12 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Cosmos.IL2CPU.Plugs;
using IL2CPU.API.Attribs;
namespace Cosmos.System.Plugs.System
namespace Cosmos.System_Plugs.System
{
[Plug(Target = typeof(decimal))]
public static class DecimalImpl

View file

@ -1,7 +1,5 @@
using System;
using Cosmos.Common;
using Cosmos.Debug.Kernel;
using IL2CPU.API;
using IL2CPU.API.Attribs;
namespace Cosmos.System_Plugs.System
@ -14,6 +12,8 @@ namespace Cosmos.System_Plugs.System
return StringHelper.GetNumberString(aThis);
}
public static string ToString(ref int aThis, IFormatProvider aFormatProvider) => ToString(ref aThis);
public static Int32 Parse(string s)
{
const string digits = "0123456789";