Skip to content

Commit

Permalink
Merge pull request CosmosOS#914 from CosmosOS/convert-tests
Browse files Browse the repository at this point in the history
Fixed Convert and added tests
  • Loading branch information
jp2masa authored Feb 26, 2018
2 parents fc77714 + 5e51301 commit 56dab0a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
1 change: 1 addition & 0 deletions Tests/Cosmos.Compiler.Tests.Bcl/Kernel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ protected override void Run()
SingleTest.Execute();
DoubleTest.Execute();
MathTest.Execute();
ConvertTests.Execute();

//mDebugger.Send("Thread test start of 500 ms");
//ThreadTest.Execute();
Expand Down
29 changes: 29 additions & 0 deletions Tests/Cosmos.Compiler.Tests.Bcl/System/ConvertTests.cs
Original file line number Diff line number Diff line change
@@ -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}");
}
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions source/Cosmos.System2_Plugs/System/Int32Impl.cs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -14,6 +12,8 @@ public static string ToString(ref int aThis)
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";
Expand Down

0 comments on commit 56dab0a

Please sign in to comment.