diff --git a/Test.sln b/Test.sln index f5490f973..4dd53a51d 100644 --- a/Test.sln +++ b/Test.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27130.2010 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28922.388 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{DAEF99B5-22F0-4885-B45B-9B600B857E1C}" EndProject @@ -162,6 +162,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cosmos.System.Tests", "Test EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cosmos.Kernel.Tests.DiskManager", "Tests\Kernels\Cosmos.Kernel.Tests.DiskManager\Cosmos.Kernel.Tests.DiskManager.csproj", "{BB6A5306-4C7A-4973-A48E-9FE3E683EAEC}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cosmos.Compiler.Tests.BclSystem", "Tests\Kernels\Cosmos.Compiler.Tests.Bcl.System\Cosmos.Compiler.Tests.BclSystem.csproj", "{30D9FA9C-0B4D-40FF-8903-6B9E9C825729}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -170,14 +172,6 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {0CDB3F6E-7971-426B-81F8-38B966A54C2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0CDB3F6E-7971-426B-81F8-38B966A54C2B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0CDB3F6E-7971-426B-81F8-38B966A54C2B}.Debug|x86.ActiveCfg = Debug|Any CPU - {0CDB3F6E-7971-426B-81F8-38B966A54C2B}.Debug|x86.Build.0 = Debug|Any CPU - {0CDB3F6E-7971-426B-81F8-38B966A54C2B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0CDB3F6E-7971-426B-81F8-38B966A54C2B}.Release|Any CPU.Build.0 = Release|Any CPU - {0CDB3F6E-7971-426B-81F8-38B966A54C2B}.Release|x86.ActiveCfg = Release|Any CPU - {0CDB3F6E-7971-426B-81F8-38B966A54C2B}.Release|x86.Build.0 = Release|Any CPU {F74A4B2B-02DA-455A-89FB-803A442B5B2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F74A4B2B-02DA-455A-89FB-803A442B5B2C}.Debug|Any CPU.Build.0 = Debug|Any CPU {F74A4B2B-02DA-455A-89FB-803A442B5B2C}.Debug|x86.ActiveCfg = Debug|Any CPU @@ -539,14 +533,6 @@ Global {FF46829E-B612-4D36-80BE-ED04521AD91A}.Release|Any CPU.Build.0 = Release|Any CPU {FF46829E-B612-4D36-80BE-ED04521AD91A}.Release|x86.ActiveCfg = Release|Any CPU {FF46829E-B612-4D36-80BE-ED04521AD91A}.Release|x86.Build.0 = Release|Any CPU - {D0EABA08-88C9-4F7C-BCA9-361B58B20D67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D0EABA08-88C9-4F7C-BCA9-361B58B20D67}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D0EABA08-88C9-4F7C-BCA9-361B58B20D67}.Debug|x86.ActiveCfg = Debug|Any CPU - {D0EABA08-88C9-4F7C-BCA9-361B58B20D67}.Debug|x86.Build.0 = Debug|Any CPU - {D0EABA08-88C9-4F7C-BCA9-361B58B20D67}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D0EABA08-88C9-4F7C-BCA9-361B58B20D67}.Release|Any CPU.Build.0 = Release|Any CPU - {D0EABA08-88C9-4F7C-BCA9-361B58B20D67}.Release|x86.ActiveCfg = Release|Any CPU - {D0EABA08-88C9-4F7C-BCA9-361B58B20D67}.Release|x86.Build.0 = Release|Any CPU {D21A7C6C-A696-4EC3-84EB-70700C1E3B34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D21A7C6C-A696-4EC3-84EB-70700C1E3B34}.Debug|Any CPU.Build.0 = Debug|Any CPU {D21A7C6C-A696-4EC3-84EB-70700C1E3B34}.Debug|x86.ActiveCfg = Debug|Any CPU @@ -635,12 +621,19 @@ Global {BB6A5306-4C7A-4973-A48E-9FE3E683EAEC}.Release|Any CPU.Build.0 = Release|Any CPU {BB6A5306-4C7A-4973-A48E-9FE3E683EAEC}.Release|x86.ActiveCfg = Release|Any CPU {BB6A5306-4C7A-4973-A48E-9FE3E683EAEC}.Release|x86.Build.0 = Release|Any CPU + {30D9FA9C-0B4D-40FF-8903-6B9E9C825729}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {30D9FA9C-0B4D-40FF-8903-6B9E9C825729}.Debug|Any CPU.Build.0 = Debug|Any CPU + {30D9FA9C-0B4D-40FF-8903-6B9E9C825729}.Debug|x86.ActiveCfg = Debug|Any CPU + {30D9FA9C-0B4D-40FF-8903-6B9E9C825729}.Debug|x86.Build.0 = Debug|Any CPU + {30D9FA9C-0B4D-40FF-8903-6B9E9C825729}.Release|Any CPU.ActiveCfg = Release|Any CPU + {30D9FA9C-0B4D-40FF-8903-6B9E9C825729}.Release|Any CPU.Build.0 = Release|Any CPU + {30D9FA9C-0B4D-40FF-8903-6B9E9C825729}.Release|x86.ActiveCfg = Release|Any CPU + {30D9FA9C-0B4D-40FF-8903-6B9E9C825729}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {0CDB3F6E-7971-426B-81F8-38B966A54C2B} = {E9CD521E-C386-466D-B5F7-A5EB19A61625} {F74A4B2B-02DA-455A-89FB-803A442B5B2C} = {DAEF99B5-22F0-4885-B45B-9B600B857E1C} {4F903492-CCA6-4FD9-A1B6-5E4CC0CE7767} = {C286932C-3F6D-47F0-BEEF-26843D1BB11B} {34AEEB7C-FD5D-4B15-A830-B429681844BD} = {C286932C-3F6D-47F0-BEEF-26843D1BB11B} @@ -702,7 +695,6 @@ Global {3DD192AF-2D72-449F-936C-ED8734225B18} = {C286932C-3F6D-47F0-BEEF-26843D1BB11B} {929EE8ED-6AD3-4442-A0C1-EC70665F2DCF} = {99192440-2DD7-4E71-B730-D44A73F46533} {FF46829E-B612-4D36-80BE-ED04521AD91A} = {E9CD521E-C386-466D-B5F7-A5EB19A61625} - {D0EABA08-88C9-4F7C-BCA9-361B58B20D67} = {E9CD521E-C386-466D-B5F7-A5EB19A61625} {D21A7C6C-A696-4EC3-84EB-70700C1E3B34} = {ECEA7778-E786-4317-90B9-A2D4427CB91C} {0DF97CAC-220B-4DAD-B397-42E394255763} = {ECEA7778-E786-4317-90B9-A2D4427CB91C} {2992AA07-E126-4EE0-B31C-D0B2ADE3393A} = {0E67EFE8-5944-4F6C-8B47-C5E06D4C79F5} @@ -714,6 +706,7 @@ Global {99E24E61-0743-47FF-AB0A-55A36C5E184C} = {52D81759-C7CC-427F-8C96-89CA10C914B5} {970C5E07-5D09-4882-949C-A8E876B22732} = {52D81759-C7CC-427F-8C96-89CA10C914B5} {BB6A5306-4C7A-4973-A48E-9FE3E683EAEC} = {29EEC029-6A2B-478A-B6E5-D63A91388ABA} + {30D9FA9C-0B4D-40FF-8903-6B9E9C825729} = {ECEA7778-E786-4317-90B9-A2D4427CB91C} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {4418C803-277E-448F-A0A0-52788FA215AD} diff --git a/Tests/Cosmos.TestRunner.Full/Cosmos.TestRunner.Full.csproj b/Tests/Cosmos.TestRunner.Full/Cosmos.TestRunner.Full.csproj index 420536e31..a2fb37690 100644 --- a/Tests/Cosmos.TestRunner.Full/Cosmos.TestRunner.Full.csproj +++ b/Tests/Cosmos.TestRunner.Full/Cosmos.TestRunner.Full.csproj @@ -18,6 +18,7 @@ + diff --git a/Tests/Cosmos.TestRunner.Full/TestKernelSets.cs b/Tests/Cosmos.TestRunner.Full/TestKernelSets.cs index 83ab5528e..c03b31ceb 100644 --- a/Tests/Cosmos.TestRunner.Full/TestKernelSets.cs +++ b/Tests/Cosmos.TestRunner.Full/TestKernelSets.cs @@ -18,6 +18,7 @@ namespace Cosmos.TestRunner.Full yield return typeof(BoxingTests.Kernel); yield return typeof(Cosmos.Compiler.Tests.TypeSystem.Kernel); yield return typeof(Cosmos.Compiler.Tests.Bcl.Kernel); + yield return typeof(Cosmos.Compiler.Tests.Bcl.System.Kernel); //yield return typeof(Cosmos.Compiler.Tests.Encryption.Kernel); yield return typeof(Cosmos.Compiler.Tests.Exceptions.Kernel); yield return typeof(Cosmos.Compiler.Tests.MethodTests.Kernel); diff --git a/Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/Cosmos.Compiler.Tests.BclSystem.csproj b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/Cosmos.Compiler.Tests.BclSystem.csproj new file mode 100644 index 000000000..f9b905215 --- /dev/null +++ b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/Cosmos.Compiler.Tests.BclSystem.csproj @@ -0,0 +1,18 @@ + + + + netcoreapp2.0 + True + CA2242;$(NoWarn) + true + + + + + + + + + + + diff --git a/Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/Kernel.cs b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/Kernel.cs new file mode 100644 index 000000000..7730642eb --- /dev/null +++ b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/Kernel.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections; + +using Cosmos.TestRunner; +using Sys = Cosmos.System; + +using Cosmos.Compiler.Tests.Bcl.CSharp; + +namespace Cosmos.Compiler.Tests.Bcl.System +{ + public class Kernel : Sys.Kernel + { + protected override void BeforeRun() + { + Console.WriteLine("Cosmos booted successfully. Starting BCL System tests now please wait..."); + } + + protected override void Run() + { + try + { + mDebugger.Send("Run"); + + + // System + ObjectTests.Execute(); + ArrayTests.Execute(); + StringTest.Execute(); + ByteTest.Execute(); + SByteTest.Execute(); + Int16Test.Execute(); + UInt16Test.Execute(); + Int32Test.Execute(); + UInt32Test.Execute(); + Int64Test.Execute(); + UInt64Test.Execute(); + CharTest.Execute(); + BooleanTest.Execute(); + SingleTest.Execute(); + DoubleTest.Execute(); + MathTest.Execute(); + ConvertTests.Execute(); + DateTimeTests.Execute(); + TimeSpanTests.Execute(); + + + TestController.Completed(); + } + catch (Exception e) + { + mDebugger.Send("Exception occurred: " + e.Message); + mDebugger.Send(e.Message); + Console.WriteLine("Exception occurred"); + Console.WriteLine(e.Message); + TestController.Failed(); + } + } + } +} diff --git a/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/ArrayTests.cs b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/ArrayTests.cs similarity index 100% rename from Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/ArrayTests.cs rename to Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/ArrayTests.cs diff --git a/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/BooleanTest.cs b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/BooleanTest.cs similarity index 100% rename from Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/BooleanTest.cs rename to Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/BooleanTest.cs diff --git a/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/ByteTest.cs b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/ByteTest.cs similarity index 100% rename from Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/ByteTest.cs rename to Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/ByteTest.cs diff --git a/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/CharTest.cs b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/CharTest.cs similarity index 100% rename from Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/CharTest.cs rename to Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/CharTest.cs diff --git a/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/ConvertTests.cs b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/ConvertTests.cs similarity index 100% rename from Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/ConvertTests.cs rename to Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/ConvertTests.cs diff --git a/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/DateTimeTests.cs b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/DateTimeTests.cs similarity index 100% rename from Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/DateTimeTests.cs rename to Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/DateTimeTests.cs diff --git a/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/DecimalTest.cs b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/DecimalTest.cs similarity index 100% rename from Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/DecimalTest.cs rename to Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/DecimalTest.cs diff --git a/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/DoubleTest.cs b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/DoubleTest.cs similarity index 100% rename from Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/DoubleTest.cs rename to Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/DoubleTest.cs diff --git a/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/Int16Test.cs b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/Int16Test.cs similarity index 100% rename from Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/Int16Test.cs rename to Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/Int16Test.cs diff --git a/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/Int32Test.cs b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/Int32Test.cs similarity index 100% rename from Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/Int32Test.cs rename to Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/Int32Test.cs diff --git a/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/Int64Test.cs b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/Int64Test.cs similarity index 100% rename from Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/Int64Test.cs rename to Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/Int64Test.cs diff --git a/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/MathTest.cs b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/MathTest.cs similarity index 100% rename from Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/MathTest.cs rename to Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/MathTest.cs diff --git a/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/ObjectTests.cs b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/ObjectTests.cs similarity index 100% rename from Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/ObjectTests.cs rename to Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/ObjectTests.cs diff --git a/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/SByteTest.cs b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/SByteTest.cs similarity index 100% rename from Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/SByteTest.cs rename to Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/SByteTest.cs diff --git a/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/SingleTest.cs b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/SingleTest.cs similarity index 100% rename from Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/SingleTest.cs rename to Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/SingleTest.cs diff --git a/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/StringTest.cs b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/StringTest.cs similarity index 57% rename from Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/StringTest.cs rename to Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/StringTest.cs index 1db830d1d..0e5cf52cc 100644 --- a/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/StringTest.cs +++ b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/StringTest.cs @@ -54,6 +54,50 @@ namespace Cosmos.Compiler.Tests.Bcl.System Assert.IsTrue(test.EndsWith("string."), "string.EndsWith(string) is not reporting false even though the string actually does end with the substring."); Assert.IsFalse(test.EndsWith("sentence."), "string.EndsWith(string) is not reporting true even though the string actually doesn't end with the substring."); + Assert.IsTrue(test.IndexOf(string.Empty, 10) == 10, "string.IndexOf currectly returns for empty string with start index"); + Assert.IsTrue(test.IndexOf(string.Empty, 10, 10) == 10, "string.IndexOf currectly returns for empty string with start index and count"); + Assert.IsTrue(test.IndexOf('T') == 0, "string.IndexOf finds the only occurance of a letter"); + Assert.IsTrue(test.IndexOf('A') == -1, "string.IndexOf correctly returns when it does not find something"); + Assert.IsTrue(test.IndexOf("ABCDE") == -1, "string.IndexOf correctly returns when it does not find something"); + Assert.IsTrue(test.IndexOf('.') == test.Length - 1, "string.IndexOf finds the only occurance of a letter at the end of the string"); + Assert.IsTrue(test.IndexOf('i') == 2, "string.IndexOf finds the first of multiple occurances of a letter"); + Assert.IsTrue(test.IndexOf('i', 8) == 18, "string.IndexOf with start point finds the first of multiple occurances of a letter"); + Assert.IsTrue(test.IndexOf("is") == 2, "string.IndexOf finds the first of multiple occurances of a string"); + Assert.IsTrue(test.IndexOf("is", 3) == 5, "string.IndexOf with start point finds the first of multiple occurances of a string"); + Assert.IsTrue(test.IndexOf("is", 3, 5) == 5, "string.IndexOf with start point and count finds the first of multiple occurances of a string"); + Assert.IsTrue(test.IndexOf("is", 3, 1) == -1, "string.IndexOf with start point and count correctly returns if it does not find something"); + + Assert.IsTrue(test.IndexOfAny(new[] { 'T', 'h', 'i', 's' }) == 0, "string.IndexOfAny finds the first one"); + Assert.IsTrue(test.IndexOfAny(new[] { 'A', 'B', 'C' }) == -1, "string.IndexOfAny finds none if none are present"); + + Assert.IsTrue(test.LastIndexOf(string.Empty, 100) == test.Length, "string.LastIndexOf handles empty correctly"); + Assert.IsTrue(test.LastIndexOf('T') == 0, "string.LastIndexOf finds the only occurance of a letter"); + Assert.IsTrue(test.LastIndexOf('.') == test.Length - 1, "string.LastIndexOf finds the only occurance of a letter at the end of the string"); + Assert.IsTrue(test.LastIndexOf('i') == test.Length - 4, "string.IndexOf finds the last of multiple occurances of a letter"); + + Assert.IsTrue(test.LastIndexOfAny(new[] { 'T', 'h', 'i', 's' }) == 18, "string.LastIndexOfAny finds the first one"); + Assert.IsTrue(test.LastIndexOfAny(new[] { 'A', 'B', 'C' }) == -1, "string.LastIndexOfAny finds none if none are present"); + + + Assert.IsTrue(test.Insert(0, "A") != test, "string.Insert creates a new instance"); + Assert.IsTrue(test.Insert(1, "A") == "TAhis is a test string.", "string.Insert correctly inserts a single character"); + Assert.IsTrue(test.Insert(2, "ABCDE F") == "ThABCDE Fis is a test string.", "string.Insert correctly adds multiple characters"); + Assert.IsTrue(test.Insert(test.Length, "END") == "This is a test string.END", "string.Insert correctly inserts at the end of the string"); + + Assert.IsTrue(test.Remove(1) == "T", "string.Remove correctly removes all other characters"); + Assert.IsTrue(test.Remove(0) == "", "string.Remove correctly removes all characters"); + Assert.IsTrue(test.Remove(0, 2) == "is is a test string.", "string.Remove works with count"); + + Assert.IsTrue(" a ".Trim() == "a", "string.Trim trims both front and back"); + Assert.IsTrue("abababababa".Trim(new[] { 'a', 'b' }) == "", "string.Trim works with custom chars"); + Assert.IsTrue("abCababababa".Trim(new[] { 'a', 'b' }) == "C", "string.Trim works with custom chars"); + Assert.IsTrue("a".Trim() == "a", "string.Trim trims both front and back"); + Assert.IsTrue(" a ".TrimStart() == "a ", "string.TrimStart trims front"); + Assert.IsTrue("a".TrimStart() == "a", "string.Trim trims front"); + Assert.IsTrue(" a ".TrimEnd() == " a", "string.TrimEnd trims back"); + Assert.IsTrue("a".TrimEnd() == "a", "string.TrimEnd trims back"); + + string lower_expected = "this is a test string."; string upper_expected = "THIS IS A TEST STRING."; Assert.IsTrue((test.ToLower() == lower_expected), "string.ToLower() does not work."); diff --git a/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/TimeSpanTests.cs b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/TimeSpanTests.cs similarity index 100% rename from Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/TimeSpanTests.cs rename to Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/TimeSpanTests.cs diff --git a/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/UInt16Test.cs b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/UInt16Test.cs similarity index 100% rename from Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/UInt16Test.cs rename to Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/UInt16Test.cs diff --git a/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/UInt32Test.cs b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/UInt32Test.cs similarity index 100% rename from Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/UInt32Test.cs rename to Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/UInt32Test.cs diff --git a/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/UInt64Test.cs b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/UInt64Test.cs similarity index 100% rename from Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/UInt64Test.cs rename to Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/UInt64Test.cs diff --git a/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/Helpers/EqualityHelper.cs b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/Helpers/EqualityHelper.cs index d0b252e4d..97353f8c2 100644 --- a/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/Helpers/EqualityHelper.cs +++ b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/Helpers/EqualityHelper.cs @@ -2,7 +2,7 @@ namespace Cosmos.Compiler.Tests.Bcl { - internal static class EqualityHelper + public static class EqualityHelper { public static bool SinglesAreEqual(float left, float right) { diff --git a/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/Kernel.cs b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/Kernel.cs index a20aa466d..ce2b0e66d 100644 --- a/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/Kernel.cs +++ b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/Kernel.cs @@ -29,27 +29,6 @@ namespace Cosmos.Compiler.Tests.Bcl WhileLoopTests.Execute(); ForeachLoopTests.Execute(); - // System - ObjectTests.Execute(); - ArrayTests.Execute(); - StringTest.Execute(); - ByteTest.Execute(); - SByteTest.Execute(); - Int16Test.Execute(); - UInt16Test.Execute(); - Int32Test.Execute(); - UInt32Test.Execute(); - Int64Test.Execute(); - UInt64Test.Execute(); - CharTest.Execute(); - BooleanTest.Execute(); - SingleTest.Execute(); - DoubleTest.Execute(); - MathTest.Execute(); - ConvertTests.Execute(); - DateTimeTests.Execute(); - TimeSpanTests.Execute(); - //mDebugger.Send("Thread test start of 500 ms"); //ThreadTest.Execute(); //mDebugger.Send("Thread test end"); diff --git a/source/Cosmos.Core_Plugs/System/StringImpl.cs b/source/Cosmos.Core_Plugs/System/StringImpl.cs index 693140891..ff6a34ace 100644 --- a/source/Cosmos.Core_Plugs/System/StringImpl.cs +++ b/source/Cosmos.Core_Plugs/System/StringImpl.cs @@ -485,7 +485,19 @@ namespace Cosmos.Core_Plugs.System public static int IndexOf(string aThis, string aSubstring, int aIdx, int aLength, StringComparison aComparison) { - return boyerMooreHorsepool(aSubstring, aThis.Substring(aIdx, aLength)); + if (aSubstring == String.Empty) + { + return aIdx; + } + int pos = boyerMooreHorsepool(aSubstring, aThis.Substring(aIdx, aLength)); + if (pos == -1) + { + return pos; + } + else + { + return pos + aIdx; //To account for offset + } } public static bool Contains(string aThis, string value) @@ -624,9 +636,38 @@ namespace Cosmos.Core_Plugs.System return aThis.Substring(0, aStartPos) + aValue + aThis.Substring(aStartPos); } + public static int LastIndexOf(string aThis, string aString, int aIndex) + { + return LastIndexOf(aThis, aString, aIndex, aThis.Length - aIndex); + } + + public static int LastIndexOf(string aThis, string aString, int aIndex, int aCount) + { + if (aString == String.Empty) + { + if (aIndex > aThis.Length) + { + return aThis.Length; + } + return aIndex; + } + + string curr = ""; + char[] chars = aThis.ToCharArray(); + for (int i = 0; i < aCount; i++) + { + curr = chars[aThis.Length - i - 1] + curr; + if (curr.StartsWith(aString)) + { + return aThis.Length - i - 1; + } + } + return -1; + } + public static int LastIndexOf(string aThis, char aChar, int aStartIndex, int aCount) { - return LastIndexOfAny(aThis, new[] { aChar }, aStartIndex, aCount); + return LastIndexOf(aThis, new string(aChar, 1), aStartIndex, aCount); } public static int LastIndexOfAny(string aThis, char[] aChars, int aStartIndex, int aCount) @@ -976,7 +1017,7 @@ namespace Cosmos.Core_Plugs.System /* * This optimization is not taking effect yet in Cosmos as String.Intern() is not implemented - */ + */ if (ReferenceEquals(strA, strB)) { mDebugger.SendInternal($"strA ({strA}) is the same object of strB ({strB}) returning 0");