mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-11 10:41:33 +00:00
Added tests for Convert.
Added back plugs for Decimal. Plugged Int32.ToString(IFormatProvider).
This commit is contained in:
parent
fc7771494e
commit
5e51301d5c
4 changed files with 34 additions and 8 deletions
|
|
@ -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();
|
||||
|
|
|
|||
29
Tests/Cosmos.Compiler.Tests.Bcl/System/ConvertTests.cs
Normal file
29
Tests/Cosmos.Compiler.Tests.Bcl/System/ConvertTests.cs
Normal 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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
@ -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";
|
||||
|
|
|
|||
Loading…
Reference in a new issue