summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kotas <jkotas@microsoft.com>2017-08-28 13:04:24 -0700
committerJan Kotas <jkotas@microsoft.com>2017-08-28 14:43:07 -0700
commit272f640378ebcc0fe9a7e2a82453fa160595f081 (patch)
tree482ef439098b758bd1ea8a857aac3d31bd99b081
parent7bf6686e042d49db54e059d212b4035694f5d3ee (diff)
downloadcoreclr-272f640378ebcc0fe9a7e2a82453fa160595f081.tar.gz
coreclr-272f640378ebcc0fe9a7e2a82453fa160595f081.tar.bz2
coreclr-272f640378ebcc0fe9a7e2a82453fa160595f081.zip
Fix build breaks - delete parse tests that are redundant with CoreFX
-rw-r--r--tests/src/CoreMangLib/cti/system/boolean/BooleanParse.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/boolean/BooleanTryParse.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/boolean/booleanparse.cs188
-rw-r--r--tests/src/CoreMangLib/cti/system/boolean/booleantryparse.cs97
-rw-r--r--tests/src/CoreMangLib/cti/system/byte/ByteParse1.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/byte/ByteParse3.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/byte/ByteTryParse.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/byte/byteparse1.cs329
-rw-r--r--tests/src/CoreMangLib/cti/system/byte/byteparse3.cs344
-rw-r--r--tests/src/CoreMangLib/cti/system/byte/bytetryparse.cs494
-rw-r--r--tests/src/CoreMangLib/cti/system/char/CharTryParse.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/char/chartryparse.cs92
-rw-r--r--tests/src/CoreMangLib/cti/system/decimal/DecimalParse.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/decimal/DecimalParse2.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/decimal/DecimalParse3.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/decimal/DecimalParse4.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/decimal/DecimalTryParse.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/decimal/decimalparse.cs171
-rw-r--r--tests/src/CoreMangLib/cti/system/decimal/decimalparse2.cs414
-rw-r--r--tests/src/CoreMangLib/cti/system/decimal/decimalparse3.cs417
-rw-r--r--tests/src/CoreMangLib/cti/system/decimal/decimalparse4.cs292
-rw-r--r--tests/src/CoreMangLib/cti/system/decimal/decimaltryparse.cs839
-rw-r--r--tests/src/CoreMangLib/cti/system/double/DoubleParse3.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/double/DoubleTryParse.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/double/doubleparse3.cs612
-rw-r--r--tests/src/CoreMangLib/cti/system/double/doubletryparse.cs606
-rw-r--r--tests/src/CoreMangLib/cti/system/int/Int32Parse1.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/int/Int32Parse2.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/int/Int32Parse3.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/int/Int32Parse4.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/int/Int32TryParse.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/int/int32parse1.cs289
-rw-r--r--tests/src/CoreMangLib/cti/system/int/int32parse2.cs360
-rw-r--r--tests/src/CoreMangLib/cti/system/int/int32parse3.cs340
-rw-r--r--tests/src/CoreMangLib/cti/system/int/int32parse4.cs238
-rw-r--r--tests/src/CoreMangLib/cti/system/int/int32tryparse.cs565
-rw-r--r--tests/src/CoreMangLib/cti/system/int16/Int16Parse1.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/int16/Int16Parse2.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/int16/Int16Parse3.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/int16/Int16TryParse.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/int16/int16parse1.cs337
-rw-r--r--tests/src/CoreMangLib/cti/system/int16/int16parse2.cs584
-rw-r--r--tests/src/CoreMangLib/cti/system/int16/int16parse3.cs454
-rw-r--r--tests/src/CoreMangLib/cti/system/int16/int16tryparse.cs553
-rw-r--r--tests/src/CoreMangLib/cti/system/int64/Int64Parse1.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/int64/Int64Parse2.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/int64/Int64Parse3.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/int64/Int64TryParse.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/int64/int64parse1.cs341
-rw-r--r--tests/src/CoreMangLib/cti/system/int64/int64parse2.cs326
-rw-r--r--tests/src/CoreMangLib/cti/system/int64/int64parse3.cs398
-rw-r--r--tests/src/CoreMangLib/cti/system/int64/int64tryparse.cs571
-rw-r--r--tests/src/CoreMangLib/cti/system/sbyte/SByteParse1.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/sbyte/SByteParse2.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/sbyte/SByteParse3.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/sbyte/SByteTryParse.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/sbyte/sbyteparse1.cs253
-rw-r--r--tests/src/CoreMangLib/cti/system/sbyte/sbyteparse2.cs330
-rw-r--r--tests/src/CoreMangLib/cti/system/sbyte/sbyteparse3.cs402
-rw-r--r--tests/src/CoreMangLib/cti/system/sbyte/sbytetryparse.cs499
-rw-r--r--tests/src/CoreMangLib/cti/system/single/SingleParse1.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/single/SingleParse2.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/single/SingleTryParse.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/single/singleparse1.csbin21004 -> 0 bytes
-rw-r--r--tests/src/CoreMangLib/cti/system/single/singleparse2.csbin35332 -> 0 bytes
-rw-r--r--tests/src/CoreMangLib/cti/system/single/singletryparse.cs615
-rw-r--r--tests/src/CoreMangLib/cti/system/uint16/UInt16Parse1.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/uint16/UInt16Parse2.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/uint16/UInt16Parse3.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/uint16/UInt16TryParse.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/uint16/uint16parse1.cs284
-rw-r--r--tests/src/CoreMangLib/cti/system/uint16/uint16parse2.cs503
-rw-r--r--tests/src/CoreMangLib/cti/system/uint16/uint16parse3.cs548
-rw-r--r--tests/src/CoreMangLib/cti/system/uint16/uint16tryparse.cs554
-rw-r--r--tests/src/CoreMangLib/cti/system/uint32/UInt32Parse1.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/uint32/UInt32Parse2.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/uint32/UInt32Parse3.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/uint32/UInt32TryParse.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/uint32/uint32parse1.cs357
-rw-r--r--tests/src/CoreMangLib/cti/system/uint32/uint32parse2.cs392
-rw-r--r--tests/src/CoreMangLib/cti/system/uint32/uint32parse3.cs334
-rw-r--r--tests/src/CoreMangLib/cti/system/uint32/uint32tryparse.cs556
-rw-r--r--tests/src/CoreMangLib/cti/system/uint64/UInt64Parse1.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/uint64/UInt64Parse2.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/uint64/UInt64Parse3.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/uint64/UInt64TryParse.csproj40
-rw-r--r--tests/src/CoreMangLib/cti/system/uint64/uint64parse1.cs354
-rw-r--r--tests/src/CoreMangLib/cti/system/uint64/uint64parse2.cs391
-rw-r--r--tests/src/CoreMangLib/cti/system/uint64/uint64parse3.cs331
-rw-r--r--tests/src/CoreMangLib/cti/system/uint64/uint64tryparse.cs561
90 files changed, 0 insertions, 19315 deletions
diff --git a/tests/src/CoreMangLib/cti/system/boolean/BooleanParse.csproj b/tests/src/CoreMangLib/cti/system/boolean/BooleanParse.csproj
deleted file mode 100644
index d9bde7654d..0000000000
--- a/tests/src/CoreMangLib/cti/system/boolean/BooleanParse.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="booleanparse.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/boolean/BooleanTryParse.csproj b/tests/src/CoreMangLib/cti/system/boolean/BooleanTryParse.csproj
deleted file mode 100644
index df1a740778..0000000000
--- a/tests/src/CoreMangLib/cti/system/boolean/BooleanTryParse.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="booleantryparse.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/boolean/booleanparse.cs b/tests/src/CoreMangLib/cti/system/boolean/booleanparse.cs
deleted file mode 100644
index 0090df02cd..0000000000
--- a/tests/src/CoreMangLib/cti/system/boolean/booleanparse.cs
+++ /dev/null
@@ -1,188 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-
-/// <summary>
-/// to test System.Boolean.Parse(string)
-/// </summary>
-public class BooleanParse
-{
- // not using Boolean.TrueString/FalseString in order to not test circularly
- const string cTRUE = "True";
- const string cFALSE = "False";
-
- public static int Main()
- {
- BooleanParse testCase = new BooleanParse();
-
- TestLibrary.TestFramework.BeginTestCase("Boolean.Parse");
- if (testCase.RunTests())
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("PASS");
- return 100;
- }
- else
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("FAIL");
- return 0;
- }
- }
-
- public bool RunTests()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.LogInformation("[Positive]");
- retVal = PosTest1() && retVal;
- retVal = PosTest2() && retVal;
- retVal = PosTest3() && retVal;
- retVal = PosTest4() && retVal;
- retVal = PosTest5() && retVal;
- retVal = PosTest6() && retVal;
- retVal = PosTest7() && retVal;
-
- TestLibrary.TestFramework.LogInformation("[Negative]");
- retVal = NegTest1() && retVal;
- retVal = NegTest2() && retVal;
- retVal = NegTest3() && retVal;
- retVal = NegTest4() && retVal;
- retVal = NegTest5() && retVal;
- retVal = NegTest6() && retVal;
- retVal = NegTest7() && retVal;
-
- return retVal;
- }
-
-
-
- public bool PosTest1()
- {
- return PosTest("001", cFALSE, false);
- }
-
- public bool PosTest2()
- {
- return PosTest("002", cTRUE, true);
- }
-
- public bool PosTest3()
- {
- return PosTest("003", "\t"+cTRUE, true);
- }
- public bool PosTest4()
- {
- return PosTest("004", cFALSE+" ", false);
- }
-
- public bool PosTest5()
- {
- return PosTest("005", " "+cFALSE+"\t ", false);
- }
-
- public bool PosTest6()
- {
- return PosTest("006", "fAlse", false);
- }
-
- public bool PosTest7()
- {
- return PosTest("007", "tRUE", true);
- }
-
- bool PosTest(string id, string str, bool expect)
- {
- bool retVal = true;
- try
- {
- if (Boolean.Parse(str) != expect)
- {
- TestLibrary.TestFramework.LogError(id, String.Format("expect Boolean.Parse(\"{0}\") == {1}",str, expect));
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError(id, "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
-
-
- public bool NegTest1()
- {
- bool retVal = false;
- try
- {
- bool v = Boolean.Parse(null);
- }
- catch (ArgumentNullException)
- {
- // that exception is what's expected
- retVal = true;
- return retVal;
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("001", "Unexpected exception: " + e);
- retVal = false;
- return retVal;
- }
-
- TestLibrary.TestFramework.LogError("001", "expect a FormatException on Boolean.Parse(null)");
- return retVal;
- }
-
- public bool NegTest2()
- {
- return NegTest("002", "0");
- }
- public bool NegTest3()
- {
- return NegTest("003", "1");
- }
- public bool NegTest4()
- {
- return NegTest("004", "Yes");
- }
- public bool NegTest5()
- {
- return NegTest("005", String.Empty);
- }
- public bool NegTest6()
- {
- return NegTest("006", cTRUE + cFALSE);
- }
-
- public bool NegTest7()
- {
- return NegTest("007", cFALSE +" "+ cTRUE);
- }
-
- bool NegTest(string id, string str)
- {
- bool retVal = false;
- try
- {
- bool v = Boolean.Parse(str);
- }
- catch ( FormatException )
- {
- // that exception is what's expected
- retVal = true;
- return retVal;
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError(id, "Unexpected exception: " + e);
- retVal = false;
- return retVal;
- }
-
- TestLibrary.TestFramework.LogError(id, String.Format("expect a FormatException on Boolean.Parse(\"{0}\")", str));
- return retVal;
- }
-}
diff --git a/tests/src/CoreMangLib/cti/system/boolean/booleantryparse.cs b/tests/src/CoreMangLib/cti/system/boolean/booleantryparse.cs
deleted file mode 100644
index ae745ba29a..0000000000
--- a/tests/src/CoreMangLib/cti/system/boolean/booleantryparse.cs
+++ /dev/null
@@ -1,97 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-
-// This test was ported over to CoreCLR from Co7521TryParse.cs
-// Tests Boolean.TryParse(str)
-// 2003/02/25 KatyK
-// 2007/06/28 adapted by MarielY
-public class BooleanTryParse
-{
- static bool verbose = false;
-
- public static int Main()
- {
- bool passed = true;
-
- try
- {
- // Success cases
- passed &= VerifyBooleanTryParse("True", true, true);
- passed &= VerifyBooleanTryParse("true", true, true);
- passed &= VerifyBooleanTryParse("TRUE", true, true);
- passed &= VerifyBooleanTryParse("tRuE", true, true);
- passed &= VerifyBooleanTryParse("False", false, true);
- passed &= VerifyBooleanTryParse("false", false, true);
- passed &= VerifyBooleanTryParse("FALSE", false, true);
- passed &= VerifyBooleanTryParse("fAlSe", false, true);
- passed &= VerifyBooleanTryParse(" True ", true, true);
- passed &= VerifyBooleanTryParse("False ", false, true);
- passed &= VerifyBooleanTryParse("True\0", true, true); // VSWhidbey 465401
- passed &= VerifyBooleanTryParse("False\0", false, true);
- passed &= VerifyBooleanTryParse("True\0 ", true, true);
- passed &= VerifyBooleanTryParse(" \0 \0 True \0 ", true, true);
- passed &= VerifyBooleanTryParse(" False \0\0\0 ", false, true);
-
- // Fail cases
- passed &= VerifyBooleanTryParse(null, false, false);
- passed &= VerifyBooleanTryParse("", false, false);
- passed &= VerifyBooleanTryParse(" ", false, false);
- passed &= VerifyBooleanTryParse("Garbage", false, false);
- passed &= VerifyBooleanTryParse("True\0Garbage", false, false);
- passed &= VerifyBooleanTryParse("True\0True", false, false);
- passed &= VerifyBooleanTryParse("True True", false, false);
- passed &= VerifyBooleanTryParse("True False", false, false);
- passed &= VerifyBooleanTryParse("False True", false, false);
- passed &= VerifyBooleanTryParse("Fa lse", false, false);
- passed &= VerifyBooleanTryParse("T", false, false);
- passed &= VerifyBooleanTryParse("0", false, false);
- passed &= VerifyBooleanTryParse("1", false, false);
-
- /// END TEST CASES
- }
- catch (Exception e)
- {
- TestLibrary.Logging.WriteLine("Unexpected exception!! " + e.ToString());
- passed = false;
- }
-
- if (passed)
- {
- TestLibrary.Logging.WriteLine ("paSs");
- return 100;
- }
- else
- {
- TestLibrary.Logging.WriteLine ("FAiL");
- return 1;
- }
- }
-
- public static bool VerifyBooleanTryParse(string value, bool expectedResult, bool expectedReturn) {
- bool result;
- if (verbose) {
- TestLibrary.Logging.WriteLine ("Test: Boolean.TryParse, Value = '{0}', Expected Result, {1}, Expected Return = {2}",
- value, expectedResult, expectedReturn);
- }
- try {
- bool returnValue = Boolean.TryParse(value, out result);
- if (returnValue != expectedReturn) {
- TestLibrary.Logging.WriteLine ("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedReturn, returnValue);
- return false;
- }
- if (result != expectedResult) {
- TestLibrary.Logging.WriteLine ("FAILURE: Value = '{0}', Expected Result: {1}, Actual Result: {2}", value, expectedResult, result);
- return false;
- }
-
- return true;
- }
- catch (Exception ex) {
- TestLibrary.Logging.WriteLine ("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-}
-
diff --git a/tests/src/CoreMangLib/cti/system/byte/ByteParse1.csproj b/tests/src/CoreMangLib/cti/system/byte/ByteParse1.csproj
deleted file mode 100644
index 5b236b9f8c..0000000000
--- a/tests/src/CoreMangLib/cti/system/byte/ByteParse1.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="byteparse1.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/byte/ByteParse3.csproj b/tests/src/CoreMangLib/cti/system/byte/ByteParse3.csproj
deleted file mode 100644
index 0c75c26d55..0000000000
--- a/tests/src/CoreMangLib/cti/system/byte/ByteParse3.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="byteparse3.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/byte/ByteTryParse.csproj b/tests/src/CoreMangLib/cti/system/byte/ByteTryParse.csproj
deleted file mode 100644
index 252c35cc73..0000000000
--- a/tests/src/CoreMangLib/cti/system/byte/ByteTryParse.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="bytetryparse.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/byte/byteparse1.cs b/tests/src/CoreMangLib/cti/system/byte/byteparse1.cs
deleted file mode 100644
index 081c36f622..0000000000
--- a/tests/src/CoreMangLib/cti/system/byte/byteparse1.cs
+++ /dev/null
@@ -1,329 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Collections;
-
-
-/// <summary>
-/// System.Byte.Parse(System.String)
-/// </summary>
-public class ByteParse1
-{
- public static int Main(string[] args)
- {
- ByteParse1 parse1 = new ByteParse1();
- TestLibrary.TestFramework.BeginTestCase("Testing System.Byte.Parse(System.String)...");
-
- if (parse1.RunTests())
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("PASS");
- return 100;
- }
- else
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("FAIL");
- return 0;
- }
- }
-
- public bool RunTests()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.LogInformation("[Positive]");
- retVal = PosTest1() && retVal;
- retVal = PosTest2() && retVal;
- retVal = PosTest3() && retVal;
- retVal = PosTest4() && retVal;
-
- TestLibrary.TestFramework.LogInformation("[Negtive]");
- retVal = NegTest1() && retVal;
- retVal = NegTest2() && retVal;
- retVal = NegTest3() && retVal;
- retVal = NegTest4() && retVal;
- retVal = NegTest5() && retVal;
- retVal = NegTest6() && retVal;
- retVal = NegTest7() && retVal;
-
- return retVal;
- }
-
- public bool PosTest1()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("Verify byteString is between Byte.MinValue and Byte.MaxValue...");
-
- try
- {
- string byteString = "99";
- Byte myByte = Byte.Parse(byteString);
-
- if (myByte != 99)
- {
- TestLibrary.TestFramework.LogError("001","The value should be equal to byteString.ToInt...");
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("002","Unexpected exception occurs: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest2()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("Verify byteString contains +...");
-
- try
- {
- string byteString = "+99";
- Byte myByte = Byte.Parse(byteString);
-
- if (myByte != 99)
- {
- TestLibrary.TestFramework.LogError("003","The value should be equal to byteString.ToInt...");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("004","Unexcepted exception occurs: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest3()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("Verify byteString is equal to Byte.MaxValue...");
-
- try
- {
- string byteString = "255";
- Byte myByte = Byte.Parse(byteString);
-
- if (myByte != 255)
- {
- TestLibrary.TestFramework.LogError("005", "byteString should be equal to Byte.MaxValue!");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("006", "Unexpected exception occurs: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest4()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("Verify byteString is equal to Byte.MinValue...");
-
- try
- {
- string byteString = "0";
- Byte myByte = Byte.Parse(byteString);
-
- if (myByte != 0)
- {
- TestLibrary.TestFramework.LogError("007", "byteString should be equal to Byte.MinValue!");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("008", "Unexpected exception occurs: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest1()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("Verify OverFlowException is thrown when byteString is greater than Byte.MaxValue...");
-
- try
- {
- string byteString = "256";
- Byte myByte = Byte.Parse(byteString);
-
- TestLibrary.TestFramework.LogError("009","No exception occurs!");
- retVal = false;
- }
- catch (OverflowException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("010", "Unexpected exception occurs: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest2()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("Verify OverFlowException is thrown when byteString is less than Byte.MinValue...");
-
- try
- {
- string byteString = "-1";
- Byte myByte = Byte.Parse(byteString);
-
- TestLibrary.TestFramework.LogError("011","No exception occurs!");
- retVal = false;
- }
- catch (OverflowException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("012","Unexpected exception occurs: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest3()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("Verify ArgumentNullException occurs when byteString is null...");
-
- try
- {
- string byteString = null;
- Byte myByte = Byte.Parse(byteString);
-
- TestLibrary.TestFramework.LogError("013", "No exception occurs!");
- retVal = false;
- }
- catch (ArgumentNullException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("014","Unexpected exception occurs: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest4()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("Verify byteString is between Byte.MaxValue and Byte.MinValue and contains plus...");
-
- try
- {
- string byteString = "plus222";
- Byte myByte = Byte.Parse(byteString);
-
- TestLibrary.TestFramework.LogError("015", "No exception occurs!");
- retVal = false;
- }
- catch (FormatException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("016", "Unexpected exception occurs: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest5()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("Verify byteString contains underline...");
-
- try
- {
- string byteString = "1_2_3";
- Byte myByte = Byte.Parse(byteString);
-
- TestLibrary.TestFramework.LogError("017", "No exception occurs!");
- retVal = false;
- }
- catch (FormatException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("018", "Unexpected exception occurs: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest6()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("Verify byteString contains only characters...");
-
- try
- {
- string byteString = "hello";
- Byte myByte = Byte.Parse(byteString);
-
- TestLibrary.TestFramework.LogError("017", "No exception occurs!");
- retVal = false;
- }
- catch (FormatException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("018", "Unexpected exception occurs: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest7()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("Verify byteString is an empty string...");
-
- try
- {
- string byteString = "";
- Byte myByte = Byte.Parse(byteString);
-
- TestLibrary.TestFramework.LogError("017", "No exception occurs!");
- retVal = false;
- }
- catch (FormatException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("018", "Unexpected exception occurs: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
-
-}
diff --git a/tests/src/CoreMangLib/cti/system/byte/byteparse3.cs b/tests/src/CoreMangLib/cti/system/byte/byteparse3.cs
deleted file mode 100644
index ef5afbd979..0000000000
--- a/tests/src/CoreMangLib/cti/system/byte/byteparse3.cs
+++ /dev/null
@@ -1,344 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Collections;
-using System.Globalization;
-
-/// <summary>
-/// System.Byte.Parse(System.String,System.Globalization.NumberStyles,System.IFormatProvider)
-/// </summary>
-public class ByteParse3
-{
- public static int Main(string[] args)
- {
- ByteParse3 parse3 = new ByteParse3();
- TestLibrary.TestFramework.BeginTestCase("Testing System.Byte.Parse(System.String,System.Globalization.NumberStyles,System.IFormatProvider)...");
-
- if (parse3.RunTests())
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("PASS");
- return 100;
- }
- else
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("FAIL");
- return 0;
- }
- }
-
- public bool RunTests()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.LogInformation("[Positive]");
- retVal = PosTest1() && retVal;
- retVal = PosTest2() && retVal;
- retVal = PosTest3() && retVal;
- retVal = PosTest4() && retVal;
- retVal = PosTest5() && retVal;
-
- TestLibrary.TestFramework.LogInformation("[Negtive]");
- retVal = NegTest1() && retVal;
- retVal = NegTest2() && retVal;
- retVal = NegTest3() && retVal;
- retVal = NegTest4() && retVal;
- retVal = NegTest5() && retVal;
-
- return retVal;
- }
-
- public bool PosTest1()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest1: Verify PositiveSign of format provider takes effect...");
-
- try
- {
- string byteString = "plus128";
- CultureInfo culture = new CultureInfo("");
- NumberFormatInfo numberFormat = culture.NumberFormat;
- numberFormat.PositiveSign = "plus";
-
- Byte myByte = Byte.Parse(byteString, NumberStyles.Number, numberFormat);
-
- if (myByte != 128)
- {
- TestLibrary.TestFramework.LogError("001", "The format provider does not takes effect!");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("002", "Unexpected exception occurs: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest2()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest2: Verify NumberGroupSeperator of format provider takes effect...");
-
- try
- {
- string byteString = "1_2_3";
- CultureInfo culture = new CultureInfo("");
- NumberFormatInfo numberFormat = culture.NumberFormat;
- numberFormat.NumberGroupSeparator = "_";
-
- Byte myByte = Byte.Parse(byteString, NumberStyles.Number, numberFormat);
-
- if (myByte != 123)
- {
- TestLibrary.TestFramework.LogError("003", "The NumberGroupSeparator of format provider does not takes effect!");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("004", "Unexpected exception occurs: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest3()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest3: Verify currency symbol of format provider should take effect...");
-
- try
- {
- string byteString = "@123";
- CultureInfo culture = new CultureInfo("");
- NumberFormatInfo numberFormat = culture.NumberFormat;
- numberFormat.CurrencySymbol = "@";
-
- Byte myByte = Byte.Parse(byteString, NumberStyles.Currency, numberFormat);
-
- if (myByte != 123)
- {
- TestLibrary.TestFramework.LogError("005", "The currency symbol of format provider does not take effect!");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("006", "Unexpected exception occurs: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest4()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest4: Verify byteString is maxValue...");
-
- try
- {
- string byteString = "@255";
- CultureInfo culture = new CultureInfo("");
- NumberFormatInfo numberFormat = culture.NumberFormat;
- numberFormat.CurrencySymbol = "@";
-
- Byte myByte = Byte.Parse(byteString, NumberStyles.Currency | NumberStyles.Number, numberFormat);
-
- if (myByte != 255)
- {
- TestLibrary.TestFramework.LogError("007", "The format provider should takes effect!");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("008", "Unexpected exception occurs: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest5()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest5: Verify byteString is minValue...");
-
- try
- {
- string byteString = "@0";
- CultureInfo culture = new CultureInfo("");
- NumberFormatInfo numberFormat = culture.NumberFormat;
- numberFormat.CurrencySymbol = "@";
-
- Byte myByte = Byte.Parse(byteString, NumberStyles.Currency | NumberStyles.Number, numberFormat);
-
- if (myByte != 0)
- {
- TestLibrary.TestFramework.LogError("009", "The format provider should takes effect!");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("010", "Unexpected exception occurs: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest1()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("NegTest1: Verify byteString is more than maxValue...");
-
- try
- {
- string byteString = "@256";
- CultureInfo culture = new CultureInfo("");
- NumberFormatInfo numberFormat = culture.NumberFormat;
- numberFormat.CurrencySymbol = "@";
-
- Byte myByte = Byte.Parse(byteString, NumberStyles.Currency | NumberStyles.Number, numberFormat);
-
- TestLibrary.TestFramework.LogError("101", "The format provider should takes effect!");
- retVal = false;
-
- }
- catch (OverflowException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("102", "Unexpected exception occurs: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest2()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("NegTest2: Verify byteString is less than minValue...");
-
- try
- {
- string byteString = "@-1";
- CultureInfo culture = new CultureInfo("");
- NumberFormatInfo numberFormat = culture.NumberFormat;
- numberFormat.CurrencySymbol = "@";
-
- Byte myByte = Byte.Parse(byteString, NumberStyles.Currency | NumberStyles.Number, numberFormat);
-
- TestLibrary.TestFramework.LogError("103", "The format provider should takes effect!");
- retVal = false;
-
- }
- catch (OverflowException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("104", "Unexpected exception occurs: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest3()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("NegTest3: Verify byteString is null referrence...");
-
- try
- {
- string byteString = null;
- CultureInfo culture = new CultureInfo("");
- NumberFormatInfo numberFormat = culture.NumberFormat;
- numberFormat.PositiveSign = "plus";
-
- Byte myByte = Byte.Parse(byteString, NumberStyles.Number, numberFormat);
-
- TestLibrary.TestFramework.LogError("105", "No exception occurs!");
- retVal = false;
- }
- catch (ArgumentNullException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("106", "Unexpected exception occurs: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest4()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("NegTest4: Verify byteString is not of the correct format...");
-
- try
- {
- string byteString = "plusHelloWorld!";
- CultureInfo culture = new CultureInfo("");
- NumberFormatInfo numberFormat = culture.NumberFormat;
- numberFormat.PositiveSign = "plus";
-
- Byte myByte = Byte.Parse(byteString, NumberStyles.Number, numberFormat);
-
- TestLibrary.TestFramework.LogError("107", "No exception occurs!");
- retVal = false;
- }
- catch (FormatException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("108", "Unexpected exception occurs: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest5()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("NegTest5: Verify style is not a combination of AllowHexSpecifier and HexNumber values...");
-
- try
- {
- string byteString = "#2fD";
- CultureInfo culture = new CultureInfo("");
- NumberFormatInfo numberFormat = culture.NumberFormat;
- numberFormat.CurrencySymbol = "#";
-
- Byte myByte = Byte.Parse(byteString, NumberStyles.Number | NumberStyles.Currency | NumberStyles.AllowHexSpecifier, numberFormat);
-
- TestLibrary.TestFramework.LogError("109", "No exception occurs!");
- retVal = false;
- }
- catch (ArgumentException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("110", "Unexpected exception occurs: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-}
diff --git a/tests/src/CoreMangLib/cti/system/byte/bytetryparse.cs b/tests/src/CoreMangLib/cti/system/byte/bytetryparse.cs
deleted file mode 100644
index f0b08d98a0..0000000000
--- a/tests/src/CoreMangLib/cti/system/byte/bytetryparse.cs
+++ /dev/null
@@ -1,494 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Globalization;
-using System.Security;
-
-// This test was ported over to CoreCLR from Co7523TryParse_all.cs
-// Tests Byte.TryParse(String), Byte.TryParse(String, NumberStyles, IFormatProvider, ref Byte)
-// 2003/02/25 KatyK
-// 2007/06/28 adapted by MarielY
-
-public class ByteTryParse
-{
- static bool verbose = false;
-
- public static int Main()
- {
- bool passed = true;
-
- try
- {
- // Make the test culture independent
- TestLibrary.Utilities.CurrentCulture = CultureInfo.InvariantCulture;
-
- // Set up NFIs to use
- NumberFormatInfo goodNFI = new NumberFormatInfo();
-
- NumberFormatInfo corruptNFI = new NumberFormatInfo(); // DecimalSeparator == GroupSeparator
- corruptNFI.NumberDecimalSeparator = ".";
- corruptNFI.NumberGroupSeparator = ".";
- corruptNFI.CurrencyDecimalSeparator = ".";
- corruptNFI.CurrencyGroupSeparator = ".";
- corruptNFI.CurrencySymbol = "$";
-
- NumberFormatInfo swappedNFI = new NumberFormatInfo(); // DecimalSeparator & GroupSeparator swapped
- swappedNFI.NumberDecimalSeparator = ".";
- swappedNFI.NumberGroupSeparator = ",";
- swappedNFI.CurrencyDecimalSeparator = ",";
- swappedNFI.CurrencyGroupSeparator = ".";
- swappedNFI.CurrencySymbol = "$";
-
- NumberFormatInfo distinctNFI = new NumberFormatInfo(); // DecimalSeparator & GroupSeparator distinct
- distinctNFI.NumberDecimalSeparator = ".";
- distinctNFI.NumberGroupSeparator = ",";
- distinctNFI.CurrencyDecimalSeparator = ":";
- distinctNFI.CurrencyGroupSeparator = ";";
- distinctNFI.CurrencySymbol = "$";
-
- NumberFormatInfo customNFI = new NumberFormatInfo();
- customNFI.NegativeSign = "^";
-
- NumberFormatInfo ambigNFI = new NumberFormatInfo();
- ambigNFI.NegativeSign = "^";
- ambigNFI.CurrencySymbol = "^";
-
- CultureInfo germanCulture = new CultureInfo("de-DE");
- CultureInfo japaneseCulture;
-
- try
- {
- japaneseCulture = new CultureInfo("ja-JP");
- }
- catch (Exception)
- {
- TestLibrary.Logging.WriteLine("East Asian Languages are not installed. Skiping Japanese culture tests.");
- japaneseCulture = null;
- }
-
- // Parse tests included for comparison/regression
- passed &= VerifyByteParse("5", 5);
- passed &= VerifyByteParse("5 ", 5);
- passed &= VerifyByteParse("5 \0", 5);
- passed &= VerifyByteParse("5\0\0\0", 5);
- passed &= VerifyByteParse("5", NumberStyles.Integer, CultureInfo.InvariantCulture, 5);
- passed &= VerifyByteParse("12", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0x12);
- passed &= VerifyByteParse("fF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0xFF);
- passed &= VerifyByteParse("5", NumberStyles.Integer, goodNFI, 5);
- passed &= VerifyByteParse("5\0", NumberStyles.Integer, CultureInfo.InvariantCulture, 5);
- passed &= VerifyByteParse("123", NumberStyles.Integer, germanCulture, 123);
- passed &= VerifyByteParse("123", NumberStyles.Integer, japaneseCulture, 123);
- passed &= VerifyByteParse("123,000", NumberStyles.AllowDecimalPoint, germanCulture, 123);
- passed &= VerifyByteParse("123.000", NumberStyles.AllowDecimalPoint, japaneseCulture, 123);
- passed &= VerifyByteParse("5,00 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Any, germanCulture, 5); // currency
- //
- passed &= VerifyByteParse("5", NumberStyles.Integer, corruptNFI, 5);
- passed &= VerifyByteParse("5", NumberStyles.Number, corruptNFI, 5);
- passed &= VerifyByteParse("5.0", NumberStyles.Number, corruptNFI, 5);
- passed &= VerifyByteParseException("5,0", NumberStyles.Number, corruptNFI, typeof(FormatException));
- passed &= VerifyByteParseException("5.0.0", NumberStyles.Number, corruptNFI, typeof(FormatException));
- passed &= VerifyByteParse("$5.0", NumberStyles.Currency, corruptNFI, 5);
- passed &= VerifyByteParseException("$5,0", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyByteParseException("$5.0.0", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyByteParse("5.0", NumberStyles.Currency, corruptNFI, 5);
- passed &= VerifyByteParseException("5,0", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyByteParseException("5.0.0", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyByteParse("5.0", NumberStyles.Any, corruptNFI, 5);
- passed &= VerifyByteParseException("5,0", NumberStyles.Any, corruptNFI, typeof(FormatException));
- passed &= VerifyByteParseException("5.0.0", NumberStyles.Any, corruptNFI, typeof(FormatException));
- //
- passed &= VerifyByteParse("5", NumberStyles.Integer, swappedNFI, 5);
- passed &= VerifyByteParse("5", NumberStyles.Number, swappedNFI, 5);
- passed &= VerifyByteParse("5.0", NumberStyles.Number, swappedNFI, 5);
- passed &= VerifyByteParseException("5.000.000", NumberStyles.Number, swappedNFI, typeof(FormatException));
- passed &= VerifyByteParse("5.0", NumberStyles.Currency, swappedNFI, 5); //???
- passed &= VerifyByteParse("$5.0", NumberStyles.Currency, swappedNFI, 50);
- passed &= VerifyByteParse("5.0", NumberStyles.Any, swappedNFI, 5); //?
- passed &= VerifyByteParse("$5.0", NumberStyles.Any, swappedNFI, 50);
- passed &= VerifyByteParse("5,0", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyByteParse("$5,0", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyByteParse("5,000", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyByteParse("$5,000", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyByteParse("5,000", NumberStyles.Any, swappedNFI, 5);
- passed &= VerifyByteParse("$5,000", NumberStyles.Any, swappedNFI, 5);
- //
- passed &= VerifyByteParse("5.0", NumberStyles.Number, distinctNFI, 5);
- passed &= VerifyByteParse("5.0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyByteParse("5.0", NumberStyles.Any, distinctNFI, 5);
- passed &= VerifyByteParseException("$5.0", NumberStyles.Currency, distinctNFI, typeof(FormatException));
- passed &= VerifyByteParseException("$5.0", NumberStyles.Any, distinctNFI, typeof(FormatException));
- passed &= VerifyByteParseException("5:0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyByteParseException("$5:0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyByteParse("5:0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyByteParse("$5:0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyByteParse("5:0", NumberStyles.Any, distinctNFI, 5);
- passed &= VerifyByteParse("$5:0", NumberStyles.Any, distinctNFI, 5);
-
- passed &= VerifyByteParseException("300", typeof(OverflowException));
- passed &= VerifyByteParseException("-5", typeof(OverflowException));
- passed &= VerifyByteParseException("Garbage", typeof(FormatException));
- passed &= VerifyByteParseException("5\0Garbage", typeof(FormatException));
- passed &= VerifyByteParseException(null, typeof(ArgumentNullException));
- passed &= VerifyByteParseException("1FF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, typeof(OverflowException));
- passed &= VerifyByteParseException("FFFFFFFF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, typeof(OverflowException));
- passed &= VerifyByteParseException("5", NumberStyles.AllowHexSpecifier | NumberStyles.AllowParentheses, null, typeof(ArgumentException));
- passed &= VerifyByteParseException("4", (NumberStyles)(-1), typeof(ArgumentException));
- passed &= VerifyByteParseException("4", (NumberStyles)0x10000, typeof(ArgumentException));
- passed &= VerifyByteParseException("4", (NumberStyles)(-1), CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifyByteParseException("4", (NumberStyles)0x10000, CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifyByteParseException("123.000", NumberStyles.Any, germanCulture, typeof(OverflowException));
- passed &= VerifyByteParseException("123,000", NumberStyles.Any, japaneseCulture, typeof(OverflowException));
- passed &= VerifyByteParseException("123,000", NumberStyles.Integer, germanCulture, typeof(FormatException));
- passed &= VerifyByteParseException("123.000", NumberStyles.Integer, japaneseCulture, typeof(FormatException));
- passed &= VerifyByteParseException("5,00 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Integer, germanCulture, typeof(FormatException)); // currency
-
- /////////// TryParse(String)
- //// Pass cases
- passed &= VerifyByteTryParse("5", 5, true);
- passed &= VerifyByteTryParse(" 5 ", 5, true);
- passed &= VerifyByteTryParse("5\0", 5, true);
- passed &= VerifyByteTryParse("5 \0", 5, true);
- passed &= VerifyByteTryParse("5\0\0\0", 5, true);
- passed &= VerifyByteTryParse(Byte.MaxValue.ToString(), Byte.MaxValue, true);
- passed &= VerifyByteTryParse(Byte.MinValue.ToString(), Byte.MinValue, true);
-
- //// Fail cases
- passed &= VerifyByteTryParse(null, 0, false);
- passed &= VerifyByteTryParse("", 0, false);
- passed &= VerifyByteTryParse("Garbage", 0, false);
- passed &= VerifyByteTryParse("5\0Garbage", 0, false);
- passed &= VerifyByteTryParse("300", 0, false);
- passed &= VerifyByteTryParse("-5", 0, false);
- passed &= VerifyByteTryParse("FF", 0, false);
- passed &= VerifyByteTryParse("27.3", 0, false);
- passed &= VerifyByteTryParse("23 5", 0, false);
-
-
- /////////// TryParse(TryParse(String, NumberStyles, IFormatProvider, ref Byte)
- //// Pass cases
- passed &= VerifyByteTryParse("5", NumberStyles.Integer, CultureInfo.InvariantCulture, 5, true);
- // Variations on NumberStyles
- passed &= VerifyByteTryParse("12", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0x12, true);
- passed &= VerifyByteTryParse("FF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0xFF, true);
- passed &= VerifyByteTryParse("fF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0xFF, true);
- passed &= VerifyByteTryParse(" 5", NumberStyles.AllowLeadingWhite, goodNFI, 5, true);
- passed &= VerifyByteTryParse("5", NumberStyles.Number, goodNFI, 5, true);
- // Variations on IFP
- passed &= VerifyByteTryParse("5", NumberStyles.Integer, goodNFI, 5, true);
- passed &= VerifyByteTryParse("5", NumberStyles.Integer, null, 5, true);
- passed &= VerifyByteTryParse("5", NumberStyles.Integer, new DateTimeFormatInfo(), 5, true);
- passed &= VerifyByteTryParse("123", NumberStyles.Integer, germanCulture, 123, true);
- passed &= VerifyByteTryParse("123", NumberStyles.Integer, japaneseCulture, 123, true);
- passed &= VerifyByteTryParse("123,000", NumberStyles.AllowDecimalPoint, germanCulture, 123, true);
- passed &= VerifyByteTryParse("123.000", NumberStyles.AllowDecimalPoint, japaneseCulture, 123, true);
- passed &= VerifyByteTryParse("5,00 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Any, germanCulture, 5, true); // currency
-
- //// Fail cases
- passed &= VerifyByteTryParse("FF", NumberStyles.Integer, CultureInfo.InvariantCulture, 0, false);
- passed &= VerifyByteTryParse("1FF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0, false);
- passed &= VerifyByteTryParse("FFFFFFFF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0, false);
- passed &= VerifyByteTryParse("^42", NumberStyles.Any, customNFI, 0, false);
- passed &= VerifyByteTryParse("-42", NumberStyles.Any, customNFI, 0, false);
- passed &= VerifyByteTryParse("5.3", NumberStyles.AllowDecimalPoint, goodNFI, 0, false);
- passed &= VerifyByteTryParse("5 ", NumberStyles.AllowLeadingWhite, goodNFI, 0, false);
- passed &= VerifyByteTryParse("123.000", NumberStyles.Any, germanCulture, 0, false);
- passed &= VerifyByteTryParse("123,000", NumberStyles.Any, japaneseCulture, 0, false);
- passed &= VerifyByteTryParse("123,000", NumberStyles.Integer, germanCulture, 0, false);
- passed &= VerifyByteTryParse("123.000", NumberStyles.Integer, japaneseCulture, 0, false);
- passed &= VerifyByteTryParse("5,00 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Integer, germanCulture, 0, false); // currency
-
- //// Exception cases
- passed &= VerifyByteTryParseException("5", NumberStyles.AllowHexSpecifier | NumberStyles.AllowParentheses, null, typeof(ArgumentException));
- passed &= VerifyByteTryParseException("4", (NumberStyles)(-1), CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifyByteTryParseException("4", (NumberStyles)0x10000, CultureInfo.InvariantCulture, typeof(ArgumentException));
-
- // NumberStyles/NFI variations
- //
- passed &= VerifyByteTryParse("5", NumberStyles.Integer, corruptNFI, 5, true);
- passed &= VerifyByteTryParse("5", NumberStyles.Number, corruptNFI, 5, true);
- passed &= VerifyByteTryParse("5.0", NumberStyles.Number, corruptNFI, 5, true);
- passed &= VerifyByteTryParse("5,0", NumberStyles.Number, corruptNFI, 0, false);
- passed &= VerifyByteTryParse("5.0.0", NumberStyles.Number, corruptNFI, 0, false);
- passed &= VerifyByteTryParse("$5.0", NumberStyles.Currency, corruptNFI, 5, true);
- passed &= VerifyByteTryParse("$5,0", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyByteTryParse("$5.0.0", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyByteTryParse("5.0", NumberStyles.Currency, corruptNFI, 5, true);
- passed &= VerifyByteTryParse("5,0", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyByteTryParse("5.0.0", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyByteTryParse("5.0", NumberStyles.Any, corruptNFI, 5, true);
- passed &= VerifyByteTryParse("5,0", NumberStyles.Any, corruptNFI, 0, false);
- passed &= VerifyByteTryParse("5.0.0", NumberStyles.Any, corruptNFI, 0, false);
- //
- passed &= VerifyByteTryParse("5", NumberStyles.Integer, swappedNFI, 5, true);
- passed &= VerifyByteTryParse("5", NumberStyles.Number, swappedNFI, 5, true);
- passed &= VerifyByteTryParse("5.0", NumberStyles.Number, swappedNFI, 5, true);
- passed &= VerifyByteTryParse("5.000.000", NumberStyles.Number, swappedNFI, 0, false);
- passed &= VerifyByteTryParse("5.0", NumberStyles.Currency, swappedNFI, 5, true); //???
- passed &= VerifyByteTryParse("$5.0", NumberStyles.Currency, swappedNFI, 50, true);
- passed &= VerifyByteTryParse("5.0", NumberStyles.Any, swappedNFI, 5, true); //?
- passed &= VerifyByteTryParse("$5.0", NumberStyles.Any, swappedNFI, 50, true);
- passed &= VerifyByteTryParse("5,0", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyByteTryParse("$5,0", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyByteTryParse("5,000", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyByteTryParse("$5,000", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyByteTryParse("5,000", NumberStyles.Any, swappedNFI, 5, true);
- passed &= VerifyByteTryParse("$5,000", NumberStyles.Any, swappedNFI, 5, true);
- //
- passed &= VerifyByteTryParse("5.0", NumberStyles.Number, distinctNFI, 5, true);
- passed &= VerifyByteTryParse("5.0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyByteTryParse("5.0", NumberStyles.Any, distinctNFI, 5, true);
- passed &= VerifyByteTryParse("$5.0", NumberStyles.Currency, distinctNFI, 0, false);
- passed &= VerifyByteTryParse("$5.0", NumberStyles.Any, distinctNFI, 0, false);
- passed &= VerifyByteTryParse("5:0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyByteTryParse("$5:0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyByteTryParse("5:0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyByteTryParse("$5:0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyByteTryParse("5:0", NumberStyles.Any, distinctNFI, 5, true);
- passed &= VerifyByteTryParse("$5:0", NumberStyles.Any, distinctNFI, 5, true);
-
-
- // Should these pass or fail? Current parse behavior is to pass, so they might be
- // parse bugs, but they're not tryparse bugs.
- passed &= VerifyByteParse("5", NumberStyles.Float, goodNFI, 5);
- passed &= VerifyByteTryParse("5", NumberStyles.Float, goodNFI, 5, true);
- passed &= VerifyByteParse("5", NumberStyles.AllowDecimalPoint, goodNFI, 5);
- passed &= VerifyByteTryParse("5", NumberStyles.AllowDecimalPoint, goodNFI, 5, true);
- // I expect ArgumentException with an ambiguous NFI
- passed &= VerifyByteParseException("^42", NumberStyles.Any, ambigNFI, typeof(OverflowException));
- passed &= VerifyByteTryParse("^42", NumberStyles.Any, ambigNFI, 0, false);
-
- /// END TEST CASES
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("001", "Unexpected exception: " + e);
- passed = false;
- }
-
- if (passed)
- {
- TestLibrary.TestFramework.LogInformation("PASS");
- return 100;
- }
- else
- {
- TestLibrary.TestFramework.LogInformation("FAIL");
- return 1;
- }
- }
-
- public static bool VerifyByteTryParse(string value, Byte expectedResult, bool expectedReturn)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Byte.TryParse, Value = '{0}', Expected Result = {1}, Expected Return = {2}",
- value, expectedResult, expectedReturn);
- }
- Byte result = 0;
- try
- {
- bool returnValue = Byte.TryParse(value, out result);
- if (returnValue != expectedReturn)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedReturn, returnValue);
- return false;
- }
- if (result != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, result);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyByteTryParse(string value, NumberStyles style, IFormatProvider provider, Byte expectedResult, bool expectedReturn)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Byte.TryParse, Value = '{0}', Style = {1}, Provider = {2}, Expected Result = {3}, Expected Return = {4}",
- value, style, provider, expectedResult, expectedReturn);
- }
- Byte result = 0;
- try
- {
- bool returnValue = Byte.TryParse(value, style, provider, out result);
- if (returnValue != expectedReturn)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Style = {1}, Provider = {2}, Expected Return = {3}, Actual Return = {4}",
- value, style, provider, expectedReturn, returnValue);
- return false;
- }
- if (result != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, result);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyByteTryParseException(string value, NumberStyles style, IFormatProvider provider, Type exceptionType)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Byte.TryParse, Value = '{0}', Style = {1}, Provider = {2}, Expected Exception = {3}",
- value, style, provider, exceptionType);
- }
- try
- {
- Byte result = 0;
- Boolean returnValue = Byte.TryParse(value, style, provider, out result);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifyByteParse(string value, Byte expectedResult)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Byte.Parse, Value = '{0}', Expected Result, {1}",
- value, expectedResult);
- }
- try
- {
- Byte returnValue = Byte.Parse(value);
- if (returnValue != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, returnValue);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyByteParse(string value, NumberStyles style, IFormatProvider provider, Byte expectedResult)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Byte.Parse, Value = '{0}', Style = {1}, provider = {2}, Expected Result = {3}",
- value, style, provider, expectedResult);
- }
- try
- {
- Byte returnValue = Byte.Parse(value, style, provider);
- if (returnValue != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, returnValue);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyByteParseException(string value, Type exceptionType)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Byte.Parse, Value = '{0}', Expected Exception, {1}",
- value, exceptionType);
- }
- try
- {
- Byte returnValue = Byte.Parse(value);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifyByteParseException(string value, NumberStyles style, Type exceptionType)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Byte.Parse, Value = '{0}', Style = {1}, Expected Exception = {3}",
- value, style, exceptionType);
- }
- try
- {
- Byte returnValue = Byte.Parse(value, style);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifyByteParseException(string value, NumberStyles style, IFormatProvider provider, Type exceptionType)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Byte.Parse, Value = '{0}', Style = {1}, Provider = {2}, Expected Exception = {3}",
- value, style, provider, exceptionType);
- }
- try
- {
- Byte returnValue = Byte.Parse(value, style, provider);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-}
diff --git a/tests/src/CoreMangLib/cti/system/char/CharTryParse.csproj b/tests/src/CoreMangLib/cti/system/char/CharTryParse.csproj
deleted file mode 100644
index 8a37783127..0000000000
--- a/tests/src/CoreMangLib/cti/system/char/CharTryParse.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="chartryparse.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/char/chartryparse.cs b/tests/src/CoreMangLib/cti/system/char/chartryparse.cs
deleted file mode 100644
index e93d361f5f..0000000000
--- a/tests/src/CoreMangLib/cti/system/char/chartryparse.cs
+++ /dev/null
@@ -1,92 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-
-// Ported to CoreCLR from Desktop test Co7522TryParse.cs
-// Tests Char.TryParse(str)
-// 2003/02/25 KatyK
-// 2007/06/28 adapted by MarielY
-public class CharTryParse
-{
- static bool verbose = false;
-
- public static int Main()
- {
- bool passed = true;
-
- try
- {
- // Success cases
- passed &= VerifyCharTryParse("a", 'a', true);
- passed &= VerifyCharTryParse("4", '4', true);
- passed &= VerifyCharTryParse(" ", ' ', true);
- passed &= VerifyCharTryParse("\n", '\n', true);
- passed &= VerifyCharTryParse("\0", '\0', true);
- passed &= VerifyCharTryParse("\u0135", '\u0135', true);
- passed &= VerifyCharTryParse("\u05d9", '\u05d9', true);
- passed &= VerifyCharTryParse("\ud801", '\ud801', true); // high surrogate
- passed &= VerifyCharTryParse("\udc01", '\udc01', true); // low surrogate
- passed &= VerifyCharTryParse("\ue001", '\ue001', true); // private use codepoint
-
- // Fail cases
- passed &= VerifyCharTryParse(null, '\0', false);
- passed &= VerifyCharTryParse("", '\0', false);
- passed &= VerifyCharTryParse("\n\r", '\0', false);
- passed &= VerifyCharTryParse("kj", '\0', false);
- passed &= VerifyCharTryParse(" a", '\0', false);
- passed &= VerifyCharTryParse("a ", '\0', false);
- passed &= VerifyCharTryParse("\\u0135", '\0', false);
- passed &= VerifyCharTryParse("\u01356", '\0', false);
- passed &= VerifyCharTryParse("\ud801\udc01", '\0', false); // surrogate pair
-
- /// END TEST CASES
- }
- catch (Exception e)
- {
- TestLibrary.Logging.WriteLine("Unexpected exception!! " + e.ToString());
- passed = false;
- }
-
- if (passed)
- {
- TestLibrary.Logging.WriteLine("paSs");
- return 100;
- }
- else
- {
- TestLibrary.Logging.WriteLine("FAiL");
- return 1;
- }
- }
-
- public static bool VerifyCharTryParse(string value, Char expectedResult, bool expectedReturn)
- {
- Char result;
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Char.TryParse, Value = '{0}', Expected Result, {1}, Expected Return = {2}",
- value, expectedResult, expectedReturn);
- }
- try
- {
- bool returnValue = Char.TryParse(value, out result);
- if (returnValue != expectedReturn)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedReturn, returnValue);
- return false;
- }
- if (result != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Result: {1}, Actual Result: {2}", value, expectedResult, result);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-}
diff --git a/tests/src/CoreMangLib/cti/system/decimal/DecimalParse.csproj b/tests/src/CoreMangLib/cti/system/decimal/DecimalParse.csproj
deleted file mode 100644
index 5d5cca7524..0000000000
--- a/tests/src/CoreMangLib/cti/system/decimal/DecimalParse.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="decimalparse.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/decimal/DecimalParse2.csproj b/tests/src/CoreMangLib/cti/system/decimal/DecimalParse2.csproj
deleted file mode 100644
index 8ec0c9c1b9..0000000000
--- a/tests/src/CoreMangLib/cti/system/decimal/DecimalParse2.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="decimalparse2.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/decimal/DecimalParse3.csproj b/tests/src/CoreMangLib/cti/system/decimal/DecimalParse3.csproj
deleted file mode 100644
index 6f862eda81..0000000000
--- a/tests/src/CoreMangLib/cti/system/decimal/DecimalParse3.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="decimalparse3.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/decimal/DecimalParse4.csproj b/tests/src/CoreMangLib/cti/system/decimal/DecimalParse4.csproj
deleted file mode 100644
index 7a037c4b4a..0000000000
--- a/tests/src/CoreMangLib/cti/system/decimal/DecimalParse4.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="decimalparse4.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/decimal/DecimalTryParse.csproj b/tests/src/CoreMangLib/cti/system/decimal/DecimalTryParse.csproj
deleted file mode 100644
index 60356796b3..0000000000
--- a/tests/src/CoreMangLib/cti/system/decimal/DecimalTryParse.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="decimaltryparse.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/decimal/decimalparse.cs b/tests/src/CoreMangLib/cti/system/decimal/decimalparse.cs
deleted file mode 100644
index b7acebdb88..0000000000
--- a/tests/src/CoreMangLib/cti/system/decimal/decimalparse.cs
+++ /dev/null
@@ -1,171 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Globalization;
-/// <summary>
-/// Parse(System.String)
-/// </summary>
-public class DecimalParse
-{
- #region Public Methods
- public bool RunTests()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.LogInformation("[Positive]");
- retVal = PosTest1() && retVal;
- retVal = PosTest2() && retVal;
- retVal = PosTest3() && retVal;
- return retVal;
- }
-
- #region Positive Test Cases
- public bool PosTest1()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest1: Calling Parse method.");
-
- try
- {
- Decimal m1 = new decimal(TestLibrary.Generator.GetDouble(-55));
- CultureInfo myCulture = CultureInfo.CurrentCulture;
- string m1ToString = m1.ToString(myCulture);
- Decimal expectValue = m1;
- Decimal actualValue = Decimal.Parse(m1ToString);
- if (actualValue != expectValue)
- {
- TestLibrary.TestFramework.LogError("001.1", "Parse method should return " + expectValue);
- retVal = false;
- }
-
-
- m1 = new decimal(TestLibrary.Generator.GetInt32(-55));
- m1ToString = m1.ToString(myCulture);
- expectValue = m1;
- actualValue = Decimal.Parse(m1ToString);
- if (actualValue != expectValue)
- {
- TestLibrary.TestFramework.LogError("001.2", "Parse method should return " + expectValue);
- retVal = false;
- }
-
- m1 = new decimal(TestLibrary.Generator.GetSingle(-55));
- m1ToString = m1.ToString(myCulture);
- expectValue = m1;
- actualValue = Decimal.Parse(m1ToString);
- if (actualValue != expectValue)
- {
- TestLibrary.TestFramework.LogError("001.3", "Parse method should return " + expectValue);
- retVal = false;
- }
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
- public bool PosTest2()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest2: Calling Parse method and the decimal is MaxValue and MinValue.");
-
- try
- {
- Decimal m1 = Decimal.MaxValue;
- CultureInfo myCulture = CultureInfo.CurrentCulture;
- string m1ToString = m1.ToString(myCulture);
- Decimal expectValue = m1;
- Decimal actualValue = Decimal.Parse(m1ToString);
- if (actualValue != expectValue)
- {
- TestLibrary.TestFramework.LogError("002.1", "Parse method should return " + expectValue);
- retVal = false;
- }
-
- m1 = Decimal.MinValue;
- m1ToString = m1.ToString(myCulture);
- expectValue = m1;
- actualValue = Decimal.Parse(m1ToString);
- if (actualValue != expectValue)
- {
- TestLibrary.TestFramework.LogError("002.2", "Parse method should return " + expectValue);
- retVal = false;
- }
-
-
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest3()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest3: Calling Parse method and the decimal is Especial value.");
-
- try
- {
- Decimal m1 = -9876543210.9876543210m;
- CultureInfo myCulture = CultureInfo.CurrentCulture;
- string m1ToString = m1.ToString(myCulture);
- Decimal expectValue = m1;
- Decimal actualValue = Decimal.Parse(m1ToString);
- if (actualValue != expectValue)
- {
- TestLibrary.TestFramework.LogError("003.1", "Parse method should return " + expectValue);
- retVal = false;
- }
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
- #endregion
-
- #endregion
-
- public static int Main()
- {
- DecimalParse test = new DecimalParse();
-
- TestLibrary.TestFramework.BeginTestCase("DecimalParse");
-
- if (test.RunTests())
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("PASS");
- return 100;
- }
- else
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("FAIL");
- return 0;
- }
- }
- #region private method
- public TypeCode GetExpectValue(Decimal myValue)
- {
- return TypeCode.Decimal;
- }
- #endregion
-}
diff --git a/tests/src/CoreMangLib/cti/system/decimal/decimalparse2.cs b/tests/src/CoreMangLib/cti/system/decimal/decimalparse2.cs
deleted file mode 100644
index 3ff85cf979..0000000000
--- a/tests/src/CoreMangLib/cti/system/decimal/decimalparse2.cs
+++ /dev/null
@@ -1,414 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Globalization;
-/// <summary>
-/// Parse(System.String,System.Globalization.NumberStyles)
-/// </summary>
-public class DecimalParse2
-{
- #region Public Methods
- public bool RunTests()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.LogInformation("[Positive]");
- retVal = PosTest1() && retVal;
- retVal = PosTest2() && retVal;
- retVal = PosTest3() && retVal;
- TestLibrary.TestFramework.LogInformation("[Negitive]");
- retVal = NegTest1() && retVal;
- retVal = NegTest2() && retVal;
- retVal = NegTest3() && retVal;
- retVal = NegTest4() && retVal;
- retVal = NegTest5() && retVal;
- retVal = NegTest6() && retVal;
- retVal = NegTest7() && retVal;
- return retVal;
- }
-
- #region Positive Test Cases
- public bool PosTest1()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest1: Calling Parse method.");
-
- try
- {
- Decimal m1 = new decimal(TestLibrary.Generator.GetDouble(-55));
- CultureInfo myCulture = CultureInfo.CurrentCulture;
- string m1ToString = m1.ToString(myCulture);
- Decimal expectValue = m1;
- retVal = VerifyHelper(m1, m1ToString, NumberStyles.AllowDecimalPoint, "001.1") & retVal;
- retVal = VerifyHelper(m1, m1ToString, NumberStyles.Any, "001.2") & retVal;
- retVal = VerifyHelper(m1, m1ToString, NumberStyles.Currency, "001.3") & retVal;
- retVal = VerifyHelper(m1, m1ToString, NumberStyles.Float, "001.4") & retVal;
- retVal = VerifyHelper(m1, m1ToString, NumberStyles.Number, "001.5") & retVal;
-
-
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
- public bool PosTest2()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest2: Calling Parse method and the decimal is MaxValue and MinValue.");
-
- try
- {
- Decimal m1 = Decimal.MaxValue;
- CultureInfo myCulture = CultureInfo.CurrentCulture;
- string m1ToString = m1.ToString(myCulture);
- Decimal expectValue = m1;
- Decimal actualValue = Decimal.Parse(m1ToString, NumberStyles.Any);
- if (actualValue != expectValue)
- {
- TestLibrary.TestFramework.LogError("002.1", "Parse method should return " + expectValue);
- retVal = false;
- }
-
- m1 = Decimal.MinValue;
- m1ToString = m1.ToString(myCulture);
- expectValue = m1;
- actualValue = Decimal.Parse(m1ToString,NumberStyles.Any);
- if (actualValue != expectValue)
- {
- TestLibrary.TestFramework.LogError("002.2", "Parse method should return " + expectValue);
- retVal = false;
- }
-
-
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest3()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest3: Calling Parse method and the decimal is Especial value.");
-
- try
- {
- Decimal m1 = -9876543210.9876543210m;
- CultureInfo myCulture = CultureInfo.CurrentCulture;
- string m1ToString = m1.ToString(myCulture);
- Decimal expectValue = m1;
- Decimal actualValue = Decimal.Parse(m1ToString, NumberStyles.Any);
- if (actualValue != expectValue)
- {
- TestLibrary.TestFramework.LogError("003.1", "Parse method should return " + expectValue);
- retVal = false;
- }
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
- #endregion
- #region Negitive test
- public bool NegTest1()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest1: s is a null reference.");
-
- try
- {
- string m1ToString = null;
-
- Decimal actualValue = Decimal.Parse(m1ToString, NumberStyles.Any);
- TestLibrary.TestFramework.LogError("101.1", "ArgumentNullException should be caught." );
- retVal = false;
- }
- catch (ArgumentNullException)
- {
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("101.0", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest2()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest2: s is not in the correct format.");
-
- try
- {
- string m1ToString = "ADAAAW";
-
- Decimal actualValue = Decimal.Parse(m1ToString, NumberStyles.Any);
- TestLibrary.TestFramework.LogError("102.1", "FormatException should be caught.");
- retVal = false;
- }
- catch (FormatException)
- {
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("102.0", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest3()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest3: s represents a number greater than MaxValue.");
-
- try
- {
-
- Decimal myDecimal = decimal.MaxValue;
- CultureInfo myCulture = CultureInfo.CurrentCulture;
- string m1ToString = myDecimal.ToString(myCulture);
- m1ToString = m1ToString + m1ToString;
- Decimal actualValue = Decimal.Parse(m1ToString, NumberStyles.Any);
- TestLibrary.TestFramework.LogError("103.1", "OverflowException should be caught.");
- retVal = false;
- }
- catch (OverflowException)
- {
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("103.0", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest4()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest4: s represents a number less than MinValue.");
-
- try
- {
-
- Decimal myDecimal = decimal.MinValue;
- CultureInfo myCulture = CultureInfo.CurrentCulture;
- string m1ToString = myDecimal.ToString(myCulture);
- m1ToString = m1ToString + Decimal.Negate(myDecimal).ToString(myCulture);
- Decimal actualValue = Decimal.Parse(m1ToString, NumberStyles.Any);
- TestLibrary.TestFramework.LogError("104.1", "OverflowException should be caught.");
- retVal = false;
- }
- catch (OverflowException)
- {
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("104.0", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
- public bool NegTest5()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest5: not support NumberStyles .");
-
- try
- {
- Decimal m1 = new decimal(TestLibrary.Generator.GetDouble(-55));
- CultureInfo myCulture = CultureInfo.CurrentCulture;
- string m1ToString = m1.ToString(myCulture);
- Decimal expectValue = m1;
- retVal = VerifyNegHelper(m1, m1ToString, NumberStyles.AllowCurrencySymbol, "105.1") & retVal;
- retVal = VerifyNegHelper(m1, m1ToString, NumberStyles.AllowExponent, "105.2") & retVal;
- retVal = VerifyNegHelper(m1, m1ToString, NumberStyles.AllowLeadingSign, "105.4") & retVal;
- retVal = VerifyNegHelper(m1, m1ToString, NumberStyles.AllowLeadingWhite, "105.5") & retVal;
- retVal = VerifyNegHelper(m1, m1ToString, NumberStyles.AllowParentheses, "105.6") & retVal;
- retVal = VerifyNegHelper(m1, m1ToString, NumberStyles.AllowThousands, "105.7") & retVal;
- retVal = VerifyNegHelper(m1, m1ToString, NumberStyles.AllowTrailingSign, "105.8") & retVal;
-
- retVal = VerifyNegHelper(m1, m1ToString, NumberStyles.AllowTrailingWhite, "105.9") & retVal;
- retVal = VerifyNegHelper(m1, m1ToString, NumberStyles.Integer, "105.11") & retVal;
- retVal = VerifyNegHelper(m1, m1ToString, NumberStyles.None, "105.12") & retVal;
- }
-
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("105.0", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest6()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest6: style is the AllowHexSpecifier value.");
-
- try
- {
- Decimal m1 = new decimal(TestLibrary.Generator.GetDouble(-55));
- CultureInfo myCulture = CultureInfo.CurrentCulture;
- string m1ToString = m1.ToString(myCulture);
- Decimal expectValue = m1;
- retVal = VerifyNegHexHelper(m1, m1ToString, NumberStyles.AllowHexSpecifier, "106.1") & retVal;
- retVal = VerifyNegHexHelper(m1, m1ToString, NumberStyles.HexNumber, "106.2") & retVal;
-
- }
-
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("106.0", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
-
- public bool NegTest7()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest6: style is not a NumberStyles value.");
-
- try
- {
- Decimal m1 = new decimal(TestLibrary.Generator.GetDouble(-55));
- CultureInfo myCulture = CultureInfo.CurrentCulture;
- string m1ToString = m1.ToString(myCulture);
- Decimal expectValue = m1;
- retVal = VerifyNegHexHelper(m1, m1ToString,(NumberStyles)9999, "107.1") & retVal;
-
- }
-
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("107.0", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- #endregion
- #endregion
-
- public static int Main()
- {
- DecimalParse2 test = new DecimalParse2();
-
- TestLibrary.TestFramework.BeginTestCase("DecimalParse2");
-
- if (test.RunTests())
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("PASS");
- return 100;
- }
- else
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("FAIL");
- return 0;
- }
- }
- #region private method
- private bool VerifyHelper(Decimal expectValue, string testValue, NumberStyles myNumberStyles, string errorno)
- {
- bool retVal = true;
- try
- {
- Decimal actualValue = Decimal.Parse(testValue, myNumberStyles);
- if (actualValue != expectValue)
- {
- TestLibrary.TestFramework.LogError(errorno, "Parse should return " + expectValue);
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError(errorno + ".0", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- private bool VerifyNegHelper(Decimal expectValue, string testValue, NumberStyles myNumberStyles, string errorno)
- {
- bool retVal = true;
- try
- {
- Decimal actualValue = Decimal.Parse(testValue, myNumberStyles);
-
- TestLibrary.TestFramework.LogError(errorno, "FormatException should be caught.");
- retVal = false;
-
- }
- catch (FormatException)
- {
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError(errorno + ".0", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- private bool VerifyNegHexHelper(Decimal expectValue, string testValue, NumberStyles myNumberStyles, string errorno)
- {
- bool retVal = true;
- try
- {
- Decimal actualValue = Decimal.Parse(testValue, myNumberStyles);
-
- TestLibrary.TestFramework.LogError(errorno, "ArgumentException should be caught.");
- retVal = false;
-
- }
- catch (ArgumentException)
- {
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError(errorno + ".0", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- #endregion
-}
diff --git a/tests/src/CoreMangLib/cti/system/decimal/decimalparse3.cs b/tests/src/CoreMangLib/cti/system/decimal/decimalparse3.cs
deleted file mode 100644
index eec6105916..0000000000
--- a/tests/src/CoreMangLib/cti/system/decimal/decimalparse3.cs
+++ /dev/null
@@ -1,417 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Globalization;
-/// <summary>
-/// Parse(System.String,System.Globalization.NumberStyles,System.IFormatProvider)
-/// </summary>
-public class DecimalParse3
-{
- #region Public Methods
- public bool RunTests()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.LogInformation("[Positive]");
- retVal = PosTest1() && retVal;
- retVal = PosTest2() && retVal;
- retVal = PosTest3() && retVal;
- TestLibrary.TestFramework.LogInformation("[Negitive]");
- retVal = NegTest1() && retVal;
- retVal = NegTest2() && retVal;
- retVal = NegTest3() && retVal;
- retVal = NegTest4() && retVal;
- retVal = NegTest5() && retVal;
- retVal = NegTest6() && retVal;
- retVal = NegTest7() && retVal;
- return retVal;
- }
-
- #region Positive Test Cases
- public bool PosTest1()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest1: Calling Parse method.");
-
- try
- {
- Decimal m1 = new decimal(TestLibrary.Generator.GetDouble(-55));
- CultureInfo myCulture = CultureInfo.InvariantCulture;
- string m1ToString = m1.ToString(myCulture);
- Decimal expectValue = m1;
- retVal = VerifyHelper(m1, m1ToString, NumberStyles.AllowDecimalPoint, "001.1") & retVal;
- retVal = VerifyHelper(m1, m1ToString, NumberStyles.Any, "001.2") & retVal;
- retVal = VerifyHelper(m1, m1ToString, NumberStyles.Currency, "001.3") & retVal;
- retVal = VerifyHelper(m1, m1ToString, NumberStyles.Float, "001.4") & retVal;
- retVal = VerifyHelper(m1, m1ToString, NumberStyles.Number, "001.5") & retVal;
-
-
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
- public bool PosTest2()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest2: Calling Parse method and the decimal is MaxValue and MinValue.");
-
- try
- {
- Decimal m1 = Decimal.MaxValue;
- CultureInfo myCulture = CultureInfo.CurrentCulture;
- string m1ToString = m1.ToString(myCulture);
- Decimal expectValue = m1;
- Decimal actualValue = Decimal.Parse(m1ToString, NumberStyles.Any, myCulture);
- if (actualValue != expectValue)
- {
- TestLibrary.TestFramework.LogError("002.1", "Parse method should return " + expectValue);
- retVal = false;
- }
-
- m1 = Decimal.MinValue;
- m1ToString = m1.ToString(myCulture);
- expectValue = m1;
- actualValue = Decimal.Parse(m1ToString,NumberStyles.Any);
- if (actualValue != expectValue)
- {
- TestLibrary.TestFramework.LogError("002.2", "Parse method should return " + expectValue);
- retVal = false;
- }
-
-
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest3()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest3: Calling Parse method and the decimal is Especial value.");
-
- try
- {
- Decimal m1 = -9876543210.9876543210m;
- CultureInfo myCulture = CultureInfo.CurrentCulture;
- string m1ToString = m1.ToString(myCulture);
- Decimal expectValue = m1;
- Decimal actualValue = Decimal.Parse(m1ToString, NumberStyles.Any, myCulture);
- if (actualValue != expectValue)
- {
- TestLibrary.TestFramework.LogError("003.1", "Parse method should return " + expectValue);
- retVal = false;
- }
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
- #endregion
- #region Negitive test
- public bool NegTest1()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest1: s is a null reference.");
-
- try
- {
- string m1ToString = null;
- CultureInfo myCluture = CultureInfo.InvariantCulture;
- Decimal actualValue = Decimal.Parse(m1ToString, NumberStyles.Any, myCluture);
- TestLibrary.TestFramework.LogError("101.1", "ArgumentNullException should be caught." );
- retVal = false;
- }
- catch (ArgumentNullException)
- {
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("101.0", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest2()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest2: s is not in the correct format.");
-
- try
- {
- string m1ToString = "ADAAAW";
- CultureInfo myCluture = CultureInfo.InvariantCulture;
- Decimal actualValue = Decimal.Parse(m1ToString, NumberStyles.Any, myCluture);
- TestLibrary.TestFramework.LogError("102.1", "FormatException should be caught.");
- retVal = false;
- }
- catch (FormatException)
- {
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("102.0", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest3()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest3: s represents a number greater than MaxValue.");
-
- try
- {
-
- Decimal myDecimal = decimal.MaxValue;
- CultureInfo myCulture = CultureInfo.CurrentCulture;
- string m1ToString = myDecimal.ToString(myCulture);
- m1ToString = m1ToString + m1ToString;
- Decimal actualValue = Decimal.Parse(m1ToString, NumberStyles.Any, myCulture);
- TestLibrary.TestFramework.LogError("103.1", "OverflowException should be caught.");
- retVal = false;
- }
- catch (OverflowException)
- {
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("103.0", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest4()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest4: s represents a number less than MinValue.");
-
- try
- {
-
- Decimal myDecimal = decimal.MinValue;
- CultureInfo myCulture = CultureInfo.CurrentCulture;
- string m1ToString = myDecimal.ToString(myCulture);
- m1ToString = m1ToString + Decimal.Negate(myDecimal).ToString(myCulture);
- Decimal actualValue = Decimal.Parse(m1ToString, NumberStyles.Any, myCulture);
- TestLibrary.TestFramework.LogError("104.1", "OverflowException should be caught.");
- retVal = false;
- }
- catch (OverflowException)
- {
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("104.0", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
- public bool NegTest5()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest5: not support NumberStyles .");
-
- try
- {
- Decimal m1 = new decimal(TestLibrary.Generator.GetDouble(-55));
- CultureInfo myCulture = CultureInfo.InvariantCulture;
- string m1ToString = m1.ToString(myCulture);
- Decimal expectValue = m1;
- retVal = VerifyNegHelper(m1, m1ToString, NumberStyles.AllowCurrencySymbol, "105.1") & retVal;
- retVal = VerifyNegHelper(m1, m1ToString, NumberStyles.AllowExponent, "105.2") & retVal;
- retVal = VerifyNegHelper(m1, m1ToString, NumberStyles.AllowLeadingSign, "105.4") & retVal;
- retVal = VerifyNegHelper(m1, m1ToString, NumberStyles.AllowLeadingWhite, "105.5") & retVal;
- retVal = VerifyNegHelper(m1, m1ToString, NumberStyles.AllowParentheses, "105.6") & retVal;
- retVal = VerifyNegHelper(m1, m1ToString, NumberStyles.AllowThousands, "105.7") & retVal;
- retVal = VerifyNegHelper(m1, m1ToString, NumberStyles.AllowTrailingSign, "105.8") & retVal;
-
- retVal = VerifyNegHelper(m1, m1ToString, NumberStyles.AllowTrailingWhite, "105.9") & retVal;
- retVal = VerifyNegHelper(m1, m1ToString, NumberStyles.Integer, "105.11") & retVal;
- retVal = VerifyNegHelper(m1, m1ToString, NumberStyles.None, "105.12") & retVal;
- }
-
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("105.0", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest6()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest6: style is the AllowHexSpecifier value.");
-
- try
- {
- Decimal m1 = new decimal(TestLibrary.Generator.GetDouble(-55));
- CultureInfo myCulture = CultureInfo.InvariantCulture;
- string m1ToString = m1.ToString(myCulture);
- Decimal expectValue = m1;
- retVal = VerifyNegHexHelper(m1, m1ToString, NumberStyles.AllowHexSpecifier, "106.1") & retVal;
- retVal = VerifyNegHexHelper(m1, m1ToString, NumberStyles.HexNumber, "106.2") & retVal;
-
- }
-
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("106.0", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
-
- public bool NegTest7()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest6: style is not a NumberStyles value.");
-
- try
- {
- Decimal m1 = new decimal(TestLibrary.Generator.GetDouble(-55));
- CultureInfo myCulture = CultureInfo.InvariantCulture;
- string m1ToString = m1.ToString(myCulture);
- Decimal expectValue = m1;
- retVal = VerifyNegHexHelper(m1, m1ToString,(NumberStyles)9999, "107.1") & retVal;
-
- }
-
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("107.0", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- #endregion
- #endregion
-
- public static int Main()
- {
- DecimalParse3 test = new DecimalParse3();
-
- TestLibrary.TestFramework.BeginTestCase("DecimalParse3");
-
- if (test.RunTests())
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("PASS");
- return 100;
- }
- else
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("FAIL");
- return 0;
- }
- }
- #region private method
- private bool VerifyHelper(Decimal expectValue, string testValue, NumberStyles myNumberStyles, string errorno)
- {
- bool retVal = true;
- try
- {
- CultureInfo myCluture = CultureInfo.InvariantCulture;
- Decimal actualValue = Decimal.Parse(testValue, myNumberStyles, myCluture);
- if (actualValue != expectValue)
- {
- TestLibrary.TestFramework.LogError(errorno, "Parse should return " + expectValue);
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError(errorno + ".0", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- private bool VerifyNegHelper(Decimal expectValue, string testValue, NumberStyles myNumberStyles, string errorno)
- {
- bool retVal = true;
- try
- {
- CultureInfo myCluture = CultureInfo.InvariantCulture;
- Decimal actualValue = Decimal.Parse(testValue, myNumberStyles, myCluture);
-
- TestLibrary.TestFramework.LogError(errorno, "FormatException should be caught.");
- retVal = false;
-
- }
- catch (FormatException)
- {
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError(errorno + ".0", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- private bool VerifyNegHexHelper(Decimal expectValue, string testValue, NumberStyles myNumberStyles, string errorno)
- {
- bool retVal = true;
- try
- {
- CultureInfo myCluture = CultureInfo.InvariantCulture;
- Decimal actualValue = Decimal.Parse(testValue, myNumberStyles, myCluture);
-
- TestLibrary.TestFramework.LogError(errorno, "ArgumentException should be caught.");
- retVal = false;
-
- }
- catch (ArgumentException)
- {
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError(errorno + ".0", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- #endregion
-}
diff --git a/tests/src/CoreMangLib/cti/system/decimal/decimalparse4.cs b/tests/src/CoreMangLib/cti/system/decimal/decimalparse4.cs
deleted file mode 100644
index 3a17b4b011..0000000000
--- a/tests/src/CoreMangLib/cti/system/decimal/decimalparse4.cs
+++ /dev/null
@@ -1,292 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Globalization;
-/// <summary>
-/// Parse(System.String,System.IFormatProvider)
-/// </summary>
-public class DecimalParse4
-{
- #region Public Methods
- public bool RunTests()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.LogInformation("[Positive]");
- retVal = PosTest1() && retVal;
- retVal = PosTest2() && retVal;
- retVal = PosTest3() && retVal;
- TestLibrary.TestFramework.LogInformation("[Negitive]");
- retVal = NegTest1() && retVal;
- retVal = NegTest2() && retVal;
- retVal = NegTest3() && retVal;
- retVal = NegTest4() && retVal;
- return retVal;
- }
-
- #region Positive Test Cases
- public bool PosTest1()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest1: Calling Parse method.");
-
- try
- {
- Decimal m1 = new decimal(TestLibrary.Generator.GetDouble(-55));
- CultureInfo myCulture = CultureInfo.CurrentCulture;
- string m1ToString = m1.ToString(myCulture);
- Decimal expectValue = m1;
- Decimal actualValue = Decimal.Parse(m1ToString, myCulture);
- if (actualValue != expectValue)
- {
- TestLibrary.TestFramework.LogError("001.1", "Parse method should return " + expectValue);
- retVal = false;
- }
-
-
- m1 = new decimal(TestLibrary.Generator.GetInt32(-55));
- m1ToString = m1.ToString(myCulture);
- expectValue = m1;
- actualValue = Decimal.Parse(m1ToString,myCulture);
- if (actualValue != expectValue)
- {
- TestLibrary.TestFramework.LogError("001.2", "Parse method should return " + expectValue);
- retVal = false;
- }
-
- m1 = new decimal(TestLibrary.Generator.GetSingle(-55));
- m1ToString = m1.ToString(myCulture);
- expectValue = m1;
- actualValue = Decimal.Parse(m1ToString, myCulture);
- if (actualValue != expectValue)
- {
- TestLibrary.TestFramework.LogError("001.3", "Parse method should return " + expectValue);
- retVal = false;
- }
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
- public bool PosTest2()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest2: Calling Parse method and the decimal is MaxValue and MinValue.");
-
- try
- {
- Decimal m1 = Decimal.MaxValue;
- CultureInfo myCulture = CultureInfo.CurrentCulture;
- string m1ToString = m1.ToString(myCulture);
- Decimal expectValue = m1;
- Decimal actualValue = Decimal.Parse(m1ToString, myCulture);
- if (actualValue != expectValue)
- {
- TestLibrary.TestFramework.LogError("002.1", "Parse method should return " + expectValue);
- TestLibrary.TestFramework.LogInformation("Actual value: " + actualValue.ToString());
- retVal = false;
- }
-
- m1 = Decimal.MinValue;
- m1ToString = m1.ToString(myCulture);
- expectValue = m1;
- actualValue = Decimal.Parse(m1ToString, myCulture);
- if (actualValue != expectValue)
- {
- TestLibrary.TestFramework.LogError("002.2", "Parse method should return " + expectValue);
- TestLibrary.TestFramework.LogInformation("Actual value: " + actualValue.ToString());
- retVal = false;
- }
-
-
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest3()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest3: Calling Parse method and the decimal is Especial value.");
-
- try
- {
- Decimal m1 = -9876543210.9876543210m;
- CultureInfo myCulture = CultureInfo.InvariantCulture;
- string m1ToString = m1.ToString(myCulture);
- Decimal expectValue = m1;
- Decimal actualValue = Decimal.Parse(m1ToString, myCulture);
- if (actualValue != expectValue)
- {
- TestLibrary.TestFramework.LogError("003.1", "Parse method should return " + expectValue);
- retVal = false;
- }
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
- #endregion
- #region Negitive test
- public bool NegTest1()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest1: s is a null reference.");
-
- try
- {
- string m1ToString = null;
- CultureInfo myCulture = CultureInfo.InvariantCulture;
- Decimal actualValue = Decimal.Parse(m1ToString, myCulture);
- TestLibrary.TestFramework.LogError("101.1", "ArgumentNullException should be caught.");
- retVal = false;
- }
- catch (ArgumentNullException)
- {
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("101.0", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest2()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest2: s is not in the correct format.");
-
- try
- {
- string m1ToString = "ADAAAW";
- CultureInfo myCulture = CultureInfo.InvariantCulture;
- Decimal actualValue = Decimal.Parse(m1ToString, myCulture);
- TestLibrary.TestFramework.LogError("102.1", "FormatException should be caught.");
- retVal = false;
- }
- catch (FormatException)
- {
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("102.0", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest3()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest3: s represents a number greater than MaxValue.");
-
- try
- {
-
- Decimal myDecimal = decimal.MaxValue;
- CultureInfo myCulture = CultureInfo.CurrentCulture;
- string m1ToString = myDecimal.ToString(myCulture);
- m1ToString = m1ToString + m1ToString;
- Decimal actualValue = Decimal.Parse(m1ToString, myCulture);
- TestLibrary.TestFramework.LogError("103.1", "OverflowException should be caught.");
- retVal = false;
- }
- catch (OverflowException)
- {
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("103.0", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest4()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest4: s represents a number less than MinValue.");
-
- try
- {
-
- Decimal myDecimal = decimal.MinValue;
- CultureInfo myCulture = CultureInfo.CurrentCulture;
- string m1ToString = myDecimal.ToString(myCulture);
- m1ToString = m1ToString + Decimal.Negate(myDecimal).ToString(myCulture);
- Decimal actualValue = Decimal.Parse(m1ToString,myCulture);
- TestLibrary.TestFramework.LogError("104.1", "OverflowException should be caught.");
- retVal = false;
- }
- catch (OverflowException)
- {
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("104.0", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
- #endregion
- #endregion
-
- public static int Main()
- {
- DecimalParse4 test = new DecimalParse4();
-
- TestLibrary.TestFramework.BeginTestCase("DecimalParse4");
-
- if (test.RunTests())
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("PASS");
- return 100;
- }
- else
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("FAIL");
- return 0;
- }
- }
- #region private method
- public TypeCode GetExpectValue(Decimal myValue)
- {
- return TypeCode.Decimal;
- }
- #endregion
-}
diff --git a/tests/src/CoreMangLib/cti/system/decimal/decimaltryparse.cs b/tests/src/CoreMangLib/cti/system/decimal/decimaltryparse.cs
deleted file mode 100644
index e6203babcf..0000000000
--- a/tests/src/CoreMangLib/cti/system/decimal/decimaltryparse.cs
+++ /dev/null
@@ -1,839 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Globalization;
-
-// Ported to CoreCLR from Co7531TryParse_all.cs
-// Tests Decimal.TryParse(String), Decimal.TryParse(String, NumberStyles, IFormatProvider, ref Decimal)
-// 2003/04/01 KatyK
-// 2007/07/12 adapted by MarielY
-public class Co7531TryParse
-{
- static bool verbose = false;
-
- public static int Main()
- {
- bool passed = true;
-
- try
- {
- // Make the test culture independent
- TestLibrary.Utilities.CurrentCulture = CultureInfo.InvariantCulture;
-
- // Set up NFIs to use
- NumberFormatInfo goodNFI = new NumberFormatInfo();
-
- NumberFormatInfo corruptNFI = new NumberFormatInfo(); // DecimalSeparator == GroupSeparator
- corruptNFI.NumberDecimalSeparator = ".";
- corruptNFI.NumberGroupSeparator = ".";
- corruptNFI.CurrencyDecimalSeparator = ".";
- corruptNFI.CurrencyGroupSeparator = ".";
- corruptNFI.CurrencySymbol = "$";
-
- NumberFormatInfo swappedNFI = new NumberFormatInfo(); // DecimalSeparator & GroupSeparator swapped
- swappedNFI.NumberDecimalSeparator = ".";
- swappedNFI.NumberGroupSeparator = ",";
- swappedNFI.CurrencyDecimalSeparator = ",";
- swappedNFI.CurrencyGroupSeparator = ".";
- swappedNFI.CurrencySymbol = "$";
-
- NumberFormatInfo distinctNFI = new NumberFormatInfo(); // DecimalSeparator & GroupSeparator distinct
- distinctNFI.NumberDecimalSeparator = ".";
- distinctNFI.NumberGroupSeparator = ",";
- distinctNFI.CurrencyDecimalSeparator = ":";
- distinctNFI.CurrencyGroupSeparator = ";";
- distinctNFI.CurrencySymbol = "$";
-
- NumberFormatInfo customNFI = new NumberFormatInfo();
- customNFI.NegativeSign = "^";
-
- NumberFormatInfo ambigNFI = new NumberFormatInfo();
- ambigNFI.NegativeSign = "^";
- ambigNFI.CurrencySymbol = "^";
-
- CultureInfo invariantCulture = CultureInfo.InvariantCulture;
- CultureInfo germanCulture = new CultureInfo("de-DE");
- CultureInfo japaneseCulture;
- try {
- japaneseCulture = new CultureInfo("ja-JP");
- }
- catch (CultureNotFoundException)
- {
- TestLibrary.TestFramework.LogInformation("East Asian Languages are not installed. Skipping Japanese culture test(s).");
- japaneseCulture = null;
- }
-
- // Parse tests included for comparison/regression
- passed &= VerifyDecimalParse("5", 5);
- passed &= VerifyDecimalParse("5 ", 5);
- passed &= VerifyDecimalParse("5\0", 5);
- passed &= VerifyDecimalParse("-5", -5);
- passed &= VerifyDecimalParse("893382737", 893382737);
- passed &= VerifyDecimalParse("-893382737", -893382737);
- passed &= VerifyDecimalParse("1234567891", 1234567891);
- passed &= VerifyDecimalParse("-1234567891", -1234567891);
- passed &= VerifyDecimalParse("123456789123456789", 123456789123456789);
- passed &= VerifyDecimalParse("-123456789123456789", -123456789123456789);
- passed &= VerifyDecimalParse("5", NumberStyles.Integer, CultureInfo.InvariantCulture, 5);
- passed &= VerifyDecimalParse("5 \0", NumberStyles.Integer, CultureInfo.InvariantCulture, 5);
- passed &= VerifyDecimalParse("5\0\0\0", NumberStyles.Integer, CultureInfo.InvariantCulture, 5);
- passed &= VerifyDecimalParse("-5", NumberStyles.Integer, CultureInfo.InvariantCulture, -5);
- passed &= VerifyDecimalParse("5", NumberStyles.Integer, goodNFI, 5);
- passed &= VerifyDecimalParse("5.0", NumberStyles.AllowDecimalPoint, goodNFI, 5.0m);
- passed &= VerifyDecimalParse("5.3", NumberStyles.AllowDecimalPoint, goodNFI, 5.3m);
- passed &= VerifyDecimalParse("123456789123456789123", 123456789123456789123m);
- passed &= VerifyDecimalParse("-123456789123456789123", -123456789123456789123m);
- passed &= VerifyDecimalParse("18446744073709551615", 18446744073709551615);
- passed &= VerifyDecimalParse("79228162514264337593543950335", 79228162514264337593543950335m);
- passed &= VerifyDecimalParse("-79228162514264337593543950335", -79228162514264337593543950335m);
- passed &= VerifyDecimalParse("5.555555555", 5.555555555m);
- passed &= VerifyDecimalParse("1.000000", 1.000000m);
- passed &= VerifyDecimalParse("123", NumberStyles.Integer, germanCulture, 123);
- passed &= VerifyDecimalParse("123", NumberStyles.Integer, japaneseCulture, 123);
- passed &= VerifyDecimalParse("123.456", NumberStyles.Any, germanCulture, 123456);
- passed &= VerifyDecimalParse("123,456", NumberStyles.Any, japaneseCulture, 123456);
- passed &= VerifyDecimalParse("123,456", NumberStyles.AllowDecimalPoint, germanCulture, 123.456m);
- passed &= VerifyDecimalParse("123.456", NumberStyles.AllowDecimalPoint, japaneseCulture, 123.456m);
- passed &= VerifyDecimalParse("5,23 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Any, germanCulture, 5.23m); // currency
- passed &= VerifyDecimalParse("5.23 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Any, germanCulture, 523); // currency
- //
- passed &= VerifyDecimalParse("5", NumberStyles.Integer, corruptNFI, 5);
- passed &= VerifyDecimalParse("5", NumberStyles.Number, corruptNFI, 5);
- passed &= VerifyDecimalParse("5.3", NumberStyles.Number, corruptNFI, 5.3m);
- passed &= VerifyDecimalParseException("5,3", NumberStyles.Number, corruptNFI, typeof(FormatException));
- passed &= VerifyDecimalParseException("5.2.3", NumberStyles.Number, corruptNFI, typeof(FormatException));
- passed &= VerifyDecimalParse("$5.3", NumberStyles.Currency, corruptNFI, 5.3m);
- passed &= VerifyDecimalParseException("$5,3", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyDecimalParseException("$5.2.3", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyDecimalParse("5.3", NumberStyles.Currency, corruptNFI, 5.3m);
- passed &= VerifyDecimalParseException("5,3", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyDecimalParseException("5.2.3", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyDecimalParse("5.3", NumberStyles.Any, corruptNFI, 5.3m);
- passed &= VerifyDecimalParseException("5,3", NumberStyles.Any, corruptNFI, typeof(FormatException));
- passed &= VerifyDecimalParseException("5.2.3", NumberStyles.Any, corruptNFI, typeof(FormatException));
- //
- passed &= VerifyDecimalParse("5", NumberStyles.Integer, swappedNFI, 5);
- passed &= VerifyDecimalParseException("1,234", NumberStyles.Integer, swappedNFI, typeof(FormatException));
- passed &= VerifyDecimalParse("5", NumberStyles.Number, swappedNFI, 5);
- passed &= VerifyDecimalParse("5.0", NumberStyles.Number, swappedNFI, 5.0m);
- passed &= VerifyDecimalParse("1,234", NumberStyles.Number, swappedNFI, 1234);
- passed &= VerifyDecimalParse("1,234.0", NumberStyles.Number, swappedNFI, 1234.0m);
- passed &= VerifyDecimalParseException("5.000.000", NumberStyles.Number, swappedNFI, typeof(FormatException));
- passed &= VerifyDecimalParseException("5.000,00", NumberStyles.Number, swappedNFI, typeof(FormatException));
- passed &= VerifyDecimalParse("5.000", NumberStyles.Currency, swappedNFI, 5); //???
- passed &= VerifyDecimalParseException("5.000,00", NumberStyles.Currency, swappedNFI, typeof(FormatException)); //???
- passed &= VerifyDecimalParse("$5.000", NumberStyles.Currency, swappedNFI, 5000);
- passed &= VerifyDecimalParse("$5.000,00", NumberStyles.Currency, swappedNFI, 5000);
- passed &= VerifyDecimalParse("5.000", NumberStyles.Any, swappedNFI, 5); //?
- passed &= VerifyDecimalParseException("5.000,00", NumberStyles.Any, swappedNFI, typeof(FormatException)); //?
- passed &= VerifyDecimalParse("$5.000", NumberStyles.Any, swappedNFI, 5000);
- passed &= VerifyDecimalParse("$5.000,00", NumberStyles.Any, swappedNFI, 5000);
- passed &= VerifyDecimalParse("5,0", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyDecimalParse("$5,0", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyDecimalParse("5,000", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyDecimalParse("$5,000", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyDecimalParseException("5,000.0", NumberStyles.Currency, swappedNFI, typeof(FormatException));
- passed &= VerifyDecimalParseException("$5,000.0", NumberStyles.Currency, swappedNFI, typeof(FormatException));
- passed &= VerifyDecimalParse("5,000", NumberStyles.Any, swappedNFI, 5);
- passed &= VerifyDecimalParse("$5,000", NumberStyles.Any, swappedNFI, 5);
- passed &= VerifyDecimalParseException("5,000.0", NumberStyles.Any, swappedNFI, typeof(FormatException));
- passed &= VerifyDecimalParseException("$5,000.0", NumberStyles.Any, swappedNFI, typeof(FormatException));
- //
- passed &= VerifyDecimalParse("5.0", NumberStyles.Number, distinctNFI, 5);
- passed &= VerifyDecimalParse("1,234.0", NumberStyles.Number, distinctNFI, 1234);
- passed &= VerifyDecimalParse("5.0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyDecimalParse("1,234.0", NumberStyles.Currency, distinctNFI, 1234);
- passed &= VerifyDecimalParse("5.0", NumberStyles.Any, distinctNFI, 5);
- passed &= VerifyDecimalParse("1,234.0", NumberStyles.Any, distinctNFI, 1234);
- passed &= VerifyDecimalParseException("$5.0", NumberStyles.Currency, distinctNFI, typeof(FormatException));
- passed &= VerifyDecimalParseException("$5.0", NumberStyles.Any, distinctNFI, typeof(FormatException));
- passed &= VerifyDecimalParseException("5:0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyDecimalParseException("5;0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyDecimalParseException("$5:0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyDecimalParse("5:0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyDecimalParse("5:000", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyDecimalParse("5;000", NumberStyles.Currency, distinctNFI, 5000);
- passed &= VerifyDecimalParse("$5:0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyDecimalParse("$5;0", NumberStyles.Currency, distinctNFI, 50);
- passed &= VerifyDecimalParse("5:0", NumberStyles.Any, distinctNFI, 5);
- passed &= VerifyDecimalParse("5;0", NumberStyles.Any, distinctNFI, 50);
- passed &= VerifyDecimalParse("$5:0", NumberStyles.Any, distinctNFI, 5);
- passed &= VerifyDecimalParse("$5;0", NumberStyles.Any, distinctNFI, 50);
- passed &= VerifyDecimalParseException("123,456;789.0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyDecimalParse("123,456;789.0", NumberStyles.Currency, distinctNFI, 123456789);
- passed &= VerifyDecimalParse("123,456;789.0", NumberStyles.Any, distinctNFI, 123456789);
- passed &= VerifyDecimalParseException("$123,456;789.0", NumberStyles.Any, distinctNFI, typeof(FormatException));
- //
- passed &= VerifyDecimalParseException("79228162514264337593543950336", typeof(OverflowException));
- passed &= VerifyDecimalParseException("-79228162514264337593543950336", typeof(OverflowException));
- passed &= VerifyDecimalParseException("Garbage", typeof(FormatException));
- passed &= VerifyDecimalParseException("5\0Garbage", typeof(FormatException));
- passed &= VerifyDecimalParseException(null, typeof(ArgumentNullException));
- passed &= VerifyDecimalParseException("FF", NumberStyles.HexNumber, goodNFI, typeof(ArgumentException));
- passed &= VerifyDecimalParseException("4", (NumberStyles)(-1), typeof(ArgumentException));
- passed &= VerifyDecimalParseException("4", (NumberStyles)0x10000, typeof(ArgumentException));
- passed &= VerifyDecimalParseException("4", (NumberStyles)(-1), CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifyDecimalParseException("4", (NumberStyles)0x10000, CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifyDecimalParseException("123,000,000,000,000,000,000", NumberStyles.Any, germanCulture, typeof(FormatException));
- passed &= VerifyDecimalParseException("123.000.000.000.000.000.000", NumberStyles.Any, japaneseCulture, typeof(FormatException));
- passed &= VerifyDecimalParseException("5,00 \u20AC", NumberStyles.Integer, germanCulture, typeof(FormatException)); // currency
-
- // Underflow cases - see VSWhidbey #576556
- Decimal zeroScale28 = new Decimal(0, 0, 0, false, 28);
- Decimal zeroScale27 = new Decimal(0, 0, 0, false, 27);
- passed &= VerifyExactDecimalParse("0E-27", NumberStyles.AllowExponent, zeroScale27);
- passed &= VerifyExactDecimalParse("0E-28", NumberStyles.AllowExponent, zeroScale28);
- passed &= VerifyExactDecimalParse("0E-29", NumberStyles.AllowExponent, zeroScale28);
- passed &= VerifyExactDecimalParse("0E-30", NumberStyles.AllowExponent, zeroScale28);
- passed &= VerifyExactDecimalParse("0E-31", NumberStyles.AllowExponent, zeroScale28);
- passed &= VerifyExactDecimalParse("0E-50", NumberStyles.AllowExponent, zeroScale28);
- passed &= VerifyExactDecimalParse("0E-100", NumberStyles.AllowExponent, zeroScale28);
- passed &= VerifyExactDecimalParse("0.000000000000000000000000000", zeroScale27);
- passed &= VerifyExactDecimalParse("0.0000000000000000000000000000", zeroScale28); //28
- passed &= VerifyExactDecimalParse("0.00000000000000000000000000000", zeroScale28); //29
- passed &= VerifyExactDecimalParse("0.000000000000000000000000000000", zeroScale28); //30
- passed &= VerifyExactDecimalParse("0.0000000000000000000000000000000", zeroScale28); //31
- passed &= VerifyExactDecimalParse("0.0", new Decimal(0, 0, 0, false, 1));
- passed &= VerifyExactDecimalParse("0E-15", NumberStyles.AllowExponent, new Decimal(0, 0, 0, false, 15));
- passed &= VerifyExactDecimalParse("0", Decimal.Zero);
-
- Decimal oneScale27 = new Decimal(1, 0, 0, false, 27);
- Decimal oneScale28 = new Decimal(1, 0, 0, false, 28);
-
- passed &= VerifyExactDecimalParse("1E-27", NumberStyles.AllowExponent, oneScale27);
- passed &= VerifyExactDecimalParse("1E-28", NumberStyles.AllowExponent, oneScale28);
- passed &= VerifyExactDecimalParse("1E-29", NumberStyles.AllowExponent, zeroScale28);
- passed &= VerifyExactDecimalParse("1E-30", NumberStyles.AllowExponent, zeroScale28);
- passed &= VerifyExactDecimalParse("1E-31", NumberStyles.AllowExponent, zeroScale28);
- passed &= VerifyExactDecimalParse("1E-50", NumberStyles.AllowExponent, zeroScale28);
- passed &= VerifyExactDecimalParse("1E-100", NumberStyles.AllowExponent, zeroScale28);
-
- passed &= VerifyExactDecimalParse("1E-27", NumberStyles.AllowExponent, invariantCulture, oneScale27);
- passed &= VerifyExactDecimalParse("1E-28", NumberStyles.AllowExponent, invariantCulture, oneScale28);
- passed &= VerifyExactDecimalParse("1E-29", NumberStyles.AllowExponent, invariantCulture, zeroScale28);
- passed &= VerifyExactDecimalParse("1E-30", NumberStyles.AllowExponent, invariantCulture, zeroScale28);
- passed &= VerifyExactDecimalParse("1E-31", NumberStyles.AllowExponent, invariantCulture, zeroScale28);
- passed &= VerifyExactDecimalParse("1E-50", NumberStyles.AllowExponent, invariantCulture, zeroScale28);
- passed &= VerifyExactDecimalParse("1E-100", NumberStyles.AllowExponent, invariantCulture, zeroScale28);
- passed &= VerifyExactDecimalParse("0E-27", NumberStyles.AllowExponent, invariantCulture, zeroScale27);
- passed &= VerifyExactDecimalParse("0E-28", NumberStyles.AllowExponent, invariantCulture, zeroScale28);
- passed &= VerifyExactDecimalParse("0E-29", NumberStyles.AllowExponent, invariantCulture, zeroScale28);
- passed &= VerifyExactDecimalParse("0E-30", NumberStyles.AllowExponent, invariantCulture, zeroScale28);
- passed &= VerifyExactDecimalParse("0E-31", NumberStyles.AllowExponent, invariantCulture, zeroScale28);
- passed &= VerifyExactDecimalParse("0E-50", NumberStyles.AllowExponent, invariantCulture, zeroScale28);
- passed &= VerifyExactDecimalParse("0E-100", NumberStyles.AllowExponent, invariantCulture, zeroScale28);
-
- // make sure parse lines up with compiler
- //passed &= VerifyExactDecimalParse("0E-50", NumberStyles.AllowExponent, 0E-50m); // V2->V4 compiler change
- passed &= VerifyExactDecimalParse("1E-50", NumberStyles.AllowExponent, 1E-50m);
- passed &= VerifyExactDecimalParse("2E-100", NumberStyles.AllowExponent, 2E-100m);
- passed &= VerifyExactDecimalParse("100E-29", NumberStyles.AllowExponent, 100E-29m);
- passed &= VerifyExactDecimalParse("200E-29", NumberStyles.AllowExponent, 200E-29m);
- passed &= VerifyExactDecimalParse("500E-29", NumberStyles.AllowExponent, 500E-29m);
- passed &= VerifyExactDecimalParse("900E-29", NumberStyles.AllowExponent, 900E-29m);
- passed &= VerifyExactDecimalParse("1900E-29", NumberStyles.AllowExponent, 1900E-29m);
- passed &= VerifyExactDecimalParse("10900E-29", NumberStyles.AllowExponent, 10900E-29m);
- passed &= VerifyExactDecimalParse("10900E-30", NumberStyles.AllowExponent, 10900E-30m);
- passed &= VerifyExactDecimalParse("10900E-31", NumberStyles.AllowExponent, 10900E-31m);
- passed &= VerifyExactDecimalParse("10900E-32", NumberStyles.AllowExponent, 10900E-32m);
- passed &= VerifyExactDecimalParse("10900E-33", NumberStyles.AllowExponent, 10900E-33m);
- passed &= VerifyExactDecimalParse("10900E-34", NumberStyles.AllowExponent, 10900E-34m);
- passed &= VerifyExactDecimalParse("10900E-340", NumberStyles.AllowExponent, 10900E-340m);
- passed &= VerifyExactDecimalParse("10900E-512", NumberStyles.AllowExponent, 10900E-512m);
- passed &= VerifyExactDecimalParse("10900E-678", NumberStyles.AllowExponent, 10900E-678m);
- passed &= VerifyExactDecimalParse("10900E-999", NumberStyles.AllowExponent, 10900E-999m);
-
-
- /////////// TryParse(String)
- //// Pass cases
- passed &= VerifyDecimalTryParse("5", 5, true);
- passed &= VerifyDecimalTryParse(" 5 ", 5, true);
- passed &= VerifyDecimalTryParse("-5", -5, true);
- passed &= VerifyDecimalTryParse("5\0", 5, true);
- passed &= VerifyDecimalTryParse("5 \0", 5, true);
- passed &= VerifyDecimalTryParse("5\0\0\0", 5, true);
- passed &= VerifyDecimalTryParse("893382737", 893382737, true);
- passed &= VerifyDecimalTryParse("-893382737", -893382737, true);
- passed &= VerifyDecimalTryParse("1234567891", 1234567891, true);
- passed &= VerifyDecimalTryParse("-1234567891", -1234567891, true);
- passed &= VerifyDecimalTryParse("123456789123456789", 123456789123456789, true);
- passed &= VerifyDecimalTryParse("-123456789123456789", -123456789123456789, true);
- passed &= VerifyDecimalTryParse("123456789123456789123", 123456789123456789123m, true);
- passed &= VerifyDecimalTryParse("-123456789123456789123", -123456789123456789123m, true);
- passed &= VerifyDecimalTryParse("18446744073709551615", 18446744073709551615, true);
- passed &= VerifyDecimalTryParse("79228162514264337593543950335", 79228162514264337593543950335m, true);
- passed &= VerifyDecimalTryParse("-79228162514264337593543950335", -79228162514264337593543950335m, true);
- passed &= VerifyDecimalTryParse("7.3", 7.3m, true);
- passed &= VerifyDecimalTryParse(".297", 0.297m, true);
- passed &= VerifyDecimalTryParse("5.555555555", 5.555555555m, true);
- passed &= VerifyDecimalTryParse("1.000000", 1.000000m, true);
-
- //// Fail cases
- passed &= VerifyDecimalTryParse(null, 0, false);
- passed &= VerifyDecimalTryParse("", 0, false);
- passed &= VerifyDecimalTryParse("Garbage", 0, false);
- passed &= VerifyDecimalTryParse("5\0Garbage", 0, false);
- passed &= VerifyDecimalTryParse("FF", 0, false);
- passed &= VerifyDecimalTryParse("23 5", 0, false);
- passed &= VerifyDecimalTryParse("NaN", 0, false);
- passed &= VerifyDecimalTryParse("Infinity", 0, false);
- passed &= VerifyDecimalTryParse("-Infinity", 0, false);
- passed &= VerifyDecimalTryParse("79228162514264337593543950336", 0, false);
- passed &= VerifyDecimalTryParse("-79228162514264337593543950336", 0, false);
- passed &= VerifyDecimalTryParse("1.234+E05", 0, false);
- passed &= VerifyDecimalTryParse("1.234E+05", 0, false);
-
-
- /////////// TryParse(TryParse(String, NumberStyles, IFormatProvider, ref Decimal)
- //// Pass cases
- passed &= VerifyDecimalTryParse("5", NumberStyles.Integer, CultureInfo.InvariantCulture, 5, true);
- passed &= VerifyDecimalTryParse("-5", NumberStyles.Integer, CultureInfo.InvariantCulture, -5, true);
- // Variations on NumberStyles
- passed &= VerifyDecimalTryParse(" 5", NumberStyles.AllowLeadingWhite, goodNFI, 5, true);
- passed &= VerifyDecimalTryParse("5", NumberStyles.Number, goodNFI, 5, true);
- passed &= VerifyDecimalTryParse("5.0", NumberStyles.AllowDecimalPoint, goodNFI, 5.0m, true);
- passed &= VerifyDecimalTryParse("5.3", NumberStyles.AllowDecimalPoint, goodNFI, 5.3m, true);
- // Variations on IFP
- passed &= VerifyDecimalTryParse("5", NumberStyles.Integer, goodNFI, 5, true);
- passed &= VerifyDecimalTryParse("5", NumberStyles.Integer, null, 5, true);
- passed &= VerifyDecimalTryParse("5", NumberStyles.Integer, new DateTimeFormatInfo(), 5, true);
- passed &= VerifyDecimalTryParse("^42", NumberStyles.Any, customNFI, -42, true);
- passed &= VerifyDecimalTryParse("123", NumberStyles.Integer, germanCulture, 123, true);
- passed &= VerifyDecimalTryParse("123", NumberStyles.Integer, japaneseCulture, 123, true);
- passed &= VerifyDecimalTryParse("123.456", NumberStyles.Any, germanCulture, 123456, true);
- passed &= VerifyDecimalTryParse("123,456", NumberStyles.Any, japaneseCulture, 123456, true);
- passed &= VerifyDecimalTryParse("123,456", NumberStyles.AllowDecimalPoint, germanCulture, 123.456m, true);
- passed &= VerifyDecimalTryParse("123.456", NumberStyles.AllowDecimalPoint, japaneseCulture, 123.456m, true);
- passed &= VerifyDecimalTryParse("5,23 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Any, germanCulture, 5.23m, true); // currency
- passed &= VerifyDecimalTryParse("5.23 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Any, germanCulture, 523, true); // currency
- //
- //// Fail cases
- passed &= VerifyDecimalTryParse("-79228162514264337593543950336", NumberStyles.Integer, CultureInfo.InvariantCulture, 0, false);
- passed &= VerifyDecimalTryParse("-42", NumberStyles.Any, customNFI, 0, false);
- passed &= VerifyDecimalTryParse("5 ", NumberStyles.AllowLeadingWhite, goodNFI, 0, false);
- passed &= VerifyDecimalTryParse("1.234+E05", NumberStyles.AllowExponent, goodNFI, 0, false);
- passed &= VerifyDecimalTryParse("5.3", NumberStyles.None, goodNFI, 0, false);
-
- //// Exception cases
- passed &= VerifyDecimalTryParseException("12", NumberStyles.HexNumber, CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifyDecimalTryParseException("5", NumberStyles.AllowHexSpecifier | NumberStyles.AllowParentheses, null, typeof(ArgumentException));
- passed &= VerifyDecimalTryParseException("4", (NumberStyles)(-1), CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifyDecimalTryParseException("4", (NumberStyles)0x10000, CultureInfo.InvariantCulture, typeof(ArgumentException));
-
- // NumberStyles/NFI variations
- //
- passed &= VerifyDecimalTryParse("5", NumberStyles.Integer, corruptNFI, 5, true);
- passed &= VerifyDecimalTryParse("5", NumberStyles.Number, corruptNFI, 5, true);
- passed &= VerifyDecimalTryParse("5.3", NumberStyles.Number, corruptNFI, 5.3m, true);
- passed &= VerifyDecimalTryParse("5,3", NumberStyles.Number, corruptNFI, 0, false);
- passed &= VerifyDecimalTryParse("5.2.3", NumberStyles.Number, corruptNFI, 0, false);
- passed &= VerifyDecimalTryParse("$5.3", NumberStyles.Currency, corruptNFI, 5.3m, true);
- passed &= VerifyDecimalTryParse("$5,3", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyDecimalTryParse("$5.2.3", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyDecimalTryParse("5.3", NumberStyles.Currency, corruptNFI, 5.3m, true);
- passed &= VerifyDecimalTryParse("5,3", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyDecimalTryParse("5.2.3", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyDecimalTryParse("5.3", NumberStyles.Any, corruptNFI, 5.3m, true);
- passed &= VerifyDecimalTryParse("5,3", NumberStyles.Any, corruptNFI, 0, false);
- passed &= VerifyDecimalTryParse("5.2.3", NumberStyles.Any, corruptNFI, 0, false);
- //
- passed &= VerifyDecimalTryParse("5", NumberStyles.Integer, swappedNFI, 5, true);
- passed &= VerifyDecimalTryParse("1,234", NumberStyles.Integer, swappedNFI, 0, false);
- passed &= VerifyDecimalTryParse("5", NumberStyles.Number, swappedNFI, 5, true);
- passed &= VerifyDecimalTryParse("5.0", NumberStyles.Number, swappedNFI, 5, true);
- passed &= VerifyDecimalTryParse("1,234", NumberStyles.Number, swappedNFI, 1234, true);
- passed &= VerifyDecimalTryParse("1,234.0", NumberStyles.Number, swappedNFI, 1234, true);
- passed &= VerifyDecimalTryParse("5.000.000", NumberStyles.Number, swappedNFI, 0, false);
- passed &= VerifyDecimalTryParse("5.000,00", NumberStyles.Number, swappedNFI, 0, false);
- passed &= VerifyDecimalTryParse("5.000", NumberStyles.Currency, swappedNFI, 5, true); //???
- passed &= VerifyDecimalTryParse("5.000,00", NumberStyles.Currency, swappedNFI, 0, false); //???
- passed &= VerifyDecimalTryParse("$5.000", NumberStyles.Currency, swappedNFI, 5000, true);
- passed &= VerifyDecimalTryParse("$5.000,00", NumberStyles.Currency, swappedNFI, 5000, true);
- passed &= VerifyDecimalTryParse("5.000", NumberStyles.Any, swappedNFI, 5, true); //?
- passed &= VerifyDecimalTryParse("5.000,00", NumberStyles.Any, swappedNFI, 0, false); //?
- passed &= VerifyDecimalTryParse("$5.000", NumberStyles.Any, swappedNFI, 5000, true);
- passed &= VerifyDecimalTryParse("$5.000,00", NumberStyles.Any, swappedNFI, 5000, true);
- passed &= VerifyDecimalTryParse("5,0", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyDecimalTryParse("$5,0", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyDecimalTryParse("5,000", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyDecimalTryParse("$5,000", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyDecimalTryParse("5,000.0", NumberStyles.Currency, swappedNFI, 0, false);
- passed &= VerifyDecimalTryParse("$5,000.0", NumberStyles.Currency, swappedNFI, 0, false);
- passed &= VerifyDecimalTryParse("5,000", NumberStyles.Any, swappedNFI, 5, true);
- passed &= VerifyDecimalTryParse("$5,000", NumberStyles.Any, swappedNFI, 5, true);
- passed &= VerifyDecimalTryParse("5,000.0", NumberStyles.Any, swappedNFI, 0, false);
- passed &= VerifyDecimalTryParse("$5,000.0", NumberStyles.Any, swappedNFI, 0, false);
- //
- passed &= VerifyDecimalTryParse("5.0", NumberStyles.Number, distinctNFI, 5, true);
- passed &= VerifyDecimalTryParse("1,234.0", NumberStyles.Number, distinctNFI, 1234, true);
- passed &= VerifyDecimalTryParse("5.0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyDecimalTryParse("1,234.0", NumberStyles.Currency, distinctNFI, 1234, true);
- passed &= VerifyDecimalTryParse("5.0", NumberStyles.Any, distinctNFI, 5, true);
- passed &= VerifyDecimalTryParse("1,234.0", NumberStyles.Any, distinctNFI, 1234, true);
- passed &= VerifyDecimalTryParse("$5.0", NumberStyles.Currency, distinctNFI, 0, false);
- passed &= VerifyDecimalTryParse("$5.0", NumberStyles.Any, distinctNFI, 0, false);
- passed &= VerifyDecimalTryParse("5:0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyDecimalTryParse("5;0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyDecimalTryParse("$5:0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyDecimalTryParse("5:0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyDecimalTryParse("5:000", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyDecimalTryParse("5;000", NumberStyles.Currency, distinctNFI, 5000, true);
- passed &= VerifyDecimalTryParse("$5:0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyDecimalTryParse("$5;0", NumberStyles.Currency, distinctNFI, 50, true);
- passed &= VerifyDecimalTryParse("5:0", NumberStyles.Any, distinctNFI, 5, true);
- passed &= VerifyDecimalTryParse("5;0", NumberStyles.Any, distinctNFI, 50, true);
- passed &= VerifyDecimalTryParse("$5:0", NumberStyles.Any, distinctNFI, 5, true);
- passed &= VerifyDecimalTryParse("$5;0", NumberStyles.Any, distinctNFI, 50, true);
- passed &= VerifyDecimalTryParse("123,456;789.0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyDecimalTryParse("123,456;789.0", NumberStyles.Currency, distinctNFI, 123456789, true);
- passed &= VerifyDecimalTryParse("123,456;789.0", NumberStyles.Any, distinctNFI, 123456789, true);
- passed &= VerifyDecimalTryParse("$123,456;789.0", NumberStyles.Any, distinctNFI, 0, false);
-
-
- // Underflow cases - see VSWhidbey #576556
- passed &= VerifyExactDecimalTryParse("0E-27", NumberStyles.AllowExponent, invariantCulture, zeroScale27, true);
- passed &= VerifyExactDecimalTryParse("0E-28", NumberStyles.AllowExponent, invariantCulture, zeroScale28, true);
- passed &= VerifyExactDecimalTryParse("0E-29", NumberStyles.AllowExponent, invariantCulture, zeroScale28, true);
- passed &= VerifyExactDecimalTryParse("0E-30", NumberStyles.AllowExponent, invariantCulture, zeroScale28, true);
- passed &= VerifyExactDecimalTryParse("0E-31", NumberStyles.AllowExponent, invariantCulture, zeroScale28, true);
- passed &= VerifyExactDecimalTryParse("0E-50", NumberStyles.AllowExponent, invariantCulture, zeroScale28, true);
- passed &= VerifyExactDecimalTryParse("0E-100", NumberStyles.AllowExponent, invariantCulture, zeroScale28, true);
- passed &= VerifyExactDecimalTryParse("0.000000000000000000000000000", zeroScale27, true);
- passed &= VerifyExactDecimalTryParse("0.0000000000000000000000000000", zeroScale28, true); //28
- passed &= VerifyExactDecimalTryParse("0.00000000000000000000000000000", zeroScale28, true); //29
- passed &= VerifyExactDecimalTryParse("0.000000000000000000000000000000", zeroScale28, true); //30
- passed &= VerifyExactDecimalTryParse("0.0000000000000000000000000000000", zeroScale28, true); //31
- passed &= VerifyExactDecimalTryParse("0.0", new Decimal(0, 0, 0, false, 1), true);
- passed &= VerifyExactDecimalTryParse("0E-15", NumberStyles.AllowExponent, invariantCulture, new Decimal(0, 0, 0, false, 15), true);
- passed &= VerifyExactDecimalTryParse("0", Decimal.Zero, true);
-
- passed &= VerifyExactDecimalTryParse("1E-27", NumberStyles.AllowExponent, invariantCulture, oneScale27, true);
- passed &= VerifyExactDecimalTryParse("1E-28", NumberStyles.AllowExponent, invariantCulture, oneScale28, true);
- passed &= VerifyExactDecimalTryParse("1E-29", NumberStyles.AllowExponent, invariantCulture, zeroScale28, true);
- passed &= VerifyExactDecimalTryParse("1E-30", NumberStyles.AllowExponent, invariantCulture, zeroScale28, true);
- passed &= VerifyExactDecimalTryParse("1E-31", NumberStyles.AllowExponent, invariantCulture, zeroScale28, true);
- passed &= VerifyExactDecimalTryParse("1E-50", NumberStyles.AllowExponent, invariantCulture, zeroScale28, true);
- passed &= VerifyExactDecimalTryParse("1E-100", NumberStyles.AllowExponent, invariantCulture, zeroScale28, true);
-
- // make sure parse lines up with compiler
- //passed &= VerifyExactDecimalTryParse("0E-50", NumberStyles.AllowExponent, invariantCulture, 0E-50m, true); // V2->V4 compiler change
- passed &= VerifyExactDecimalTryParse("1E-50", NumberStyles.AllowExponent, invariantCulture, 1E-50m, true);
- passed &= VerifyExactDecimalTryParse("2E-100", NumberStyles.AllowExponent, invariantCulture, 2E-100m, true);
- passed &= VerifyExactDecimalTryParse("100E-29", NumberStyles.AllowExponent, invariantCulture, 100E-29m, true);
- passed &= VerifyExactDecimalTryParse("200E-29", NumberStyles.AllowExponent, invariantCulture, 200E-29m, true);
- passed &= VerifyExactDecimalTryParse("500E-29", NumberStyles.AllowExponent, invariantCulture, 500E-29m, true);
- passed &= VerifyExactDecimalTryParse("900E-29", NumberStyles.AllowExponent, invariantCulture, 900E-29m, true);
- passed &= VerifyExactDecimalTryParse("1900E-29", NumberStyles.AllowExponent, invariantCulture, 1900E-29m, true);
- passed &= VerifyExactDecimalTryParse("10900E-29", NumberStyles.AllowExponent, invariantCulture, 10900E-29m, true);
- passed &= VerifyExactDecimalTryParse("10900E-30", NumberStyles.AllowExponent, invariantCulture, 10900E-30m, true);
- passed &= VerifyExactDecimalTryParse("10900E-31", NumberStyles.AllowExponent, invariantCulture, 10900E-31m, true);
- passed &= VerifyExactDecimalTryParse("10900E-32", NumberStyles.AllowExponent, invariantCulture, 10900E-32m, true);
- passed &= VerifyExactDecimalTryParse("10900E-33", NumberStyles.AllowExponent, invariantCulture, 10900E-33m, true);
- passed &= VerifyExactDecimalTryParse("10900E-34", NumberStyles.AllowExponent, invariantCulture, 10900E-34m, true);
- passed &= VerifyExactDecimalTryParse("10900E-340", NumberStyles.AllowExponent, invariantCulture, 10900E-340m, true);
- passed &= VerifyExactDecimalTryParse("10900E-512", NumberStyles.AllowExponent, invariantCulture, 10900E-512m, true);
- passed &= VerifyExactDecimalTryParse("10900E-678", NumberStyles.AllowExponent, invariantCulture, 10900E-678m, true);
- passed &= VerifyExactDecimalTryParse("10900E-999", NumberStyles.AllowExponent, invariantCulture, 10900E-999m, true);
-
-
- // Should these pass or fail? Current parse behavior is to pass, so they might be
- // parse bugs, but they're not tryparse bugs.
- passed &= VerifyDecimalParse("5", NumberStyles.AllowExponent, goodNFI, 5);
- passed &= VerifyDecimalTryParse("5", NumberStyles.AllowExponent, goodNFI, 5, true);
- // I expect ArgumentException with an ambiguous NFI
- passed &= VerifyDecimalParse("^42", NumberStyles.Any, ambigNFI, -42);
- passed &= VerifyDecimalTryParse("^42", NumberStyles.Any, ambigNFI, -42, true);
-
- /// END TEST CASES
- }
- catch (Exception e)
- {
- TestLibrary.Logging.WriteLine("Unexpected exception!! " + e.ToString());
- passed = false;
- }
-
- if (passed)
- {
- TestLibrary.Logging.WriteLine("paSs");
- return 100;
- }
- else
- {
- TestLibrary.Logging.WriteLine("FAiL");
- return 1;
- }
- }
-
- public static bool VerifyDecimalTryParse(string value, Decimal expectedResult, bool expectedReturn)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Decimal.TryParse, Value = '{0}', Expected Result = {1}, Expected Return = {2}",
- value, expectedResult, expectedReturn);
- }
- Decimal result = 0;
- try
- {
- bool returnValue = Decimal.TryParse(value, out result);
- if (returnValue != expectedReturn)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedReturn, returnValue);
- return false;
- }
- if (result != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, result);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyDecimalTryParse(string value, NumberStyles style, IFormatProvider provider, Decimal expectedResult, bool expectedReturn)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Decimal.TryParse, Value = '{0}', Style = {1}, Provider = {2}, Expected Result = {3}, Expected Return = {4}",
- value, style, provider, expectedResult, expectedReturn);
- }
- Decimal result = 0;
- try
- {
- bool returnValue = Decimal.TryParse(value, style, provider, out result);
- if (returnValue != expectedReturn)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Style = {1}, Provider = {2}, Expected Return = {3}, Actual Return = {4}",
- value, style, provider, expectedReturn, returnValue);
- return false;
- }
- if (result != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, result);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyDecimalTryParseException(string value, NumberStyles style, IFormatProvider provider, Type exceptionType)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Decimal.TryParse, Value = '{0}', Style = {1}, Provider = {2}, Expected Exception = {3}",
- value, style, provider, exceptionType);
- }
- try
- {
- Decimal result = 0;
- Boolean returnValue = Decimal.TryParse(value, style, provider, out result);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifyDecimalParse(string value, Decimal expectedResult)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Decimal.Parse, Value = '{0}', Expected Result, {1}",
- value, expectedResult);
- }
- try
- {
- Decimal returnValue = Decimal.Parse(value);
- if (returnValue != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, returnValue);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyDecimalParse(string value, NumberStyles style, IFormatProvider provider, Decimal expectedResult)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Decimal.Parse, Value = '{0}', Style = {1}, provider = {2}, Expected Result = {3}",
- value, style, provider, expectedResult);
- }
- try
- {
- Decimal returnValue = Decimal.Parse(value, style, provider);
- if (returnValue != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, returnValue);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static String HexValue(Decimal value)
- {
- Int32[] bits = Decimal.GetBits(value);
- return String.Format("{{0x{0:X8} {1:X8} {2:X8} {3:X8} }}", bits[0], bits[1], bits[2], bits[3]);
- }
-
- // Verify that decimals have the same bits, not just the same values.
- public static Boolean CompareExact(Decimal x, Decimal y)
- {
- Int32[] arrayX = Decimal.GetBits(x);
- Int32[] arrayY = Decimal.GetBits(y);
- for (int i = 0; i < 4; i++)
- {
- if (arrayX[i] != arrayY[i])
- {
- return false;
- }
- }
- return true;
- }
-
- public static bool VerifyExactDecimalParse(string value, Decimal expectedResult)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Decimal.Parse, Value = '{0}', Expected Result = {1}",
- value, expectedResult);
- }
- try
- {
- Decimal returnValue = Decimal.Parse(value);
- if (!CompareExact(returnValue, expectedResult))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, HexValue(expectedResult), HexValue(returnValue));
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyExactDecimalParse(string value, NumberStyles style, Decimal expectedResult)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Decimal.Parse, Value = '{0}', Style = {1}, Expected Result = {2}",
- value, style, expectedResult);
- }
- try
- {
- Decimal returnValue = Decimal.Parse(value, style);
- if (!CompareExact(returnValue, expectedResult))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, HexValue(expectedResult), HexValue(returnValue));
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyExactDecimalParse(string value, NumberStyles style, IFormatProvider provider, Decimal expectedResult)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Decimal.Parse, Value = '{0}', Style = {1}, provider = {2}, Expected Result = {3}",
- value, style, provider, expectedResult);
- }
- try
- {
- Decimal returnValue = Decimal.Parse(value, style, provider);
- if (!CompareExact(returnValue, expectedResult))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, HexValue(expectedResult), HexValue(returnValue));
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyExactDecimalTryParse(string value, Decimal expectedResult, bool expectedReturn)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Decimal.TryParse, Value = '{0}', Expected Result = {1}, Expected Return = {2}",
- value, expectedResult, expectedReturn);
- }
- Decimal result = 0;
- try
- {
- bool returnValue = Decimal.TryParse(value, out result);
- if (returnValue != expectedReturn)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedReturn, returnValue);
- return false;
- }
- if (!CompareExact(result, expectedResult))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, HexValue(expectedResult), HexValue(result));
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyExactDecimalTryParse(string value, NumberStyles style, IFormatProvider provider, Decimal expectedResult, bool expectedReturn)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Decimal.TryParse, Value = '{0}', Style = {1}, Provider = {2}, Expected Result = {3}, Expected Return = {4}",
- value, style, provider, expectedResult, expectedReturn);
- }
- Decimal result = 0;
- try
- {
- bool returnValue = Decimal.TryParse(value, style, provider, out result);
- if (returnValue != expectedReturn)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Style = {1}, Provider = {2}, Expected Return = {3}, Actual Return = {4}",
- value, style, provider, expectedReturn, returnValue);
- return false;
- }
- if (!CompareExact(result, expectedResult))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, HexValue(expectedResult), HexValue(result));
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyDecimalParseException(string value, Type exceptionType)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Decimal.Parse, Value = '{0}', Expected Exception, {1}",
- value, exceptionType);
- }
- try
- {
- Decimal returnValue = Decimal.Parse(value);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifyDecimalParseException(string value, NumberStyles style, Type exceptionType)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Decimal.Parse, Value = '{0}', Style = {1}, Expected Exception = {3}",
- value, style, exceptionType);
- }
- try
- {
- Decimal returnValue = Decimal.Parse(value, style);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifyDecimalParseException(string value, NumberStyles style, IFormatProvider provider, Type exceptionType)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Decimal.Parse, Value = '{0}', Style = {1}, Provider = {2}, Expected Exception = {3}",
- value, style, provider, exceptionType);
- }
- try
- {
- Decimal returnValue = Decimal.Parse(value, style, provider);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-}
diff --git a/tests/src/CoreMangLib/cti/system/double/DoubleParse3.csproj b/tests/src/CoreMangLib/cti/system/double/DoubleParse3.csproj
deleted file mode 100644
index bbbdbd1bcb..0000000000
--- a/tests/src/CoreMangLib/cti/system/double/DoubleParse3.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="doubleparse3.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/double/DoubleTryParse.csproj b/tests/src/CoreMangLib/cti/system/double/DoubleTryParse.csproj
deleted file mode 100644
index 25fc91d436..0000000000
--- a/tests/src/CoreMangLib/cti/system/double/DoubleTryParse.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="doubletryparse.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/double/doubleparse3.cs b/tests/src/CoreMangLib/cti/system/double/doubleparse3.cs
deleted file mode 100644
index 97eecb82d2..0000000000
--- a/tests/src/CoreMangLib/cti/system/double/doubleparse3.cs
+++ /dev/null
@@ -1,612 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Threading;
-using System.Globalization;
-
-/// <summary>
-/// Parse(System.String,System.Globalization.NumberStyles,System.IFormatProvider)
-/// </summary>
-
-public class DoubleParse3
-{
- private static NumberFormatInfo nfi;
- private static string currencySymbol;
-
- public static void InitializeIFormatProvider()
- {
- nfi = new CultureInfo("en-US").NumberFormat;
- currencySymbol = nfi.CurrencySymbol;
- }
-
- public static int Main()
- {
- InitializeIFormatProvider();
-
- DoubleParse3 test = new DoubleParse3();
-
- TestLibrary.TestFramework.BeginTestCase("DoubleParse3");
-
- if (test.RunTests())
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("PASS");
- return 100;
- }
- else
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("FAIL");
- return 0;
- }
- }
-
- public bool RunTests()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.LogInformation("[Positive]");
- retVal = PosTest1() && retVal;
- retVal = PosTest2() && retVal;
- retVal = PosTest3() && retVal;
- retVal = PosTest4() && retVal;
- retVal = PosTest5() && retVal;
- retVal = PosTest6() && retVal;
- retVal = PosTest7() && retVal;
- retVal = PosTest8() && retVal;
- retVal = PosTest9() && retVal;
- retVal = PosTest10() && retVal;
- retVal = PosTest11() && retVal;
- retVal = PosTest12() && retVal;
- retVal = PosTest13() && retVal;
- retVal = PosTest14() && retVal;
- retVal = PosTest15() && retVal;
- retVal = PosTest16() && retVal;
-
- TestLibrary.TestFramework.LogInformation("[Negative]");
- retVal = NegTest1() && retVal;
- retVal = NegTest2() && retVal;
- retVal = NegTest3() && retVal;
- retVal = NegTest4() && retVal;
- retVal = NegTest5() && retVal;
- retVal = NegTest6() && retVal;
-
- return retVal;
- }
-
- public bool PosTest1()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest1: Ensure the result is correct when NumberStyles is set to AllowCurrencySymbol.");
-
- try
- {
- Double d = Double.Parse("123" + currencySymbol, NumberStyles.AllowCurrencySymbol, nfi);
- if (d.CompareTo(123.0) != 0)
- {
- TestLibrary.TestFramework.LogError("P01.1", "The result is not correct when NumberStyles is set to AllowCurrencySymbol!");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("P01.2", "Unexpected exception: " + e);
- TestLibrary.TestFramework.LogInformation(e.StackTrace);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest2()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest2: Ensure the result is correct when NumberStyles is set to AllowDecimalPoint.");
-
- try
- {
- Double d = Double.Parse("123.1", NumberStyles.AllowDecimalPoint, nfi);
- if (d.CompareTo(123.1) != 0)
- {
- TestLibrary.TestFramework.LogError("P02.1", "The result is not correct when NumberStyles is set to AllowDecimalPoint!");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("P02.2", "Unexpected exception: " + e);
- TestLibrary.TestFramework.LogInformation(e.StackTrace);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest3()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest3: Ensure the result is correct when NumberStyles is set to AllowExponent.");
-
- try
- {
- Double d = Double.Parse("123E2", NumberStyles.AllowExponent, nfi);
- if (d.CompareTo(12300.0) != 0)
- {
- TestLibrary.TestFramework.LogError("P03.1", "The result is not correct when NumberStyles is set to AllowExponent!");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("P03.2", "Unexpected exception: " + e);
- TestLibrary.TestFramework.LogInformation(e.StackTrace);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest4()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest4: Ensure the result is correct when NumberStyles is set to AllowLeadingSign.");
-
- try
- {
- Double d = Double.Parse("-12345", NumberStyles.AllowLeadingSign, nfi);
- if (d.CompareTo(-12345.0) != 0)
- {
- TestLibrary.TestFramework.LogError("P04.1", "The result is not correct when NumberStyles is set to AllowLeadingSign!");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("P04.2", "Unexpected exception: " + e);
- TestLibrary.TestFramework.LogInformation(e.StackTrace);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest5()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest5: Ensure the result is correct when NumberStyles is set to AllowLeadingWhite.");
-
- try
- {
- Double d = Double.Parse(" 1234", NumberStyles.AllowLeadingWhite, nfi);
- if (d.CompareTo(1234.0) != 0)
- {
- TestLibrary.TestFramework.LogError("P05.1", "The result is not correct when NumberStyles is set to AllowLeadingWhite!");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("P05.2", "Unexpected exception: " + e);
- TestLibrary.TestFramework.LogInformation(e.StackTrace);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest6()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest6: Ensure the result is correct when NumberStyles is set to AllowParentheses.");
-
- try
- {
- Double d = Double.Parse("(456)", NumberStyles.AllowParentheses, nfi);
- if (d.CompareTo(-456.0) != 0)
- {
- TestLibrary.TestFramework.LogError("P06.1", "The result is not correct when NumberStyles is set to AllowParentheses!");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("P06.2", "Unexpected exception: " + e);
- TestLibrary.TestFramework.LogInformation(e.StackTrace);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest7()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest7: Ensure the result is correct when NumberStyles is set to AllowThousands.");
-
- try
- {
- Double d = Double.Parse("123,456", NumberStyles.AllowThousands, nfi);
- if (d.CompareTo(123456.0) != 0)
- {
- TestLibrary.TestFramework.LogError("P07.1", "The result is not correct when NumberStyles is set to AllowThousands!");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("P07.2", "Unexpected exception: " + e);
- TestLibrary.TestFramework.LogInformation(e.StackTrace);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest8()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest8: Ensure the result is correct when NumberStyles is set to AllowTrailingSign.");
-
- try
- {
- Double d = Double.Parse("123-", NumberStyles.AllowTrailingSign, nfi);
- if (d.CompareTo(-123.0) != 0)
- {
- TestLibrary.TestFramework.LogError("P08.1", "The result is not correct when NumberStyles is set to AllowTrailingSign!");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("P08.2", "Unexpected exception: " + e);
- TestLibrary.TestFramework.LogInformation(e.StackTrace);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest9()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest9: Ensure the result is correct when NumberStyles is set to AllowTrailingWhite.");
-
- try
- {
- Double d = Double.Parse("123 ", NumberStyles.AllowTrailingWhite, nfi);
- if (d.CompareTo(123.0) != 0)
- {
- TestLibrary.TestFramework.LogError("P09.1", "The result is not correct when NumberStyles is set to AllowTrailingWhite!");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("P09.2", "Unexpected exception: " + e);
- TestLibrary.TestFramework.LogInformation(e.StackTrace);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest10()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest10: Ensure the result is correct when NumberStyles is set to Any.");
-
- try
- {
- Double d = Double.Parse("-123E2 " + currencySymbol, NumberStyles.Any, nfi);
- if (d.CompareTo(-12300.0) != 0)
- {
- TestLibrary.TestFramework.LogError("P10.1", "The result is not correct when NumberStyles is set to Any!");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("P10.2", "Unexpected exception: " + e);
- TestLibrary.TestFramework.LogInformation(e.StackTrace);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest11()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest11: Ensure the result is correct when NumberStyles is set to Currency.");
-
- try
- {
- Double d = Double.Parse("-123 " + currencySymbol, NumberStyles.Currency, nfi);
- if (d.CompareTo(-123.0) != 0)
- {
- TestLibrary.TestFramework.LogError("P11.1", "The result is not correct when NumberStyles is set to Currency!");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("P11.2", "Unexpected exception: " + e);
- TestLibrary.TestFramework.LogInformation(e.StackTrace);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest12()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest12: Ensure the result is correct when NumberStyles is set to Float.");
-
- try
- {
- Double d = Double.Parse(" -123.4 ", NumberStyles.Float, nfi);
- if (d.CompareTo(-123.4) != 0)
- {
- TestLibrary.TestFramework.LogError("P12.1", "The result is not correct when NumberStyles is set to Float!");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("P12.2", "Unexpected exception: " + e);
- TestLibrary.TestFramework.LogInformation(e.StackTrace);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest13()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest13: Ensure the result is correct when NumberStyles is set to Integer.");
-
- try
- {
- Double d = Double.Parse(" -123 ", NumberStyles.Integer, nfi);
- if (d.CompareTo(-123.0) != 0)
- {
- TestLibrary.TestFramework.LogError("P13.1", "The result is not correct when NumberStyles is set to Integer!");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("P13.2", "Unexpected exception: " + e);
- TestLibrary.TestFramework.LogInformation(e.StackTrace);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest14()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest14: Ensure the result is correct when NumberStyles is set to None.");
-
- try
- {
- Double d = Double.Parse("123", NumberStyles.None, nfi);
- if (d.CompareTo(123.0) != 0)
- {
- TestLibrary.TestFramework.LogError("P14.1", "The result is not correct when NumberStyles is set to None!");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("P14.2", "Unexpected exception: " + e);
- TestLibrary.TestFramework.LogInformation(e.StackTrace);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest15()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest15: Ensure the result is correct when NumberStyles is set to Number.");
-
- try
- {
- Double d = Double.Parse(" 4,123.1- ", NumberStyles.Number, nfi);
- if (d.CompareTo(-4123.1) != 0)
- {
- TestLibrary.TestFramework.LogError("P15.1", "The result is not correct when NumberStyles is set to Number!");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("P15.2", "Unexpected exception: " + e);
- TestLibrary.TestFramework.LogInformation(e.StackTrace);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest16()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest16: Ensure the result is correct when NumberStyles is set to None but System.String has currency symbol.");
-
- try
- {
- Double d = Double.Parse("123$", NumberStyles.None, nfi);
- TestLibrary.TestFramework.LogError("P16.1", "The result is not correct when NumberStyles is set to None but System.String has currency symbol!");
- retVal = false;
- }
- catch (FormatException)
- {
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("P16.2", "Unexpected exception: " + e);
- TestLibrary.TestFramework.LogInformation(e.StackTrace);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest1()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("NegTest1: ArgumentNullException should be thrown when System.String is a null reference.");
-
- try
- {
- Double d = Double.Parse(null, NumberStyles.Any, nfi);
- TestLibrary.TestFramework.LogError("N01.1", "ArgumentNullException is not thrown when System.String is a null reference!");
- retVal = false;
- }
- catch (ArgumentNullException)
- {
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N01.2", "Unexpected exception: " + e);
- TestLibrary.TestFramework.LogInformation(e.StackTrace);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest2()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("NegTest2: FormatException should be thrown when System.String is not a number in a valid format.");
-
- try
- {
- Double d = Double.Parse("123,456.5.66", NumberStyles.None, nfi);
- TestLibrary.TestFramework.LogError("N02.1", "FormatException is not thrown when System.String is not a number in a valid format!");
- retVal = false;
- }
- catch (FormatException)
- {
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N02.2", "Unexpected exception: " + e);
- TestLibrary.TestFramework.LogInformation(e.StackTrace);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest3()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("NegTest3: OverflowException should be thrown when System.String represents a number greater than MaxValue.");
-
- try
- {
- Double d = Double.Parse("1.79769313486233e308", NumberStyles.Float, nfi);
- TestLibrary.TestFramework.LogError("N03.1", "OverflowException is not thrown when System.String represents a number greater than MaxValue!");
- retVal = false;
- }
- catch (OverflowException)
- {
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N03.2", "Unexpected exception: " + e);
- TestLibrary.TestFramework.LogInformation(e.StackTrace);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest4()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("NegTest4: ArgumentException should be thrown when NumberStyles contains AllowHexSpecifier value.");
-
- try
- {
- Double d = Double.Parse("108", NumberStyles.HexNumber, nfi);
- TestLibrary.TestFramework.LogError("N04.1", "ArgumentException is not thrown when NumberStyles contains AllowHexSpecifier value!");
- retVal = false;
- }
- catch (ArgumentException)
- {
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N04.2", "Unexpected exception: " + e);
- TestLibrary.TestFramework.LogInformation(e.StackTrace);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest5()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("NegTest5: ArgumentException should be thrown when NumberStyles is the AllowHexSpecifier value.");
-
- try
- {
- Double d = Double.Parse("108", NumberStyles.AllowHexSpecifier, nfi);
- TestLibrary.TestFramework.LogError("N05.1", "ArgumentException is not thrown when NumberStyles is the AllowHexSpecifier value!");
- retVal = false;
- }
- catch (ArgumentException)
- {
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N05.2", "Unexpected exception: " + e);
- TestLibrary.TestFramework.LogInformation(e.StackTrace);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest6()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("NegTest6: ArgumentException should be thrown when NumberStyles is not a NumberStyles value.");
-
- try
- {
- Double d = Double.Parse("123", (NumberStyles)5000, nfi);
- TestLibrary.TestFramework.LogError("N06.1", "ArgumentException is not thrown when NumberStyles is not a NumberStyles value!");
- retVal = false;
- }
- catch (ArgumentException)
- {
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N06.2", "Unexpected exception: " + e);
- TestLibrary.TestFramework.LogInformation(e.StackTrace);
- retVal = false;
- }
-
- return retVal;
- }
-}
diff --git a/tests/src/CoreMangLib/cti/system/double/doubletryparse.cs b/tests/src/CoreMangLib/cti/system/double/doubletryparse.cs
deleted file mode 100644
index 514e57ae2e..0000000000
--- a/tests/src/CoreMangLib/cti/system/double/doubletryparse.cs
+++ /dev/null
@@ -1,606 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Globalization;
-
-// Ported to CoreCLR from Co7532TryParse_all.cs
-// Tests Double.TryParse(String), Double.TryParse(String, NumberStyles, IFormatProvider, ref Double)
-// 2003/04/01 KatyK
-// 2007/06/28 adapted by MarielY
-public class DoubleTryParse
-{
- static bool verbose = false;
-
- public static int Main()
- {
- bool passed = true;
-
- try
- {
- // Make the test culture independent
- TestLibrary.Utilities.CurrentCulture = CultureInfo.InvariantCulture;
-
- // Set up NFIs to use
- NumberFormatInfo goodNFI = new NumberFormatInfo();
-
- NumberFormatInfo corruptNFI = new NumberFormatInfo(); // DecimalSeparator == GroupSeparator
- corruptNFI.NumberDecimalSeparator = ".";
- corruptNFI.NumberGroupSeparator = ".";
- corruptNFI.CurrencyDecimalSeparator = ".";
- corruptNFI.CurrencyGroupSeparator = ".";
- corruptNFI.CurrencySymbol = "$";
-
- NumberFormatInfo swappedNFI = new NumberFormatInfo(); // DecimalSeparator & GroupSeparator swapped
- swappedNFI.NumberDecimalSeparator = ".";
- swappedNFI.NumberGroupSeparator = ",";
- swappedNFI.CurrencyDecimalSeparator = ",";
- swappedNFI.CurrencyGroupSeparator = ".";
- swappedNFI.CurrencySymbol = "$";
-
- NumberFormatInfo distinctNFI = new NumberFormatInfo(); // DecimalSeparator & GroupSeparator distinct
- distinctNFI.NumberDecimalSeparator = ".";
- distinctNFI.NumberGroupSeparator = ",";
- distinctNFI.CurrencyDecimalSeparator = ":";
- distinctNFI.CurrencyGroupSeparator = ";";
- distinctNFI.CurrencySymbol = "$";
-
- NumberFormatInfo customNFI = new NumberFormatInfo();
- customNFI.NegativeSign = "^";
-
- NumberFormatInfo ambigNFI = new NumberFormatInfo();
- ambigNFI.NegativeSign = "^";
- ambigNFI.CurrencySymbol = "^";
-
- CultureInfo germanCulture = new CultureInfo("de-DE");
- CultureInfo japaneseCulture;
- try
- {
- japaneseCulture = new CultureInfo("ja-JP");
- }
- catch (Exception)
- {
- TestLibrary.TestFramework.LogInformation("East Asian Languages are not installed. Skipping Japanese culture test(s).");
- japaneseCulture = null;
- }
-
- // Parse tests included for comparison/regression
- passed &= VerifyDoubleParse("0", 0);
- passed &= VerifyDoubleParse("5", 5);
- passed &= VerifyDoubleParse("5 ", 5);
- passed &= VerifyDoubleParse("5\0", 5);
- passed &= VerifyDoubleParse("-5", -5);
- passed &= VerifyDoubleParse("893382737", 893382737);
- passed &= VerifyDoubleParse("-893382737", -893382737);
- passed &= VerifyDoubleParse("1234567891", 1234567891);
- passed &= VerifyDoubleParse("-1234567891", -1234567891);
- passed &= VerifyDoubleParse("123456789123456789", 123456789123456789);
- passed &= VerifyDoubleParse("-123456789123456789", -123456789123456789);
- passed &= VerifyDoubleParse("5", NumberStyles.Integer, CultureInfo.InvariantCulture, 5);
- passed &= VerifyDoubleParse("5 \0", NumberStyles.Integer, CultureInfo.InvariantCulture, 5);
- passed &= VerifyDoubleParse("5\0\0\0", NumberStyles.Integer, CultureInfo.InvariantCulture, 5);
- passed &= VerifyDoubleParse("-5", NumberStyles.Integer, CultureInfo.InvariantCulture, -5);
- passed &= VerifyDoubleParse("5", NumberStyles.Integer, goodNFI, 5);
- passed &= VerifyDoubleParse("5.0", NumberStyles.AllowDecimalPoint, goodNFI, 5);
- passed &= VerifyDoubleParse("5.3", NumberStyles.AllowDecimalPoint, goodNFI, 5.3);
- passed &= VerifyDoubleParse("123456789123456789123", 123456789123456789123.0);
- passed &= VerifyDoubleParse("-123456789123456789123", -123456789123456789123.0);
- passed &= VerifyDoubleParse("18446744073709551615", 18446744073709551615);
- passed &= VerifyDoubleParse("79228162514264337593543950335", 79228162514264337593543950335.0);
- passed &= VerifyDoubleParse("-79228162514264337593543950335", -79228162514264337593543950335.0);
- passed &= VerifyDoubleParse("5.555555555", 5.555555555);
- passed &= VerifyDoubleParse("1.000000", 1.0);
- passed &= VerifyDoubleParse("79228162514264337593543950336", 79228162514264337593543950336.0);
- passed &= VerifyDoubleParse("-79228162514264337593543950336", -79228162514264337593543950336.0);
- passed &= VerifyDoubleParse("1.79769313486231E+308", NumberStyles.Float | NumberStyles.AllowExponent, null, 1.79769313486231E+308);
- passed &= VerifyDoubleParse("-1.79769313486231E+308", NumberStyles.Float | NumberStyles.AllowExponent, null, -1.79769313486231E+308);
- passed &= VerifyDoubleParse("NaN", NumberStyles.Float, NumberFormatInfo.InvariantInfo, Double.NaN);
- passed &= VerifyDoubleParse("Infinity", NumberStyles.Float, NumberFormatInfo.InvariantInfo, Double.PositiveInfinity);
- passed &= VerifyDoubleParse("-Infinity", NumberStyles.Float, NumberFormatInfo.InvariantInfo, Double.NegativeInfinity);
- passed &= VerifyDoubleParse("123", NumberStyles.Integer, germanCulture, 123);
- passed &= VerifyDoubleParse("123", NumberStyles.Integer, japaneseCulture, 123);
- passed &= VerifyDoubleParse("123.456", NumberStyles.Any, germanCulture, 123456);
- passed &= VerifyDoubleParse("123,456", NumberStyles.Any, japaneseCulture, 123456);
- passed &= VerifyDoubleParse("123,456", NumberStyles.AllowDecimalPoint, germanCulture, 123.456);
- passed &= VerifyDoubleParse("123.456", NumberStyles.AllowDecimalPoint, japaneseCulture, 123.456);
- passed &= VerifyDoubleParse("5,23 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Any, germanCulture, 5.23); // currency
- passed &= VerifyDoubleParse("5.23 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Any, germanCulture, 523); // currency
- //
- passed &= VerifyDoubleParse("5", NumberStyles.Integer, corruptNFI, 5);
- passed &= VerifyDoubleParse("5", NumberStyles.Number, corruptNFI, 5);
- passed &= VerifyDoubleParse("5.3", NumberStyles.Number, corruptNFI, 5.3);
- passed &= VerifyDoubleParseException("5,3", NumberStyles.Number, corruptNFI, typeof(FormatException));
- passed &= VerifyDoubleParseException("5.2.3", NumberStyles.Number, corruptNFI, typeof(FormatException));
- passed &= VerifyDoubleParse("$5.3", NumberStyles.Currency, corruptNFI, 5.3);
- passed &= VerifyDoubleParseException("$5,3", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyDoubleParseException("$5.2.3", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyDoubleParse("5.3", NumberStyles.Currency, corruptNFI, 5.3);
- passed &= VerifyDoubleParseException("5,3", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyDoubleParseException("5.2.3", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyDoubleParse("5.3", NumberStyles.Any, corruptNFI, 5.3);
- passed &= VerifyDoubleParseException("5,3", NumberStyles.Any, corruptNFI, typeof(FormatException));
- passed &= VerifyDoubleParseException("5.2.3", NumberStyles.Any, corruptNFI, typeof(FormatException));
- //
- passed &= VerifyDoubleParse("5", NumberStyles.Integer, swappedNFI, 5);
- passed &= VerifyDoubleParseException("1,234", NumberStyles.Integer, swappedNFI, typeof(FormatException));
- passed &= VerifyDoubleParse("5", NumberStyles.Number, swappedNFI, 5);
- passed &= VerifyDoubleParse("5.0", NumberStyles.Number, swappedNFI, 5);
- passed &= VerifyDoubleParse("1,234", NumberStyles.Number, swappedNFI, 1234);
- passed &= VerifyDoubleParse("1,234.0", NumberStyles.Number, swappedNFI, 1234);
- passed &= VerifyDoubleParseException("5.000.000", NumberStyles.Number, swappedNFI, typeof(FormatException));
- passed &= VerifyDoubleParseException("5.000,00", NumberStyles.Number, swappedNFI, typeof(FormatException));
- passed &= VerifyDoubleParse("5.000", NumberStyles.Currency, swappedNFI, 5); //???
- passed &= VerifyDoubleParseException("5.000,00", NumberStyles.Currency, swappedNFI, typeof(FormatException)); //???
- passed &= VerifyDoubleParse("$5.000", NumberStyles.Currency, swappedNFI, 5000);
- passed &= VerifyDoubleParse("$5.000,00", NumberStyles.Currency, swappedNFI, 5000);
- passed &= VerifyDoubleParse("5.000", NumberStyles.Any, swappedNFI, 5); //?
- passed &= VerifyDoubleParseException("5.000,00", NumberStyles.Any, swappedNFI, typeof(FormatException)); //?
- passed &= VerifyDoubleParse("$5.000", NumberStyles.Any, swappedNFI, 5000);
- passed &= VerifyDoubleParse("$5.000,00", NumberStyles.Any, swappedNFI, 5000);
- passed &= VerifyDoubleParse("5,0", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyDoubleParse("$5,0", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyDoubleParse("5,000", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyDoubleParse("$5,000", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyDoubleParseException("5,000.0", NumberStyles.Currency, swappedNFI, typeof(FormatException));
- passed &= VerifyDoubleParseException("$5,000.0", NumberStyles.Currency, swappedNFI, typeof(FormatException));
- passed &= VerifyDoubleParse("5,000", NumberStyles.Any, swappedNFI, 5);
- passed &= VerifyDoubleParse("$5,000", NumberStyles.Any, swappedNFI, 5);
- passed &= VerifyDoubleParseException("5,000.0", NumberStyles.Any, swappedNFI, typeof(FormatException));
- passed &= VerifyDoubleParseException("$5,000.0", NumberStyles.Any, swappedNFI, typeof(FormatException));
- //
- passed &= VerifyDoubleParse("5.0", NumberStyles.Number, distinctNFI, 5);
- passed &= VerifyDoubleParse("1,234.0", NumberStyles.Number, distinctNFI, 1234);
- passed &= VerifyDoubleParse("5.0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyDoubleParse("1,234.0", NumberStyles.Currency, distinctNFI, 1234);
- passed &= VerifyDoubleParse("5.0", NumberStyles.Any, distinctNFI, 5);
- passed &= VerifyDoubleParse("1,234.0", NumberStyles.Any, distinctNFI, 1234);
- passed &= VerifyDoubleParseException("$5.0", NumberStyles.Currency, distinctNFI, typeof(FormatException));
- passed &= VerifyDoubleParseException("$5.0", NumberStyles.Any, distinctNFI, typeof(FormatException));
- passed &= VerifyDoubleParseException("5:0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyDoubleParseException("5;0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyDoubleParseException("$5:0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyDoubleParse("5:0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyDoubleParse("5:000", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyDoubleParse("5;000", NumberStyles.Currency, distinctNFI, 5000);
- passed &= VerifyDoubleParse("$5:0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyDoubleParse("$5;0", NumberStyles.Currency, distinctNFI, 50);
- passed &= VerifyDoubleParse("5:0", NumberStyles.Any, distinctNFI, 5);
- passed &= VerifyDoubleParse("5;0", NumberStyles.Any, distinctNFI, 50);
- passed &= VerifyDoubleParse("$5:0", NumberStyles.Any, distinctNFI, 5);
- passed &= VerifyDoubleParse("$5;0", NumberStyles.Any, distinctNFI, 50);
- passed &= VerifyDoubleParseException("123,456;789.0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyDoubleParse("123,456;789.0", NumberStyles.Currency, distinctNFI, 123456789);
- passed &= VerifyDoubleParse("123,456;789.0", NumberStyles.Any, distinctNFI, 123456789);
- passed &= VerifyDoubleParseException("$123,456;789.0", NumberStyles.Any, distinctNFI, typeof(FormatException));
- //
- passed &= VerifyDoubleParseException("1.79769313486231E+309", NumberStyles.Float | NumberStyles.AllowExponent, null, typeof(OverflowException));
- passed &= VerifyDoubleParseException("-1.79769313486231E+309", NumberStyles.Float | NumberStyles.AllowExponent, null, typeof(OverflowException));
- passed &= VerifyDoubleParseException("1.89769313486231E+308", NumberStyles.Float | NumberStyles.AllowExponent, null, typeof(OverflowException));
- passed &= VerifyDoubleParseException("-1.89769313486231E+308", NumberStyles.Float | NumberStyles.AllowExponent, null, typeof(OverflowException));
- passed &= VerifyDoubleParseException("Garbage", typeof(FormatException));
- passed &= VerifyDoubleParseException("5\0Garbage", typeof(FormatException));
- passed &= VerifyDoubleParseException(null, typeof(ArgumentNullException));
- passed &= VerifyDoubleParseException("FF", NumberStyles.HexNumber, goodNFI, typeof(ArgumentException));
- passed &= VerifyDoubleParseException("4", (NumberStyles)(-1), typeof(ArgumentException));
- passed &= VerifyDoubleParseException("4", (NumberStyles)0x10000, typeof(ArgumentException));
- passed &= VerifyDoubleParseException("4", (NumberStyles)(-1), CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifyDoubleParseException("4", (NumberStyles)0x10000, CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifyDoubleParseException("123,000,000,000,000,000,000", NumberStyles.Any, germanCulture, typeof(FormatException));
- passed &= VerifyDoubleParseException("123.000.000.000.000.000.000", NumberStyles.Any, japaneseCulture, typeof(FormatException));
- passed &= VerifyDoubleParseException("5,00 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Integer, germanCulture, typeof(FormatException)); // currency
-
-
- /////////// TryParse(String)
- //// Pass cases
- passed &= VerifyDoubleTryParse("0", 0, true);
- passed &= VerifyDoubleTryParse("-0", 0, true);
- passed &= VerifyDoubleTryParse("5", 5, true);
- passed &= VerifyDoubleTryParse(" 5 ", 5, true);
- passed &= VerifyDoubleTryParse("-5", -5, true);
- passed &= VerifyDoubleTryParse("5\0", 5, true);
- passed &= VerifyDoubleTryParse("5 \0", 5, true);
- passed &= VerifyDoubleTryParse("5\0\0\0", 5, true);
- passed &= VerifyDoubleTryParse("893382737", 893382737, true);
- passed &= VerifyDoubleTryParse("-893382737", -893382737, true);
- passed &= VerifyDoubleTryParse("1234567891", 1234567891, true);
- passed &= VerifyDoubleTryParse("-1234567891", -1234567891, true);
- passed &= VerifyDoubleTryParse("123456789123456789", 123456789123456789, true);
- passed &= VerifyDoubleTryParse("-123456789123456789", -123456789123456789, true);
- passed &= VerifyDoubleTryParse("123456789123456789123", 123456789123456789123.0, true);
- passed &= VerifyDoubleTryParse("-123456789123456789123", -123456789123456789123.0, true);
- passed &= VerifyDoubleTryParse("18446744073709551615", 18446744073709551615, true);
- passed &= VerifyDoubleTryParse("79228162514264337593543950335", 79228162514264337593543950335.0, true);
- passed &= VerifyDoubleTryParse("-79228162514264337593543950335", -79228162514264337593543950335.0, true);
- passed &= VerifyDoubleTryParse("79228162514264337593543950336", 79228162514264337593543950336.0, true);
- passed &= VerifyDoubleTryParse("-79228162514264337593543950336", -79228162514264337593543950336.0, true);
- passed &= VerifyDoubleTryParse("7.3", 7.3, true);
- passed &= VerifyDoubleTryParse(".297", 0.297, true);
- passed &= VerifyDoubleTryParse("5.555555555", 5.555555555, true);
- passed &= VerifyDoubleTryParse("1.000000", 1.0, true);
- passed &= VerifyDoubleTryParse("1.234E+05", 123400, true);
- passed &= VerifyDoubleTryParse("NaN", Double.NaN, true);
- passed &= VerifyDoubleTryParse("Infinity", Double.PositiveInfinity, true);
- passed &= VerifyDoubleTryParse("-Infinity", Double.NegativeInfinity, true);
-
- //// Fail cases
- passed &= VerifyDoubleTryParse(null, 0, false);
- passed &= VerifyDoubleTryParse("", 0, false);
- passed &= VerifyDoubleTryParse("Garbage", 0, false);
- passed &= VerifyDoubleTryParse("5\0Garbage", 0, false);
- passed &= VerifyDoubleTryParse("FF", 0, false);
- passed &= VerifyDoubleTryParse("23 5", 0, false);
- passed &= VerifyDoubleTryParse("1.234+E05", 0, false);
-
-
- /////////// TryParse(TryParse(String, NumberStyles, IFormatProvider, ref Double)
- //// Pass cases
- passed &= VerifyDoubleTryParse("5", NumberStyles.Integer, CultureInfo.InvariantCulture, 5, true);
- passed &= VerifyDoubleTryParse("-5", NumberStyles.Integer, CultureInfo.InvariantCulture, -5, true);
- passed &= VerifyDoubleTryParse("-79228162514264337593543950336", NumberStyles.Integer, CultureInfo.InvariantCulture, -79228162514264337593543950336.0, true);
- // Variations on NumberStyles
- passed &= VerifyDoubleTryParse(" 5", NumberStyles.AllowLeadingWhite, goodNFI, 5, true);
- passed &= VerifyDoubleTryParse("5", NumberStyles.Number, goodNFI, 5, true);
- passed &= VerifyDoubleTryParse("5.0", NumberStyles.AllowDecimalPoint, goodNFI, 5.0, true);
- passed &= VerifyDoubleTryParse("5.3", NumberStyles.AllowDecimalPoint, goodNFI, 5.3, true);
- passed &= VerifyDoubleTryParse("1.234E+05", NumberStyles.Float | NumberStyles.AllowExponent, goodNFI, 123400, true);
- passed &= VerifyDoubleTryParse("1.79769313486231E+308", NumberStyles.Float | NumberStyles.AllowExponent, null, 1.79769313486231E+308, true);
- passed &= VerifyDoubleTryParse("-1.79769313486231E+308", NumberStyles.Float | NumberStyles.AllowExponent, null, -1.79769313486231E+308, true);
- // Variations on IFP
- passed &= VerifyDoubleTryParse("5", NumberStyles.Integer, goodNFI, 5, true);
- passed &= VerifyDoubleTryParse("5", NumberStyles.Integer, null, 5, true);
- passed &= VerifyDoubleTryParse("5", NumberStyles.Integer, new DateTimeFormatInfo(), 5, true);
- passed &= VerifyDoubleTryParse("^42", NumberStyles.Any, customNFI, -42, true);
- passed &= VerifyDoubleTryParse("123", NumberStyles.Integer, germanCulture, 123, true);
- passed &= VerifyDoubleTryParse("123", NumberStyles.Integer, japaneseCulture, 123, true);
- passed &= VerifyDoubleTryParse("123.456", NumberStyles.Any, germanCulture, 123456, true);
- passed &= VerifyDoubleTryParse("123,456", NumberStyles.Any, japaneseCulture, 123456, true);
- passed &= VerifyDoubleTryParse("123,456", NumberStyles.AllowDecimalPoint, germanCulture, 123.456, true);
- passed &= VerifyDoubleTryParse("123.456", NumberStyles.AllowDecimalPoint, japaneseCulture, 123.456, true);
- passed &= VerifyDoubleTryParse("5,23 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Any, germanCulture, 5.23, true); // currency
- passed &= VerifyDoubleTryParse("5.23 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Any, germanCulture, 523, true); // currency
- //
- //// Fail cases
- passed &= VerifyDoubleTryParse("-42", NumberStyles.Any, customNFI, 0, false);
- passed &= VerifyDoubleTryParse("5 ", NumberStyles.AllowLeadingWhite, goodNFI, 0, false);
- passed &= VerifyDoubleTryParse("5.3", NumberStyles.None, goodNFI, 0, false);
- passed &= VerifyDoubleTryParse("1.234E+05", NumberStyles.AllowExponent, goodNFI, 0, false);
- passed &= VerifyDoubleTryParse("-1.79769313486231E+309", NumberStyles.Float | NumberStyles.AllowExponent, null, 0, false);
- passed &= VerifyDoubleTryParse("1.89769313486231E+308", NumberStyles.Float | NumberStyles.AllowExponent, null, 0, false);
- passed &= VerifyDoubleTryParse("-1.89769313486231E+308", NumberStyles.Float | NumberStyles.AllowExponent, null, 0, false);
- passed &= VerifyDoubleTryParse("123,000,000,000,000,000,000", NumberStyles.Any, germanCulture, 0, false);
- passed &= VerifyDoubleTryParse("123.000.000.000.000.000.000", NumberStyles.Any, japaneseCulture, 0, false);
-
- //// Exception cases
- passed &= VerifyDoubleTryParseException("12", NumberStyles.HexNumber, CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifyDoubleTryParseException("5", NumberStyles.AllowHexSpecifier | NumberStyles.AllowParentheses, null, typeof(ArgumentException));
- passed &= VerifyDoubleTryParseException("4", (NumberStyles)(-1), CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifyDoubleTryParseException("4", (NumberStyles)0x10000, CultureInfo.InvariantCulture, typeof(ArgumentException));
-
- // NumberStyles/NFI variations
- //
- passed &= VerifyDoubleTryParse("5", NumberStyles.Integer, corruptNFI, 5, true);
- passed &= VerifyDoubleTryParse("5", NumberStyles.Number, corruptNFI, 5, true);
- passed &= VerifyDoubleTryParse("5.3", NumberStyles.Number, corruptNFI, 5.3, true);
- passed &= VerifyDoubleTryParse("5,3", NumberStyles.Number, corruptNFI, 0, false);
- passed &= VerifyDoubleTryParse("5.2.3", NumberStyles.Number, corruptNFI, 0, false);
- passed &= VerifyDoubleTryParse("$5.3", NumberStyles.Currency, corruptNFI, 5.3, true);
- passed &= VerifyDoubleTryParse("$5,3", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyDoubleTryParse("$5.2.3", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyDoubleTryParse("5.3", NumberStyles.Currency, corruptNFI, 5.3, true);
- passed &= VerifyDoubleTryParse("5,3", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyDoubleTryParse("5.2.3", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyDoubleTryParse("5.3", NumberStyles.Any, corruptNFI, 5.3, true);
- passed &= VerifyDoubleTryParse("5,3", NumberStyles.Any, corruptNFI, 0, false);
- passed &= VerifyDoubleTryParse("5.2.3", NumberStyles.Any, corruptNFI, 0, false);
- //
- passed &= VerifyDoubleTryParse("5", NumberStyles.Integer, swappedNFI, 5, true);
- passed &= VerifyDoubleTryParse("1,234", NumberStyles.Integer, swappedNFI, 0, false);
- passed &= VerifyDoubleTryParse("5", NumberStyles.Number, swappedNFI, 5, true);
- passed &= VerifyDoubleTryParse("5.0", NumberStyles.Number, swappedNFI, 5, true);
- passed &= VerifyDoubleTryParse("1,234", NumberStyles.Number, swappedNFI, 1234, true);
- passed &= VerifyDoubleTryParse("1,234.0", NumberStyles.Number, swappedNFI, 1234, true);
- passed &= VerifyDoubleTryParse("5.000.000", NumberStyles.Number, swappedNFI, 0, false);
- passed &= VerifyDoubleTryParse("5.000,00", NumberStyles.Number, swappedNFI, 0, false);
- passed &= VerifyDoubleTryParse("5.000", NumberStyles.Currency, swappedNFI, 5, true); //???
- passed &= VerifyDoubleTryParse("5.000,00", NumberStyles.Currency, swappedNFI, 0, false); //???
- passed &= VerifyDoubleTryParse("$5.000", NumberStyles.Currency, swappedNFI, 5000, true);
- passed &= VerifyDoubleTryParse("$5.000,00", NumberStyles.Currency, swappedNFI, 5000, true);
- passed &= VerifyDoubleTryParse("5.000", NumberStyles.Any, swappedNFI, 5, true); //?
- passed &= VerifyDoubleTryParse("5.000,00", NumberStyles.Any, swappedNFI, 0, false); //?
- passed &= VerifyDoubleTryParse("$5.000", NumberStyles.Any, swappedNFI, 5000, true);
- passed &= VerifyDoubleTryParse("$5.000,00", NumberStyles.Any, swappedNFI, 5000, true);
- passed &= VerifyDoubleTryParse("5,0", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyDoubleTryParse("$5,0", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyDoubleTryParse("5,000", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyDoubleTryParse("$5,000", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyDoubleTryParse("5,000.0", NumberStyles.Currency, swappedNFI, 0, false);
- passed &= VerifyDoubleTryParse("$5,000.0", NumberStyles.Currency, swappedNFI, 0, false);
- passed &= VerifyDoubleTryParse("5,000", NumberStyles.Any, swappedNFI, 5, true);
- passed &= VerifyDoubleTryParse("$5,000", NumberStyles.Any, swappedNFI, 5, true);
- passed &= VerifyDoubleTryParse("5,000.0", NumberStyles.Any, swappedNFI, 0, false);
- passed &= VerifyDoubleTryParse("$5,000.0", NumberStyles.Any, swappedNFI, 0, false);
- //
- passed &= VerifyDoubleTryParse("5.0", NumberStyles.Number, distinctNFI, 5, true);
- passed &= VerifyDoubleTryParse("1,234.0", NumberStyles.Number, distinctNFI, 1234, true);
- passed &= VerifyDoubleTryParse("5.0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyDoubleTryParse("1,234.0", NumberStyles.Currency, distinctNFI, 1234, true);
- passed &= VerifyDoubleTryParse("5.0", NumberStyles.Any, distinctNFI, 5, true);
- passed &= VerifyDoubleTryParse("1,234.0", NumberStyles.Any, distinctNFI, 1234, true);
- passed &= VerifyDoubleTryParse("$5.0", NumberStyles.Currency, distinctNFI, 0, false);
- passed &= VerifyDoubleTryParse("$5.0", NumberStyles.Any, distinctNFI, 0, false);
- passed &= VerifyDoubleTryParse("5:0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyDoubleTryParse("5;0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyDoubleTryParse("$5:0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyDoubleTryParse("5:0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyDoubleTryParse("5:000", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyDoubleTryParse("5;000", NumberStyles.Currency, distinctNFI, 5000, true);
- passed &= VerifyDoubleTryParse("$5:0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyDoubleTryParse("$5;0", NumberStyles.Currency, distinctNFI, 50, true);
- passed &= VerifyDoubleTryParse("5:0", NumberStyles.Any, distinctNFI, 5, true);
- passed &= VerifyDoubleTryParse("5;0", NumberStyles.Any, distinctNFI, 50, true);
- passed &= VerifyDoubleTryParse("$5:0", NumberStyles.Any, distinctNFI, 5, true);
- passed &= VerifyDoubleTryParse("$5;0", NumberStyles.Any, distinctNFI, 50, true);
- passed &= VerifyDoubleTryParse("123,456;789.0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyDoubleTryParse("123,456;789.0", NumberStyles.Currency, distinctNFI, 123456789, true);
- passed &= VerifyDoubleTryParse("123,456;789.0", NumberStyles.Any, distinctNFI, 123456789, true);
- passed &= VerifyDoubleTryParse("$123,456;789.0", NumberStyles.Any, distinctNFI, 0, false);
-
-
- // Should these pass or fail? Current parse behavior is to pass, so they might be
- // parse bugs, but they're not tryparse bugs.
- passed &= VerifyDoubleParse("5", NumberStyles.AllowExponent, goodNFI, 5);
- passed &= VerifyDoubleTryParse("5", NumberStyles.AllowExponent, goodNFI, 5, true);
- // I expect ArgumentException with an ambiguous NFI
- passed &= VerifyDoubleParse("^42", NumberStyles.Any, ambigNFI, -42);
- passed &= VerifyDoubleTryParse("^42", NumberStyles.Any, ambigNFI, -42, true);
-
- /// END TEST CASES
- }
- catch (Exception e)
- {
- TestLibrary.Logging.WriteLine("Unexpected exception!! " + e.ToString());
- passed = false;
- }
-
- if (passed)
- {
- TestLibrary.Logging.WriteLine("paSs");
- return 100;
- }
- else
- {
- TestLibrary.Logging.WriteLine("FAiL");
- return 1;
- }
- }
-
- public static bool VerifyDoubleTryParse(string value, Double expectedResult, bool expectedReturn)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Double.TryParse, Value = '{0}', Expected Result = {1}, Expected Return = {2}",
- value, expectedResult, expectedReturn);
- }
- Double result = 0;
- try
- {
- bool returnValue = Double.TryParse(value, out result);
- if (returnValue != expectedReturn)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedReturn, returnValue);
- return false;
- }
- if (Double.IsNaN(expectedResult) && Double.IsNaN(result))
- {
- return true;
- }
- if (result != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, result);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyDoubleTryParse(string value, NumberStyles style, IFormatProvider provider, Double expectedResult, bool expectedReturn)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Double.TryParse, Value = '{0}', Style = {1}, Provider = {2}, Expected Result = {3}, Expected Return = {4}",
- value, style, provider, expectedResult, expectedReturn);
- }
- Double result = 0;
- try
- {
- bool returnValue = Double.TryParse(value, style, provider, out result);
- if (returnValue != expectedReturn)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Style = {1}, Provider = {2}, Expected Return = {3}, Actual Return = {4}",
- value, style, provider, expectedReturn, returnValue);
- return false;
- }
- if (Double.IsNaN(expectedResult) && Double.IsNaN(result))
- {
- return true;
- }
- if (result != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, result);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyDoubleTryParseException(string value, NumberStyles style, IFormatProvider provider, Type exceptionType)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Double.TryParse, Value = '{0}', Style = {1}, Provider = {2}, Expected Exception = {3}",
- value, style, provider, exceptionType);
- }
- try
- {
- Double result = 0;
- Boolean returnValue = Double.TryParse(value, style, provider, out result);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifyDoubleParse(string value, Double expectedResult)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Double.Parse, Value = '{0}', Expected Result, {1}",
- value, expectedResult);
- }
- try
- {
- Double returnValue = Double.Parse(value);
- if (Double.IsNaN(expectedResult) && Double.IsNaN(returnValue))
- {
- return true;
- }
- if (returnValue != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, returnValue);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyDoubleParse(string value, NumberStyles style, IFormatProvider provider, Double expectedResult)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Double.Parse, Value = '{0}', Style = {1}, provider = {2}, Expected Result = {3}",
- value, style, provider, expectedResult);
- }
- try
- {
- Double returnValue = Double.Parse(value, style, provider);
- if (Double.IsNaN(expectedResult) && Double.IsNaN(returnValue))
- {
- return true;
- }
- if (returnValue != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, returnValue);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyDoubleParseException(string value, Type exceptionType)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Double.Parse, Value = '{0}', Expected Exception, {1}",
- value, exceptionType);
- }
- try
- {
- Double returnValue = Double.Parse(value);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifyDoubleParseException(string value, NumberStyles style, Type exceptionType)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Double.Parse, Value = '{0}', Style = {1}, Expected Exception = {3}",
- value, style, exceptionType);
- }
- try
- {
- Double returnValue = Double.Parse(value, style);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifyDoubleParseException(string value, NumberStyles style, IFormatProvider provider, Type exceptionType)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Double.Parse, Value = '{0}', Style = {1}, Provider = {2}, Expected Exception = {3}",
- value, style, provider, exceptionType);
- }
- try
- {
- Double returnValue = Double.Parse(value, style, provider);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-}
diff --git a/tests/src/CoreMangLib/cti/system/int/Int32Parse1.csproj b/tests/src/CoreMangLib/cti/system/int/Int32Parse1.csproj
deleted file mode 100644
index 1310df47af..0000000000
--- a/tests/src/CoreMangLib/cti/system/int/Int32Parse1.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="int32parse1.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/int/Int32Parse2.csproj b/tests/src/CoreMangLib/cti/system/int/Int32Parse2.csproj
deleted file mode 100644
index 02ce3e68cd..0000000000
--- a/tests/src/CoreMangLib/cti/system/int/Int32Parse2.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="int32parse2.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/int/Int32Parse3.csproj b/tests/src/CoreMangLib/cti/system/int/Int32Parse3.csproj
deleted file mode 100644
index 6634e074e0..0000000000
--- a/tests/src/CoreMangLib/cti/system/int/Int32Parse3.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="int32parse3.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/int/Int32Parse4.csproj b/tests/src/CoreMangLib/cti/system/int/Int32Parse4.csproj
deleted file mode 100644
index 5cb1113721..0000000000
--- a/tests/src/CoreMangLib/cti/system/int/Int32Parse4.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="int32parse4.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/int/Int32TryParse.csproj b/tests/src/CoreMangLib/cti/system/int/Int32TryParse.csproj
deleted file mode 100644
index 273223cadf..0000000000
--- a/tests/src/CoreMangLib/cti/system/int/Int32TryParse.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="int32tryparse.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/int/int32parse1.cs b/tests/src/CoreMangLib/cti/system/int/int32parse1.cs
deleted file mode 100644
index d8eb2c0cd9..0000000000
--- a/tests/src/CoreMangLib/cti/system/int/int32parse1.cs
+++ /dev/null
@@ -1,289 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-
-//system.Int32.Parse(system.string)
-public class Int32Parse1
-{
- #region Public Methods
- public bool RunTests()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.LogInformation("[Positive]");
- retVal = PosTest1() && retVal;
- retVal = PosTest2() && retVal;
- retVal = PosTest3() && retVal;
- retVal = PosTest4() && retVal;
-
- TestLibrary.TestFramework.LogInformation("[Negative]");
- retVal = NegTest1() && retVal;
- retVal = NegTest2() && retVal;
- retVal = NegTest3() && retVal;
- retVal = NegTest4() && retVal;
- retVal = NegTest5() && retVal;
-
- return retVal;
- }
-
- #region Positive Test Cases
- public bool PosTest1()
- {
- bool retVal = true;
-
-
- TestLibrary.TestFramework.BeginScenario("PosTest1: normal test basic function of the method ");
-
- try
- {
- string s1 = Int32.MaxValue.ToString();
- if (Int32.MaxValue != Int32.Parse(s1))
- {
- TestLibrary.TestFramework.LogError("001", "the result is not the int32.maxvalue as expected ");
- retVal = false;
- }
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest2()
- {
- bool retVal = true;
-
-
- TestLibrary.TestFramework.BeginScenario("PosTest2: normal test about int32.minvalue ");
-
- try
- {
- string s1 = Int32.MinValue.ToString();
- if (Int32.MinValue != Int32.Parse(s1))
- {
- TestLibrary.TestFramework.LogError("003", "the result is not the int32.minvalue as expected ");
- retVal = false;
- }
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest3()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest3: test the parameter of white space in both of the beginning and end of the string");
-
- try
- {
- string s1 = " 12125684 ";
- Int32 i1 = Int32.Parse(s1);
- if (i1 != 12125684)
- {
- TestLibrary.TestFramework.LogError("005", "the result is not the int32 as expected ");
- retVal = false;
- }
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest4()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest4: test the parameter (-0)");
-
- try
- {
- string s1 = "-0";
- Int32 i1 = Int32.Parse(s1);
- if (i1 != 0)
- {
- TestLibrary.TestFramework.LogError("007", "the result is not the 0 as expected ");
- retVal = false;
- }
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("008", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
- #endregion
-
- #region Negative Test Cases
- public bool NegTest1()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest1: null reference parameter ");
-
- try
- {
- string s1 = null;
- Int32 i1 = Int32.Parse(s1);
- TestLibrary.TestFramework.LogError("101", "the Method did not throw a ArgumentNullException");
- retVal = false;
- }
- catch (ArgumentNullException)
- {
- }
-
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("102", "Unexpected exception: " + e);
- TestLibrary.TestFramework.LogInformation(e.StackTrace);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest2()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest2: test FormatException1 ");
-
- string s1 = "-321-677";
- try
- {
- Int32 i1 = Int32.Parse(s1);
- TestLibrary.TestFramework.LogError("103", "the Method did not throw a FormatException,patameter is: " + s1);
- retVal = false;
- }
- catch (FormatException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("104", "Unexpected exception: " + e);
- TestLibrary.TestFramework.LogInformation(e.StackTrace);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest3()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest3: test FormatException2, parameter:43dce6a");
-
- try
- {
- string s1 = "43dce6a";
- Int32 i1 = Int32.Parse(s1);
- TestLibrary.TestFramework.LogError("105", "the Method did not throw a FormatException,patameter is: " + s1);
- retVal = false;
- }
- catch (FormatException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("106", "Unexpected exception: " + e);
- TestLibrary.TestFramework.LogInformation(e.StackTrace);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest4()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest4: test FormatException3 by setting the parameter white space");
-
- try
- {
- string s1 = " ";
- Int32 i1 = Int32.Parse(s1);
- TestLibrary.TestFramework.LogError("107", "the Method did not throw a FormatException,patameter is: white space");
- retVal = false;
- }
- catch (FormatException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("108", "Unexpected exception: " + e);
- TestLibrary.TestFramework.LogInformation(e.StackTrace);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest5()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest5: test OverFlowException");
-
- try
- {
- string s1 = "2147483648";
- Int32 i1 = Int32.Parse(s1);
- TestLibrary.TestFramework.LogError("109", "the Method did not throw an OverflowException ,patameter is: Int32.MaxValue+1");
- retVal = false;
- }
- catch (OverflowException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("110", "Unexpected exception: " + e);
- TestLibrary.TestFramework.LogInformation(e.StackTrace);
- retVal = false;
- }
-
- return retVal;
- }
- #endregion
- #endregion
-
- public static int Main()
- {
- Int32Parse1 test = new Int32Parse1();
-
- TestLibrary.TestFramework.BeginTestCase("Int32Parse");
-
- if (test.RunTests())
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("PASS");
- return 100;
- }
- else
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("FAIL");
- return 0;
- }
- }
-}
diff --git a/tests/src/CoreMangLib/cti/system/int/int32parse2.cs b/tests/src/CoreMangLib/cti/system/int/int32parse2.cs
deleted file mode 100644
index a7c2b1d749..0000000000
--- a/tests/src/CoreMangLib/cti/system/int/int32parse2.cs
+++ /dev/null
@@ -1,360 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Globalization;
-
-//System.Int32.Parse(System.String,System.Globalization.NumberStyles)
-public class Int32Parse2
-{
- #region Privates
- private CultureInfo CurrentCulture = TestLibrary.Utilities.CurrentCulture;
- private CultureInfo CustomCulture = null;
- private CultureInfo CustomCultureForNumberFormat
- {
- get
- {
- if (null == CustomCulture)
- {
- CustomCulture = new CultureInfo(CurrentCulture.Name);
- NumberFormatInfo nfi = CustomCulture.NumberFormat;
- //default is "," in most of the cultures, but in some cultures like DE, TR it is "."
- //nfi.NumberGroupSeparator;
- nfi.NumberGroupSizes = new int[] { 3 };
- nfi.NegativeSign = "-"; //for NegTest5
- nfi.NumberNegativePattern = 1; //for NegTest5
-
- CustomCulture.NumberFormat = nfi;
- }
- return CustomCulture;
- }
- }
- #endregion
-
- #region Public Methods
- public bool RunTests()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.LogInformation("[Positive]");
- retVal = PosTest1() && retVal;
- retVal = PosTest2() && retVal;
- retVal = PosTest3() && retVal;
- retVal = PosTest4() && retVal;
- retVal = PosTest5() && retVal;
-
- TestLibrary.TestFramework.LogInformation("[Negative]");
- retVal = NegTest1() && retVal;
- retVal = NegTest2() && retVal;
- retVal = NegTest3() && retVal;
- retVal = NegTest4() && retVal;
- retVal = NegTest5() && retVal;
-
- return retVal;
- }
-
- #region Positive Test Cases
- public bool PosTest1()
- {
- bool retVal = true;
-
- // Add your scenario description here
- TestLibrary.TestFramework.BeginScenario("PosTest1:Test the parameter NumberStyles.AllowThousands ");
-
- try
- {
- TestLibrary.Utilities.CurrentCulture = CustomCultureForNumberFormat;
- String groupSeparator = CustomCultureForNumberFormat.NumberFormat.NumberGroupSeparator;
-
- string s1 = "2" + groupSeparator + "147" + groupSeparator + "483" + groupSeparator + "647";
- Int32 i1 = Int32.Parse(s1, System.Globalization.NumberStyles.AllowThousands);
- if (i1 != Int32.MaxValue)
- {
- TestLibrary.TestFramework.LogError("001", "The result is not the value as expected ");
- retVal = false;
- }
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
- retVal = false;
- }
- finally
- {
- TestLibrary.Utilities.CurrentCulture = CurrentCulture;
- }
- return retVal;
- }
-
- public bool PosTest2()
- {
- bool retVal = true;
-
- // Add your scenario description here
- TestLibrary.TestFramework.BeginScenario("PosTest2:Test the parameters NumberStyles.AllowParentheses ");
-
- try
- {
- string s1 = "(105)";
- Int32 i1 = Int32.Parse(s1, System.Globalization.NumberStyles.AllowParentheses);
- if (i1 != -105)
- {
- TestLibrary.TestFramework.LogError("003", "The result is not the value as expected ");
- retVal = false;
- }
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest3()
- {
- bool retVal = true;
-
- // Add your scenario description here
- TestLibrary.TestFramework.BeginScenario("PosTest3:Test the parameters with white space in both the beginning and the end ");
-
- try
- {
- string s1 = " 8765 ";
- Int32 i1 = Int32.Parse(s1, System.Globalization.NumberStyles.AllowLeadingWhite | System.Globalization.NumberStyles.AllowTrailingWhite);
- if (i1 != 8765)
- {
- TestLibrary.TestFramework.LogError("005", "The result is not the value as expected ");
- retVal = false;
- }
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest4()
- {
- bool retVal = true;
-
- // Add your scenario description here
- TestLibrary.TestFramework.BeginScenario("PosTest4:Test the parameters NumberStyles.AllowTrailingSign");
-
- try
- {
- string s1 = "8765-";
- Int32 i1 = Int32.Parse(s1, System.Globalization.NumberStyles.AllowTrailingSign);
- if (i1 != -8765)
- {
- TestLibrary.TestFramework.LogError("007", "The result is not the value as expected ");
- retVal = false;
- }
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("008", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest5()
- {
- bool retVal = true;
-
- // Add your scenario description here
- TestLibrary.TestFramework.BeginScenario("PosTest5:Test the parameters NumberStyles.HexNumber");
-
- try
- {
- string s1 = " 6a9fe7 ";
- Int32 i1 = Int32.Parse(s1, System.Globalization.NumberStyles.HexNumber);
- if (i1 != 6987751)
- {
- TestLibrary.TestFramework.LogError("009", "The result is not the value as expected ");
- retVal = false;
- }
-
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("010", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
- #endregion
-
- #region Negative Test Cases
- public bool NegTest1()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest1: null reference parameter");
-
- try
- {
- string s1 = null;
- Int32 i1 = Int32.Parse(s1, System.Globalization.NumberStyles.AllowLeadingSign);
- TestLibrary.TestFramework.LogError("101", "the Method did not throw a ArgumentNullException");
- retVal = false;
- }
- catch (ArgumentNullException)
- {
- }
-
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("102", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest2()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest2: test FormatException1 ");
-
- string s1 = " (321)677 ";
- try
- {
- Int32 i1 = Int32.Parse(s1, System.Globalization.NumberStyles.AllowParentheses);
- TestLibrary.TestFramework.LogError("103", "the Method did not throw a FormatException,patameter is: " + s1);
- retVal = false;
- }
- catch (System.FormatException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("104", "Unexpected exception: " + e);
- TestLibrary.TestFramework.LogInformation(e.StackTrace);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest3()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest3: test ArgumentException1");
-
- try
- {
- string s1 = "43dce6a-";
- Int32 i1 = Int32.Parse(s1, System.Globalization.NumberStyles.HexNumber | System.Globalization.NumberStyles.AllowTrailingSign);
- TestLibrary.TestFramework.LogError("105", "the Method did not throw a FormatException,patameter is: " + s1);
- retVal = false;
- }
- catch (System.ArgumentException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("106", "Unexpected exception: " + e);
- TestLibrary.TestFramework.LogInformation(e.StackTrace);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest4()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest4: test ArgumentException2");
-
- try
- {
- string s1 = "4346";
- int i1 = 54543;
- System.Globalization.NumberStyles Ns = (System.Globalization.NumberStyles)i1;
- Int32 i2 = Int32.Parse(s1, Ns);
- TestLibrary.TestFramework.LogError("107", "the Method did not throw a FormatException,patameter is: " + s1);
- retVal = false;
- }
- catch (System.ArgumentException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("108", "Unexpected exception: " + e);
- TestLibrary.TestFramework.LogInformation(e.StackTrace);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest5()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest5: test OverflowException ");
-
- try
- {
- TestLibrary.Utilities.CurrentCulture = CustomCultureForNumberFormat;
- String groupSeparator = CustomCultureForNumberFormat.NumberFormat.NumberGroupSeparator;
-
- string s1 = "-2" + groupSeparator + "147" + groupSeparator + "483" + groupSeparator + "650";
- Int32 i1 = Int32.Parse(s1, System.Globalization.NumberStyles.AllowThousands | System.Globalization.NumberStyles.AllowLeadingSign);
- TestLibrary.TestFramework.LogError("109", "the Method did not throw a FormatException,patameter is: " + s1);
- retVal = false;
- }
- catch (System.OverflowException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("110", "Unexpected exception: " + e);
- TestLibrary.TestFramework.LogInformation(e.StackTrace);
- retVal = false;
- }
- finally
- {
- TestLibrary.Utilities.CurrentCulture = CurrentCulture;
- }
-
- return retVal;
- }
- #endregion
- #endregion
-
- public static int Main()
- {
- Int32Parse2 test = new Int32Parse2();
-
- TestLibrary.TestFramework.BeginTestCase("Int32Parse2");
-
- if (test.RunTests())
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("PASS");
- return 100;
- }
- else
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("FAIL");
- return 0;
- }
- }
-}
diff --git a/tests/src/CoreMangLib/cti/system/int/int32parse3.cs b/tests/src/CoreMangLib/cti/system/int/int32parse3.cs
deleted file mode 100644
index d50f31d832..0000000000
--- a/tests/src/CoreMangLib/cti/system/int/int32parse3.cs
+++ /dev/null
@@ -1,340 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Globalization;
-
-//Parse(System.String,System.Globalization.NumberStyles,System.IFormatProvider)
-public class Int32Parse3
-{
- #region Privates
- private CultureInfo CurrentCulture = TestLibrary.Utilities.CurrentCulture;
- private CultureInfo customCulture = null;
- private CultureInfo CustomCulture
- {
- get
- {
- if (null == customCulture)
- {
- customCulture = new CultureInfo(CurrentCulture.Name);
- NumberFormatInfo nfi = CustomCulture.NumberFormat;
- nfi.NumberGroupSeparator = ",";
- nfi.NumberGroupSizes = new int[] { 3 };
- nfi.NegativeSign = "-";
- nfi.NumberNegativePattern = 1;
-
- customCulture.NumberFormat = nfi;
- }
- return customCulture;
- }
- }
- #endregion
-
- #region Public Methods
- public bool RunTests()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.LogInformation("[Positive]");
- retVal = PosTest1() && retVal;
- retVal = PosTest2() && retVal;
- retVal = PosTest3() && retVal;
- retVal = PosTest4() && retVal;
-// retVal = PosTest5() && retVal;
- retVal = PosTest6() && retVal;
-
- TestLibrary.TestFramework.LogInformation("[Negative]");
- retVal = NegTest1() && retVal;
- retVal = NegTest2() && retVal;
- retVal = NegTest3() && retVal;
- retVal = NegTest4() && retVal;
-
- return retVal;
- }
-
- #region Positive Test Cases
- public bool PosTest1()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest1:Test the method with the cultureinfo parameter which implemented the IFormatProvider interface ");
-
- try
- {
- string s1 = "1,000";
- int i1 = Int32.Parse(s1, System.Globalization.NumberStyles.AllowThousands, CustomCulture);
- if (i1 != 1000)
- {
- TestLibrary.TestFramework.LogError("001", "The result is not the value as expected. ");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest2()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest2:Test the method with the numberformatinfo parameter which implemented the IFormatProvider interface ");
-
- try
- {
- // if NumberFormatInfo is null, created without any argument, Parse uses CurrrentCulture
- TestLibrary.Utilities.CurrentCulture = CustomCulture;
- string s1 = " 3,000 ";
- int i1 = Int32.Parse(s1, System.Globalization.NumberStyles.AllowThousands | System.Globalization.NumberStyles.AllowLeadingWhite | System.Globalization.NumberStyles.AllowTrailingWhite, new NumberFormatInfo());
- if (i1 != 3000)
- {
- TestLibrary.TestFramework.LogError("003", "The result is not the value as expected. ");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
- retVal = false;
- }
- finally
- {
- TestLibrary.Utilities.CurrentCulture = CurrentCulture;
- }
- return retVal;
- }
-
- public bool PosTest3()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest3:Test the method with the DateTimeFormatInfo parameter which implemented the IFormatProvider interface ");
-
- try
- {
- TestLibrary.Utilities.CurrentCulture = CustomCulture;
- string s1 = "-56,466";
- int i1 = Int32.Parse(s1, System.Globalization.NumberStyles.AllowThousands | System.Globalization.NumberStyles.AllowLeadingSign, new DateTimeFormatInfo());
- if (i1 != -56466)
- {
- TestLibrary.TestFramework.LogError("005", "The result is not the value as expected. ");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
- retVal = false;
- }
- finally
- {
- TestLibrary.Utilities.CurrentCulture = CurrentCulture;
- }
- return retVal;
- }
-
- public bool PosTest4()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest4: Test special string \"-3.456.789\" using the cultureinfo parameter");
-
- try
- {
- string s1 = "-3.456.789";
- int i1 = Int32.Parse(s1, System.Globalization.NumberStyles.AllowThousands | System.Globalization.NumberStyles.AllowLeadingSign, new CultureInfo("pt-BR"));
- if (i1 != -3456789)
- {
- TestLibrary.TestFramework.LogError("007", "The result is not the value as expected. ");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("008", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-/*
- public bool PosTest5()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest5: Test special string \" 3 456 78\" using the cultureinfo parameter");
-
- try
- {
- string s1 = " 3 456 78";
- int i1 = Int32.Parse(s1, System.Globalization.NumberStyles.AllowThousands | System.Globalization.NumberStyles.AllowLeadingWhite, new CultureInfo("sma-SE"));
- if (i1 != 345678)
- {
- TestLibrary.TestFramework.LogError("009", "The result is not the value as expected. ");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("010", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-*/
- public bool PosTest6()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest6: Using the null reference as the third parameter IFormatProvider");
-
- try
- {
- string s1 = " 345678";
- int i1 = Int32.Parse(s1, System.Globalization.NumberStyles.AllowThousands | System.Globalization.NumberStyles.AllowLeadingWhite, null);
- if (i1 != 345678)
- {
- TestLibrary.TestFramework.LogError("011", "The result is not the value as expected. ");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("012", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
- #endregion
-
- #region Nagetive Test Cases
- public bool NegTest1()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest1:Set the parameter string to null reference ");
-
- try
- {
- String s1 = null;
- int i1 = Int32.Parse(s1, System.Globalization.NumberStyles.AllowThousands, new CultureInfo("en-US"));
- TestLibrary.TestFramework.LogError("101", "The ArgumentNullException was not thrown as expected ");
- retVal = false;
- }
- catch (ArgumentNullException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("102", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest2()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest2:Test the ArgumentException");
-
- try
- {
- String s1 = "1000";
- int i1 = 54543;
- System.Globalization.NumberStyles Ns = (System.Globalization.NumberStyles)i1;
- Int32 i2 = Int32.Parse(s1, Ns, new CultureInfo("en-US"));
- TestLibrary.TestFramework.LogError("103", "the Method did not throw a ArgumentException,patameter is: " + s1);
- retVal = false;
- }
- catch (ArgumentException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("104", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest3()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest3:Using improper cultureinfo");
-
- try
- {
- String s1 = "1 000";
- Int32 i2 = Int32.Parse(s1, System.Globalization.NumberStyles.AllowThousands, CustomCulture);
- TestLibrary.TestFramework.LogError("105", "the Method did not throw a FormatException,patameter is: " + s1);
- retVal = false;
- }
- catch (FormatException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("106", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest4()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest4:Test the OverflowException");
-
- try
- {
- String s1 = "2,147,483,650";
- Int32 i2 = Int32.Parse(s1, System.Globalization.NumberStyles.AllowThousands, CustomCulture);
- TestLibrary.TestFramework.LogError("107", "the Method did not throw an OverflowException,patameter is: " + s1);
- retVal = false;
- }
- catch (System.OverflowException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("108", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
- #endregion
- #endregion
-
- public static int Main()
- {
- Int32Parse3 test = new Int32Parse3();
-
- TestLibrary.TestFramework.BeginTestCase("Int32Parse3");
-
- if (test.RunTests())
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("PASS");
- return 100;
- }
- else
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("FAIL");
- return 0;
- }
- }
-} \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/int/int32parse4.cs b/tests/src/CoreMangLib/cti/system/int/int32parse4.cs
deleted file mode 100644
index 79dc5a395f..0000000000
--- a/tests/src/CoreMangLib/cti/system/int/int32parse4.cs
+++ /dev/null
@@ -1,238 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Globalization;
-
-//Parse(System.String,System.IFormatProvider)
-public class Int32Parse4
-{
- #region Public Methods
- public bool RunTests()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.LogInformation("[Positive]");
- retVal = PosTest1() && retVal;
- retVal = PosTest2() && retVal;
- retVal = PosTest3() && retVal;
- retVal = PosTest4() && retVal;
-
- TestLibrary.TestFramework.LogInformation("[Negative]");
- retVal = NegTest1() && retVal;
- retVal = NegTest2() && retVal;
- retVal = NegTest3() && retVal;
-
- return retVal;
- }
-
- #region Positive Test Cases
- public bool PosTest1()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest1: Test the IFormatInfo parameter.");
-
- try
- {
- string s1 = " #1345";
- NumberFormatInfo n1 = new NumberFormatInfo();
- n1.NegativeSign = "#";
- int i1 = Int32.Parse(s1, n1);
- if (i1 != -1345)
- {
- TestLibrary.TestFramework.LogError("001", "The result is not the value as expected. ");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest2()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest2: Test the string with white space in both the beginning and the end");
-
- try
- {
- int i2 = TestLibrary.Generator.GetInt32(-55);
- string s1 = " " + i2.ToString() + " ";
- NumberFormatInfo n1 = new NumberFormatInfo();
- n1.NegativeSign = "#";
- int i1 = Int32.Parse(s1, n1);
- if (i1 != i2)
- {
- TestLibrary.TestFramework.LogError("003", "The result is not the value as expected. ");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest3()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest3: Using number as the negative sign");
-
- try
- {
- int i2 = TestLibrary.Generator.GetInt32(-55);
- string s1 = " 00" + i2;
- NumberFormatInfo n1 = new NumberFormatInfo();
- n1.NegativeSign = "00";
- int i1 = Int32.Parse(s1, n1);
- if (i1 != -i2)
- {
- TestLibrary.TestFramework.LogError("005", "The result is not the value as expected. ");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest4()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest4: Using null reference as the second parameter");
-
- try
- {
- int i2 = TestLibrary.Generator.GetInt32(-55);
- string s1 = i2.ToString();
- NumberFormatInfo n1 = null;
- int i1 = Int32.Parse(s1, n1);
- if (i1 != i2)
- {
- TestLibrary.TestFramework.LogError("007", "The result is not the value as expected. ");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("008", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
- #endregion
-
- #region Negative Test Cases
- public bool NegTest1()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest1: Set the parameter string to null reference ");
-
- try
- {
- String s1 = null;
- int i1 = Int32.Parse(s1, new NumberFormatInfo());
- TestLibrary.TestFramework.LogError("101", "The ArgumentNullException was not thrown as expected ");
- retVal = false;
- }
- catch (ArgumentNullException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("102", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest2()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest2: Test FormatException ");
-
- string s1 = " (321)677 ";
- try
- {
- Int32 i1 = Int32.Parse(s1, new NumberFormatInfo());
- TestLibrary.TestFramework.LogError("103", "the Method did not throw a FormatException,patameter is: " + s1);
- retVal = false;
- }
- catch (System.FormatException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("104", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest3()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest3: Test OverflowException ");
-
- try
- {
- string s1 = "2147483650";
- Int32 i1 = Int32.Parse(s1, new NumberFormatInfo());
- TestLibrary.TestFramework.LogError("105", "the Method did not throw a FormatException,patameter is: " + s1);
- retVal = false;
- }
- catch (System.OverflowException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("106", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
- #endregion
- #endregion
-
- public static int Main()
- {
- Int32Parse4 test = new Int32Parse4();
-
- TestLibrary.TestFramework.BeginTestCase("Int32Parse4");
-
- if (test.RunTests())
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("PASS");
- return 100;
- }
- else
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("FAIL");
- return 0;
- }
- }
-}
diff --git a/tests/src/CoreMangLib/cti/system/int/int32tryparse.cs b/tests/src/CoreMangLib/cti/system/int/int32tryparse.cs
deleted file mode 100644
index a5b9a6081d..0000000000
--- a/tests/src/CoreMangLib/cti/system/int/int32tryparse.cs
+++ /dev/null
@@ -1,565 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Globalization;
-
-// Ported to CoreCLR from Co7527TryParse_all.cs
-// Tests Int32.TryParse(String), Int32.TryParse(String, NumberStyles, IFormatProvider, ref Int32)
-// 2003/04/01 KatyK
-// 2007/06/28 adapted by MarielY
-
-public class Int32TryParse
-{
- static bool verbose = false;
-
- public static int Main()
- {
- bool passed = true;
-
- try
- {
- // Make the test culture independent
- TestLibrary.Utilities.CurrentCulture = CultureInfo.InvariantCulture;
-
- // Set up NFIs to use
- NumberFormatInfo goodNFI = new NumberFormatInfo();
-
- NumberFormatInfo corruptNFI = new NumberFormatInfo(); // DecimalSeparator == GroupSeparator
- corruptNFI.NumberDecimalSeparator = ".";
- corruptNFI.NumberGroupSeparator = ".";
- corruptNFI.CurrencyDecimalSeparator = ".";
- corruptNFI.CurrencyGroupSeparator = ".";
- corruptNFI.CurrencySymbol = "$";
-
- NumberFormatInfo swappedNFI = new NumberFormatInfo(); // DecimalSeparator & GroupSeparator swapped
- swappedNFI.NumberDecimalSeparator = ".";
- swappedNFI.NumberGroupSeparator = ",";
- swappedNFI.CurrencyDecimalSeparator = ",";
- swappedNFI.CurrencyGroupSeparator = ".";
- swappedNFI.CurrencySymbol = "$";
-
- NumberFormatInfo distinctNFI = new NumberFormatInfo(); // DecimalSeparator & GroupSeparator distinct
- distinctNFI.NumberDecimalSeparator = ".";
- distinctNFI.NumberGroupSeparator = ",";
- distinctNFI.CurrencyDecimalSeparator = ":";
- distinctNFI.CurrencyGroupSeparator = ";";
- distinctNFI.CurrencySymbol = "$";
-
- NumberFormatInfo customNFI = new NumberFormatInfo();
- customNFI.NegativeSign = "^";
-
- NumberFormatInfo ambigNFI = new NumberFormatInfo();
- ambigNFI.NegativeSign = "^";
- ambigNFI.CurrencySymbol = "^";
-
- CultureInfo germanCulture = new CultureInfo("de-DE");
- CultureInfo japaneseCulture;
-
- try
- {
- japaneseCulture = new CultureInfo("ja-JP");
- }
- catch (Exception)
- {
- TestLibrary.Logging.WriteLine("East Asian Languages are not installed. Skiping Japanese culture tests.");
- japaneseCulture = null;
- }
-
- // Parse tests included for comparison/regression
- passed &= VerifyInt32Parse("5", 5);
- passed &= VerifyInt32Parse("-5", -5);
- passed &= VerifyInt32Parse("5 ", 5);
- passed &= VerifyInt32Parse("5\0", 5);
- passed &= VerifyInt32Parse("893382737", 893382737);
- passed &= VerifyInt32Parse("-893382737", -893382737);
- passed &= VerifyInt32Parse("1234567891", 1234567891);
- passed &= VerifyInt32Parse("-1234567891", -1234567891);
- passed &= VerifyInt32Parse("5", NumberStyles.Integer, CultureInfo.InvariantCulture, 5);
- passed &= VerifyInt32Parse("-5", NumberStyles.Integer, CultureInfo.InvariantCulture, -5);
- passed &= VerifyInt32Parse("5 \0", NumberStyles.Integer, CultureInfo.InvariantCulture, 5);
- passed &= VerifyInt32Parse("5\0\0\0", NumberStyles.Integer, CultureInfo.InvariantCulture, 5);
- passed &= VerifyInt32Parse("12", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0x12);
- passed &= VerifyInt32Parse("fF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0xFF);
- passed &= VerifyInt32Parse("5", NumberStyles.Integer, goodNFI, 5);
- passed &= VerifyInt32Parse("5.0", NumberStyles.AllowDecimalPoint, goodNFI, 5);
- passed &= VerifyInt32Parse("123", NumberStyles.Integer, germanCulture, 123);
- passed &= VerifyInt32Parse("123", NumberStyles.Integer, japaneseCulture, 123);
- passed &= VerifyInt32Parse("123.000", NumberStyles.Any, germanCulture, 123000);
- passed &= VerifyInt32Parse("123,000", NumberStyles.Any, japaneseCulture, 123000);
- passed &= VerifyInt32Parse("123,000", NumberStyles.AllowDecimalPoint, germanCulture, 123);
- passed &= VerifyInt32Parse("123.000", NumberStyles.AllowDecimalPoint, japaneseCulture, 123);
- passed &= VerifyInt32Parse("5,00" + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Any, germanCulture, 5); // currency
- //
- passed &= VerifyInt32Parse("5", NumberStyles.Integer, corruptNFI, 5);
- passed &= VerifyInt32Parse("5", NumberStyles.Number, corruptNFI, 5);
- passed &= VerifyInt32Parse("5.0", NumberStyles.Number, corruptNFI, 5);
- passed &= VerifyInt32ParseException("5,0", NumberStyles.Number, corruptNFI, typeof(FormatException));
- passed &= VerifyInt32ParseException("5.0.0", NumberStyles.Number, corruptNFI, typeof(FormatException));
- passed &= VerifyInt32Parse("$5.0", NumberStyles.Currency, corruptNFI, 5);
- passed &= VerifyInt32ParseException("$5,0", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyInt32ParseException("$5.0.0", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyInt32Parse("5.0", NumberStyles.Currency, corruptNFI, 5);
- passed &= VerifyInt32ParseException("5,0", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyInt32ParseException("5.0.0", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyInt32Parse("5.0", NumberStyles.Any, corruptNFI, 5);
- passed &= VerifyInt32ParseException("5,0", NumberStyles.Any, corruptNFI, typeof(FormatException));
- passed &= VerifyInt32ParseException("5.0.0", NumberStyles.Any, corruptNFI, typeof(FormatException));
- //
- passed &= VerifyInt32Parse("5", NumberStyles.Integer, swappedNFI, 5);
- passed &= VerifyInt32ParseException("1,234", NumberStyles.Integer, swappedNFI, typeof(FormatException));
- passed &= VerifyInt32Parse("5", NumberStyles.Number, swappedNFI, 5);
- passed &= VerifyInt32Parse("5.0", NumberStyles.Number, swappedNFI, 5);
- passed &= VerifyInt32Parse("1,234", NumberStyles.Number, swappedNFI, 1234);
- passed &= VerifyInt32Parse("1,234.0", NumberStyles.Number, swappedNFI, 1234);
- passed &= VerifyInt32ParseException("5.000.000", NumberStyles.Number, swappedNFI, typeof(FormatException));
- passed &= VerifyInt32ParseException("5.000,00", NumberStyles.Number, swappedNFI, typeof(FormatException));
- passed &= VerifyInt32Parse("5.000", NumberStyles.Currency, swappedNFI, 5); //???
- passed &= VerifyInt32ParseException("5.000,00", NumberStyles.Currency, swappedNFI, typeof(FormatException)); //???
- passed &= VerifyInt32Parse("$5.000", NumberStyles.Currency, swappedNFI, 5000);
- passed &= VerifyInt32Parse("$5.000,00", NumberStyles.Currency, swappedNFI, 5000);
- passed &= VerifyInt32Parse("5.000", NumberStyles.Any, swappedNFI, 5); //?
- passed &= VerifyInt32ParseException("5.000,00", NumberStyles.Any, swappedNFI, typeof(FormatException)); //?
- passed &= VerifyInt32Parse("$5.000", NumberStyles.Any, swappedNFI, 5000);
- passed &= VerifyInt32Parse("$5.000,00", NumberStyles.Any, swappedNFI, 5000);
- passed &= VerifyInt32Parse("5,0", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyInt32Parse("$5,0", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyInt32Parse("5,000", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyInt32Parse("$5,000", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyInt32ParseException("5,000.0", NumberStyles.Currency, swappedNFI, typeof(FormatException));
- passed &= VerifyInt32ParseException("$5,000.0", NumberStyles.Currency, swappedNFI, typeof(FormatException));
- passed &= VerifyInt32Parse("5,000", NumberStyles.Any, swappedNFI, 5);
- passed &= VerifyInt32Parse("$5,000", NumberStyles.Any, swappedNFI, 5);
- passed &= VerifyInt32ParseException("5,000.0", NumberStyles.Any, swappedNFI, typeof(FormatException));
- passed &= VerifyInt32ParseException("$5,000.0", NumberStyles.Any, swappedNFI, typeof(FormatException));
- //
- passed &= VerifyInt32Parse("5.0", NumberStyles.Number, distinctNFI, 5);
- passed &= VerifyInt32Parse("1,234.0", NumberStyles.Number, distinctNFI, 1234);
- passed &= VerifyInt32Parse("5.0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyInt32Parse("1,234.0", NumberStyles.Currency, distinctNFI, 1234);
- passed &= VerifyInt32Parse("5.0", NumberStyles.Any, distinctNFI, 5);
- passed &= VerifyInt32Parse("1,234.0", NumberStyles.Any, distinctNFI, 1234);
- passed &= VerifyInt32ParseException("$5.0", NumberStyles.Currency, distinctNFI, typeof(FormatException));
- passed &= VerifyInt32ParseException("$5.0", NumberStyles.Any, distinctNFI, typeof(FormatException));
- passed &= VerifyInt32ParseException("5:0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyInt32ParseException("5;0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyInt32ParseException("$5:0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyInt32Parse("5:0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyInt32Parse("5:000", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyInt32Parse("5;000", NumberStyles.Currency, distinctNFI, 5000);
- passed &= VerifyInt32Parse("$5:0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyInt32Parse("$5;0", NumberStyles.Currency, distinctNFI, 50);
- passed &= VerifyInt32Parse("5:0", NumberStyles.Any, distinctNFI, 5);
- passed &= VerifyInt32Parse("5;0", NumberStyles.Any, distinctNFI, 50);
- passed &= VerifyInt32Parse("$5:0", NumberStyles.Any, distinctNFI, 5);
- passed &= VerifyInt32Parse("$5;0", NumberStyles.Any, distinctNFI, 50);
- passed &= VerifyInt32ParseException("123,456;789.0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyInt32Parse("123,456;789.0", NumberStyles.Currency, distinctNFI, 123456789);
- passed &= VerifyInt32Parse("123,456;789.0", NumberStyles.Any, distinctNFI, 123456789);
- passed &= VerifyInt32ParseException("$123,456;789.0", NumberStyles.Any, distinctNFI, typeof(FormatException));
- //
- passed &= VerifyInt32ParseException("12345678912", typeof(OverflowException));
- passed &= VerifyInt32ParseException("-12345678912", typeof(OverflowException));
- passed &= VerifyInt32ParseException("3123456789", typeof(OverflowException));
- passed &= VerifyInt32ParseException("5.3", NumberStyles.AllowDecimalPoint, goodNFI, typeof(OverflowException)); //weird that it's Overflow, but consistent with v1
- passed &= VerifyInt32ParseException("Garbage", typeof(FormatException));
- passed &= VerifyInt32ParseException("5\0Garbage", typeof(FormatException));
- passed &= VerifyInt32ParseException(null, typeof(ArgumentNullException));
- passed &= VerifyInt32ParseException("893382737", NumberStyles.HexNumber, CultureInfo.InvariantCulture, typeof(OverflowException));
- passed &= VerifyInt32ParseException("5", NumberStyles.AllowHexSpecifier | NumberStyles.AllowParentheses, null, typeof(ArgumentException));
- passed &= VerifyInt32ParseException("4", (NumberStyles)(-1), typeof(ArgumentException));
- passed &= VerifyInt32ParseException("4", (NumberStyles)0x10000, typeof(ArgumentException));
- passed &= VerifyInt32ParseException("4", (NumberStyles)(-1), CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifyInt32ParseException("4", (NumberStyles)0x10000, CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifyInt32ParseException("123.000.000.000", NumberStyles.Any, germanCulture, typeof(OverflowException));
- passed &= VerifyInt32ParseException("123,000,000,000", NumberStyles.Any, japaneseCulture, typeof(OverflowException));
- passed &= VerifyInt32ParseException("123,000,000,000", NumberStyles.Integer, germanCulture, typeof(FormatException));
- passed &= VerifyInt32ParseException("123.000.000.000", NumberStyles.Integer, japaneseCulture, typeof(FormatException));
- passed &= VerifyInt32ParseException("5,00 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Integer, germanCulture, typeof(FormatException)); // currency
-
- /////////// TryParse(String)
- //// Pass cases
- passed &= VerifyInt32TryParse("5", 5, true);
- passed &= VerifyInt32TryParse("-5", -5, true);
- passed &= VerifyInt32TryParse(" 5 ", 5, true);
- passed &= VerifyInt32TryParse("5\0", 5, true);
- passed &= VerifyInt32TryParse("5 \0", 5, true);
- passed &= VerifyInt32TryParse("5\0\0\0", 5, true);
- passed &= VerifyInt32TryParse("10000", 10000, true);
- passed &= VerifyInt32TryParse("893382737", 893382737, true);
- passed &= VerifyInt32TryParse("-893382737", -893382737, true);
- passed &= VerifyInt32TryParse("1234567891", 1234567891, true);
- passed &= VerifyInt32TryParse("-1234567891", -1234567891, true);
- passed &= VerifyInt32TryParse(Int32.MaxValue.ToString(), Int32.MaxValue, true);
- passed &= VerifyInt32TryParse(Int32.MinValue.ToString(), Int32.MinValue, true);
-
- //// Fail cases
- passed &= VerifyInt32TryParse(null, 0, false);
- passed &= VerifyInt32TryParse("", 0, false);
- passed &= VerifyInt32TryParse("Garbage", 0, false);
- passed &= VerifyInt32TryParse("5\0Garbage", 0, false);
- passed &= VerifyInt32TryParse("3123456789", 0, false);
- passed &= VerifyInt32TryParse("12345678912", 0, false);
- passed &= VerifyInt32TryParse("-12345678912", 0, false);
- passed &= VerifyInt32TryParse("FF", 0, false);
- passed &= VerifyInt32TryParse("27.3", 0, false);
- passed &= VerifyInt32TryParse("23 5", 0, false);
-
-
- /////////// TryParse(TryParse(String, NumberStyles, IFormatProvider, ref Int32)
- //// Pass cases
- passed &= VerifyInt32TryParse("5", NumberStyles.Integer, CultureInfo.InvariantCulture, 5, true);
- passed &= VerifyInt32TryParse("-5", NumberStyles.Integer, CultureInfo.InvariantCulture, -5, true);
- // Variations on NumberStyles
- passed &= VerifyInt32TryParse("12", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0x12, true);
- passed &= VerifyInt32TryParse("FF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0xFF, true);
- passed &= VerifyInt32TryParse("fF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0xFF, true);
- passed &= VerifyInt32TryParse("FFFFFFFF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, -1, true);
- passed &= VerifyInt32TryParse(" 5", NumberStyles.AllowLeadingWhite, goodNFI, 5, true);
- passed &= VerifyInt32TryParse("5", NumberStyles.Number, goodNFI, 5, true);
- passed &= VerifyInt32TryParse("5.0", NumberStyles.AllowDecimalPoint, goodNFI, 5, true);
- // Variations on IFP
- passed &= VerifyInt32TryParse("5", NumberStyles.Integer, goodNFI, 5, true);
- passed &= VerifyInt32TryParse("5", NumberStyles.Integer, null, 5, true);
- passed &= VerifyInt32TryParse("5", NumberStyles.Integer, new DateTimeFormatInfo(), 5, true);
- passed &= VerifyInt32TryParse("^42", NumberStyles.Any, customNFI, -42, true);
- passed &= VerifyInt32TryParse("123", NumberStyles.Integer, germanCulture, 123, true);
- passed &= VerifyInt32TryParse("123", NumberStyles.Integer, japaneseCulture, 123, true);
- passed &= VerifyInt32TryParse("123.000", NumberStyles.Any, germanCulture, 123000, true);
- passed &= VerifyInt32TryParse("123,000", NumberStyles.Any, japaneseCulture, 123000, true);
- passed &= VerifyInt32TryParse("123,000", NumberStyles.AllowDecimalPoint, germanCulture, 123, true);
- passed &= VerifyInt32TryParse("123.000", NumberStyles.AllowDecimalPoint, japaneseCulture, 123, true);
- passed &= VerifyInt32TryParse("5,00 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Any, germanCulture, 5, true); // currency
-
- //// Fail cases
- passed &= VerifyInt32TryParse("FF", NumberStyles.Integer, CultureInfo.InvariantCulture, 0, false);
- passed &= VerifyInt32TryParse("893382737", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0, false);
- passed &= VerifyInt32TryParse("-42", NumberStyles.Any, customNFI, 0, false);
- passed &= VerifyInt32TryParse("5.3", NumberStyles.AllowDecimalPoint, goodNFI, 0, false);
- passed &= VerifyInt32TryParse("5 ", NumberStyles.AllowLeadingWhite, goodNFI, 0, false);
- passed &= VerifyInt32TryParse("123.000.000.000", NumberStyles.Any, germanCulture, 0, false);
- passed &= VerifyInt32TryParse("123,000,000,000", NumberStyles.Any, japaneseCulture, 0, false);
- passed &= VerifyInt32TryParse("123,000,000,000", NumberStyles.Integer, germanCulture, 0, false);
- passed &= VerifyInt32TryParse("123.000.000.000", NumberStyles.Integer, japaneseCulture, 0, false);
- passed &= VerifyInt32TryParse("5,00 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Integer, germanCulture, 0, false); // currency
-
- //// Exception cases
- passed &= VerifyInt32TryParseException("5", NumberStyles.AllowHexSpecifier | NumberStyles.AllowParentheses, null, typeof(ArgumentException));
- passed &= VerifyInt32TryParseException("4", (NumberStyles)(-1), CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifyInt32TryParseException("4", (NumberStyles)0x10000, CultureInfo.InvariantCulture, typeof(ArgumentException));
-
- // NumberStyles/NFI variations
- //
- //
- passed &= VerifyInt32TryParse("5", NumberStyles.Integer, corruptNFI, 5, true);
- passed &= VerifyInt32TryParse("5", NumberStyles.Number, corruptNFI, 5, true);
- passed &= VerifyInt32TryParse("5.0", NumberStyles.Number, corruptNFI, 5, true);
- passed &= VerifyInt32TryParse("5,0", NumberStyles.Number, corruptNFI, 0, false);
- passed &= VerifyInt32TryParse("5.0.0", NumberStyles.Number, corruptNFI, 0, false);
- passed &= VerifyInt32TryParse("$5.0", NumberStyles.Currency, corruptNFI, 5, true);
- passed &= VerifyInt32TryParse("$5,0", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyInt32TryParse("$5.0.0", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyInt32TryParse("5.0", NumberStyles.Currency, corruptNFI, 5, true);
- passed &= VerifyInt32TryParse("5,0", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyInt32TryParse("5.0.0", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyInt32TryParse("5.0", NumberStyles.Any, corruptNFI, 5, true);
- passed &= VerifyInt32TryParse("5,0", NumberStyles.Any, corruptNFI, 0, false);
- passed &= VerifyInt32TryParse("5.0.0", NumberStyles.Any, corruptNFI, 0, false);
- //
- passed &= VerifyInt32TryParse("5", NumberStyles.Integer, swappedNFI, 5, true);
- passed &= VerifyInt32TryParse("1,234", NumberStyles.Integer, swappedNFI, 0, false);
- passed &= VerifyInt32TryParse("5", NumberStyles.Number, swappedNFI, 5, true);
- passed &= VerifyInt32TryParse("5.0", NumberStyles.Number, swappedNFI, 5, true);
- passed &= VerifyInt32TryParse("1,234", NumberStyles.Number, swappedNFI, 1234, true);
- passed &= VerifyInt32TryParse("1,234.0", NumberStyles.Number, swappedNFI, 1234, true);
- passed &= VerifyInt32TryParse("5.000.000", NumberStyles.Number, swappedNFI, 0, false);
- passed &= VerifyInt32TryParse("5.000,00", NumberStyles.Number, swappedNFI, 0, false);
- passed &= VerifyInt32TryParse("5.000", NumberStyles.Currency, swappedNFI, 5, true); //???
- passed &= VerifyInt32TryParse("5.000,00", NumberStyles.Currency, swappedNFI, 0, false); //???
- passed &= VerifyInt32TryParse("$5.000", NumberStyles.Currency, swappedNFI, 5000, true);
- passed &= VerifyInt32TryParse("$5.000,00", NumberStyles.Currency, swappedNFI, 5000, true);
- passed &= VerifyInt32TryParse("5.000", NumberStyles.Any, swappedNFI, 5, true); //?
- passed &= VerifyInt32TryParse("5.000,00", NumberStyles.Any, swappedNFI, 0, false); //?
- passed &= VerifyInt32TryParse("$5.000", NumberStyles.Any, swappedNFI, 5000, true);
- passed &= VerifyInt32TryParse("$5.000,00", NumberStyles.Any, swappedNFI, 5000, true);
- passed &= VerifyInt32TryParse("5,0", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyInt32TryParse("$5,0", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyInt32TryParse("5,000", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyInt32TryParse("$5,000", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyInt32TryParse("5,000.0", NumberStyles.Currency, swappedNFI, 0, false);
- passed &= VerifyInt32TryParse("$5,000.0", NumberStyles.Currency, swappedNFI, 0, false);
- passed &= VerifyInt32TryParse("5,000", NumberStyles.Any, swappedNFI, 5, true);
- passed &= VerifyInt32TryParse("$5,000", NumberStyles.Any, swappedNFI, 5, true);
- passed &= VerifyInt32TryParse("5,000.0", NumberStyles.Currency, swappedNFI, 0, false);
- passed &= VerifyInt32TryParse("$5,000.0", NumberStyles.Currency, swappedNFI, 0, false);
- //
- passed &= VerifyInt32TryParse("5.0", NumberStyles.Number, distinctNFI, 5, true);
- passed &= VerifyInt32TryParse("1,234.0", NumberStyles.Number, distinctNFI, 1234, true);
- passed &= VerifyInt32TryParse("5.0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyInt32TryParse("1,234.0", NumberStyles.Currency, distinctNFI, 1234, true);
- passed &= VerifyInt32TryParse("5.0", NumberStyles.Any, distinctNFI, 5, true);
- passed &= VerifyInt32TryParse("1,234.0", NumberStyles.Any, distinctNFI, 1234, true);
- passed &= VerifyInt32TryParse("$5.0", NumberStyles.Currency, distinctNFI, 0, false);
- passed &= VerifyInt32TryParse("$5.0", NumberStyles.Any, distinctNFI, 0, false);
- passed &= VerifyInt32TryParse("5:0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyInt32TryParse("5;0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyInt32TryParse("$5:0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyInt32TryParse("5:0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyInt32TryParse("5:000", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyInt32TryParse("5;000", NumberStyles.Currency, distinctNFI, 5000, true);
- passed &= VerifyInt32TryParse("$5:0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyInt32TryParse("$5;0", NumberStyles.Currency, distinctNFI, 50, true);
- passed &= VerifyInt32TryParse("5:0", NumberStyles.Any, distinctNFI, 5, true);
- passed &= VerifyInt32TryParse("5;0", NumberStyles.Any, distinctNFI, 50, true);
- passed &= VerifyInt32TryParse("$5:0", NumberStyles.Any, distinctNFI, 5, true);
- passed &= VerifyInt32TryParse("$5;0", NumberStyles.Any, distinctNFI, 50, true);
- passed &= VerifyInt32TryParse("123,456;789.0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyInt32TryParse("123,456;789.0", NumberStyles.Currency, distinctNFI, 123456789, true);
- passed &= VerifyInt32TryParse("123,456;789.0", NumberStyles.Any, distinctNFI, 123456789, true);
- passed &= VerifyInt32TryParse("$123,456;789.0", NumberStyles.Any, distinctNFI, 0, false);
-
-
- // Should these pass or fail? Current parse behavior is to pass, so they might be
- // parse bugs, but they're not tryparse bugs.
- passed &= VerifyInt32Parse("5", NumberStyles.Float, goodNFI, 5);
- passed &= VerifyInt32TryParse("5", NumberStyles.Float, goodNFI, 5, true);
- passed &= VerifyInt32Parse("5", NumberStyles.AllowDecimalPoint, goodNFI, 5);
- passed &= VerifyInt32TryParse("5", NumberStyles.AllowDecimalPoint, goodNFI, 5, true);
- // I expect ArgumentException with an ambiguous NFI
- passed &= VerifyInt32Parse("^42", NumberStyles.Any, ambigNFI, -42);
- passed &= VerifyInt32TryParse("^42", NumberStyles.Any, ambigNFI, -42, true);
-
- /// END TEST CASES
- }
- catch (Exception e)
- {
- TestLibrary.Logging.WriteLine("Unexpected exception!! " + e.ToString());
- passed = false;
- }
-
- if (passed)
- {
- TestLibrary.Logging.WriteLine("paSs");
- return 100;
- }
- else
- {
- TestLibrary.Logging.WriteLine("FAiL");
- return 1;
- }
- }
-
- public static bool VerifyInt32TryParse(string value, Int32 expectedResult, bool expectedReturn)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Int32.TryParse, Value = '{0}', Expected Result = {1}, Expected Return = {2}",
- value, expectedResult, expectedReturn);
- }
- Int32 result = 0;
- try
- {
- bool returnValue = Int32.TryParse(value, out result);
- if (returnValue != expectedReturn)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedReturn, returnValue);
- return false;
- }
- if (result != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, result);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyInt32TryParse(string value, NumberStyles style, IFormatProvider provider, Int32 expectedResult, bool expectedReturn)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Int32.TryParse, Value = '{0}', Style = {1}, Provider = {2}, Expected Result = {3}, Expected Return = {4}",
- value, style, provider, expectedResult, expectedReturn);
- }
- Int32 result = 0;
- try
- {
- bool returnValue = Int32.TryParse(value, style, provider, out result);
- if (returnValue != expectedReturn)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Style = {1}, Provider = {2}, Expected Return = {3}, Actual Return = {4}",
- value, style, provider, expectedReturn, returnValue);
- return false;
- }
- if (result != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, result);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyInt32TryParseException(string value, NumberStyles style, IFormatProvider provider, Type exceptionType)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Int32.TryParse, Value = '{0}', Style = {1}, Provider = {2}, Expected Exception = {3}",
- value, style, provider, exceptionType);
- }
- try
- {
- Int32 result = 0;
- Boolean returnValue = Int32.TryParse(value, style, provider, out result);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifyInt32Parse(string value, Int32 expectedResult)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Int32.Parse, Value = '{0}', Expected Result, {1}",
- value, expectedResult);
- }
- try
- {
- Int32 returnValue = Int32.Parse(value);
- if (returnValue != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, returnValue);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyInt32Parse(string value, NumberStyles style, IFormatProvider provider, Int32 expectedResult)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Int32.Parse, Value = '{0}', Style = {1}, provider = {2}, Expected Result = {3}",
- value, style, provider, expectedResult);
- }
- try
- {
- Int32 returnValue = Int32.Parse(value, style, provider);
- if (returnValue != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, returnValue);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyInt32ParseException(string value, Type exceptionType)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Int32.Parse, Value = '{0}', Expected Exception, {1}",
- value, exceptionType);
- }
- try
- {
- Int32 returnValue = Int32.Parse(value);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifyInt32ParseException(string value, NumberStyles style, Type exceptionType)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Int32.Parse, Value = '{0}', Style = {1}, Expected Exception = {3}",
- value, style, exceptionType);
- }
- try
- {
- Int32 returnValue = Int32.Parse(value, style);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifyInt32ParseException(string value, NumberStyles style, IFormatProvider provider, Type exceptionType)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Int32.Parse, Value = '{0}', Style = {1}, Provider = {2}, Expected Exception = {3}",
- value, style, provider, exceptionType);
- }
- try
- {
- Int32 returnValue = Int32.Parse(value, style, provider);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-}
diff --git a/tests/src/CoreMangLib/cti/system/int16/Int16Parse1.csproj b/tests/src/CoreMangLib/cti/system/int16/Int16Parse1.csproj
deleted file mode 100644
index 5eae3b1111..0000000000
--- a/tests/src/CoreMangLib/cti/system/int16/Int16Parse1.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="int16parse1.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/int16/Int16Parse2.csproj b/tests/src/CoreMangLib/cti/system/int16/Int16Parse2.csproj
deleted file mode 100644
index b238db373e..0000000000
--- a/tests/src/CoreMangLib/cti/system/int16/Int16Parse2.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="int16parse2.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/int16/Int16Parse3.csproj b/tests/src/CoreMangLib/cti/system/int16/Int16Parse3.csproj
deleted file mode 100644
index bc7ce2713a..0000000000
--- a/tests/src/CoreMangLib/cti/system/int16/Int16Parse3.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="int16parse3.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/int16/Int16TryParse.csproj b/tests/src/CoreMangLib/cti/system/int16/Int16TryParse.csproj
deleted file mode 100644
index 4b4af63357..0000000000
--- a/tests/src/CoreMangLib/cti/system/int16/Int16TryParse.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="int16tryparse.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/int16/int16parse1.cs b/tests/src/CoreMangLib/cti/system/int16/int16parse1.cs
deleted file mode 100644
index f3816ae6e7..0000000000
--- a/tests/src/CoreMangLib/cti/system/int16/int16parse1.cs
+++ /dev/null
@@ -1,337 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-
-/// <summary>
-/// Int16.Parse(String)
-/// </summary>
-public class Int16Parse1
-{
- #region Public Methods
- public bool RunTests()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.LogInformation("[Positive]");
- retVal = PosTest1() && retVal;
- retVal = PosTest2() && retVal;
- retVal = PosTest3() && retVal;
- retVal = PosTest4() && retVal;
- retVal = PosTest5() && retVal;
-
- TestLibrary.TestFramework.LogInformation("[Negative]");
- retVal = NegTest1() && retVal;
- retVal = NegTest2() && retVal;
- retVal = NegTest3() && retVal;
- retVal = NegTest4() && retVal;
- retVal = NegTest5() && retVal;
- retVal = NegTest6() && retVal;
-
- return retVal;
- }
-
- #region Positive Test Cases
- public bool PosTest1()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest1: Normally test a random string of int16 ");
-
- try
- {
- string str = TestLibrary.Generator.GetInt16(-55).ToString();
- Int16 i1 = Int16.Parse(str);
- Int16 i2 = Convert.ToInt16(str);
- if (i1 != i2)
- {
- TestLibrary.TestFramework.LogError("001", "the result is not the value as expected, the string is " + str);
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest2()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest2: Test the int16.MaxValue");
-
- try
- {
- string str = "32767";
- Int16 i1 = Int16.Parse(str);
- if (i1 != 32767)
- {
- TestLibrary.TestFramework.LogError("003", "the result is not the value as expected ");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest3()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest3: Test the int16.MinValue");
-
- try
- {
- string str = "-32768";
- Int16 i1 = Int16.Parse(str);
- if (i1 != -32768)
- {
- TestLibrary.TestFramework.LogError("005", "the result is not the value as expected ");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest4()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest4: The argument with white space in both beginning and the end");
-
- try
- {
- string str2;
- string str = str2 = TestLibrary.Generator.GetInt16(-55).ToString();
- str = " " + str;
- str = str + " ";
- Int16 i1 = Int16.Parse(str);
- Int16 i2 = Int16.Parse(str2);
- if (i1 != i2)
- {
- TestLibrary.TestFramework.LogError("007", "the result is not the value as expected,the string is :" + str);
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("008", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest5()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest5: Test the parameter \"-0\"");
-
- try
- {
- Int16 i1 = Int16.Parse("-0");
- if (i1 != 0)
- {
- TestLibrary.TestFramework.LogError("009", "the result is not the value as expected ");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("010", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
- #endregion
-
- #region Nagetive Test Cases
- public bool NegTest1()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest1: The argument is null reference");
-
- try
- {
- string str = null;
- Int16 i1 = Int16.Parse(str);
- TestLibrary.TestFramework.LogError("101", "the Method did not throw an ArgumentNullException");
- retVal = false;
- }
- catch (ArgumentNullException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("102", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest2()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest2: Test format exception 1");
-
- try
- {
- string str = "-123-567";
- Int16 i1 = Int16.Parse(str);
- TestLibrary.TestFramework.LogError("103", "the Method did not throw a FormatException");
- retVal = false;
- }
- catch (FormatException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("104", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest3()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest3: Test format exception 2");
-
- try
- {
- string str = "98d5t6w7";
- Int16 i1 = Int16.Parse(str);
- TestLibrary.TestFramework.LogError("105", "the Method did not throw a FormatException");
- retVal = false;
- }
- catch (FormatException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("106", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest4()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest4: Test format exception 3, the string is white space");
-
- try
- {
- string str = " ";
- Int16 i1 = Int16.Parse(str);
- TestLibrary.TestFramework.LogError("107", "the Method did not throw a FormatException");
- retVal = false;
- }
- catch (FormatException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("108", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest5()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest5: The string represents a number less than int16.minvalue");
-
- try
- {
- string str = (Int16.MinValue - 1).ToString();
- Int16 i1 = Int16.Parse(str);
- TestLibrary.TestFramework.LogError("109", "the Method did not throw a OverflowException");
- retVal = false;
- }
- catch (OverflowException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("110", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest6()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest6: The string represents a number greater than int16.maxvalue");
-
- try
- {
- string str = (Int16.MaxValue + 1).ToString();
- Int16 i1 = Int16.Parse(str);
- TestLibrary.TestFramework.LogError("111", "the Method did not throw a OverflowException");
- retVal = false;
- }
- catch (OverflowException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("112", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
- #endregion
- #endregion
-
- public static int Main()
- {
- Int16Parse1 test = new Int16Parse1();
-
- TestLibrary.TestFramework.BeginTestCase("Int16Parse1");
-
- if (test.RunTests())
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("PASS");
- return 100;
- }
- else
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("FAIL");
- return 0;
- }
- }
-}
diff --git a/tests/src/CoreMangLib/cti/system/int16/int16parse2.cs b/tests/src/CoreMangLib/cti/system/int16/int16parse2.cs
deleted file mode 100644
index 958a412885..0000000000
--- a/tests/src/CoreMangLib/cti/system/int16/int16parse2.cs
+++ /dev/null
@@ -1,584 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Globalization;
-
-/// <summary>
-/// Int16.Parse(String,System.Globalization.NumberStyles)
-/// </summary>
-public class Int16Parse2
-{
- #region Privates
- private CultureInfo CurrentCulture = TestLibrary.Utilities.CurrentCulture;
- private CultureInfo customCulture = null;
- private CultureInfo CustomCulture
- {
- get
- {
- if (null == customCulture)
- {
- customCulture = new CultureInfo(CurrentCulture.Name);
- NumberFormatInfo nfi = customCulture.NumberFormat;
- //default is "," in most of the cultures, but in some cultures like DE, TR it is "."
- //nfi.NumberGroupSeparator = ",";
- nfi.NumberGroupSizes = new int[] { 3 };
- nfi.NegativeSign = "-";
- nfi.NumberNegativePattern = 1;
- customCulture.NumberFormat = nfi;
- }
- return customCulture;
- }
- }
- #endregion
-
- #region Public Methods
- public bool RunTests()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.LogInformation("[Positive]");
- retVal = PosTest1() && retVal;
- retVal = PosTest2() && retVal;
- retVal = PosTest3() && retVal;
- retVal = PosTest4() && retVal;
- retVal = PosTest5() && retVal;
- retVal = PosTest6() && retVal;
- retVal = PosTest7() && retVal;
- retVal = PosTest8() && retVal;
- retVal = PosTest9() && retVal;
- retVal = PosTest10() && retVal;
-
- TestLibrary.TestFramework.LogInformation("[Negative]");
- retVal = NegTest1() && retVal;
- retVal = NegTest2() && retVal;
- retVal = NegTest3() && retVal;
- retVal = NegTest4() && retVal;
- retVal = NegTest5() && retVal;
- retVal = NegTest6() && retVal;
- retVal = NegTest7() && retVal;
- retVal = NegTest8() && retVal;
-
- return retVal;
- }
-
- #region Positive Test Cases
- public bool PosTest1()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest1: Normally test a random string of int16 ");
-
- try
- {
- string str = TestLibrary.Generator.GetInt16().ToString();
- NumberStyles numberstyle = NumberStyles.Any;
- Int16 i1 = Int16.Parse(str, numberstyle);
- Int16 i2 = Convert.ToInt16(str);
- if (i1 != i2)
- {
- TestLibrary.TestFramework.LogError("001", "the result is not the value as expected, the string is " + str);
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest2()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest2: Test the int16.MaxValue");
-
- try
- {
- string str = "32767";
- NumberStyles numberstyle = NumberStyles.Any;
- Int16 i1 = Int16.Parse(str, numberstyle);
- if (i1 != 32767)
- {
- TestLibrary.TestFramework.LogError("003", "the result is not the value as expected ");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest3()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest3: Test the int16.MinValue");
-
- try
- {
- TestLibrary.Utilities.CurrentCulture = CustomCulture; //NegativeSign may differ
- string str = "-32768";
- NumberStyles numberstyle = NumberStyles.Any;
- Int16 i1 = Int16.Parse(str, numberstyle);
- if (i1 != -32768)
- {
- TestLibrary.TestFramework.LogError("005", "the result is not the value as expected ");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
- retVal = false;
- }
- finally
- {
- TestLibrary.Utilities.CurrentCulture = CurrentCulture;
- }
- return retVal;
- }
-
- public bool PosTest4()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest4: The argument with white space in both beginning and the end");
-
- try
- {
- string str2;
- string str = str2 = TestLibrary.Generator.GetInt16().ToString();
- str = " " + str;
- str = str + " ";
- NumberStyles numberstyle = NumberStyles.Any;
- Int16 i1 = Int16.Parse(str, numberstyle);
- Int16 i2 = Int16.Parse(str2, numberstyle);
- if (i1 != i2)
- {
- TestLibrary.TestFramework.LogError("007", "the result is not the value as expected,the string is :" + str);
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("008", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest5()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest5: Test the parameter \"-0\"");
-
- try
- {
- TestLibrary.Utilities.CurrentCulture = CustomCulture; //NegativeSign may differ
- NumberStyles numberstyle = NumberStyles.Any;
- Int16 i1 = Int16.Parse("-0", numberstyle);
- if (i1 != 0)
- {
- TestLibrary.TestFramework.LogError("009", "the result is not the value as expected ");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("010", "Unexpected exception: " + e);
- retVal = false;
- }
- finally
- {
- TestLibrary.Utilities.CurrentCulture = CurrentCulture;
- }
- return retVal;
- }
-
- public bool PosTest6()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest6: Test the parameter NumberStyles.AllowThousands");
-
- try
- {
- TestLibrary.Utilities.CurrentCulture = CustomCulture; //NumberGroupSeparator may different than ","
- string str = "32" + CustomCulture.NumberFormat.NumberGroupSeparator + "700";
- NumberStyles numberstyle = NumberStyles.AllowThousands;
- Int16 i1 = Int16.Parse(str, numberstyle);
- if (i1 != 32700)
- {
- TestLibrary.TestFramework.LogError("011", "the result is not the value as expected ");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("012", "Unexpected exception: " + e);
- retVal = false;
- }
- finally
- {
- TestLibrary.Utilities.CurrentCulture = CurrentCulture;
- }
- return retVal;
- }
-
- public bool PosTest7()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest7: Test the parameter NumberStyles.AllowParentheses");
-
- try
- {
- Int16 int16 = TestLibrary.Generator.GetInt16();
- string str = "(" + int16.ToString() + ")";
- NumberStyles numberstyle = NumberStyles.AllowParentheses;
- Int16 i1 = Int16.Parse(str, numberstyle);
- if (i1 != (-int16))
- {
- TestLibrary.TestFramework.LogError("013", "the result is not the value as expected,the int16 is: " + int16);
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("014", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest8()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest8: The string with white space in both the beginning and the end");
-
- try
- {
- Int16 int16 = TestLibrary.Generator.GetInt16();
- string str = " " + int16.ToString() + " ";
- NumberStyles numberstyle = NumberStyles.AllowLeadingWhite | System.Globalization.NumberStyles.AllowTrailingWhite;
- Int16 i1 = Int16.Parse(str, numberstyle);
- if (i1 != int16)
- {
- TestLibrary.TestFramework.LogError("015", "the result is not the value as expected ");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("016", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest9()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest9: Test the parameters NumberStyles.AllowTrailingSign");
-
- try
- {
- TestLibrary.Utilities.CurrentCulture = CustomCulture; //NegativeSign may be different
- string str = "8765-";
- NumberStyles numberstyle = NumberStyles.AllowTrailingSign;
- Int16 i1 = Int16.Parse(str, numberstyle);
- if (i1 != -8765)
- {
- TestLibrary.TestFramework.LogError("017", "the result is not the value as expected ");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("018", "Unexpected exception: " + e);
- retVal = false;
- }
- finally
- {
- TestLibrary.Utilities.CurrentCulture = CurrentCulture; //NegativeSign may be different
- }
- return retVal;
- }
-
- public bool PosTest10()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest10: Test the parameters NumberStyles.HexNumber");
-
- try
- {
- string str = "5e81";
- NumberStyles numberstyle = NumberStyles.HexNumber;
- Int16 i1 = Int16.Parse(str, numberstyle);
- if (i1 != 24193)
- {
- TestLibrary.TestFramework.LogError("019", "the result is not the value as expected ");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("020", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
- #endregion
-
- #region Nagetive Test Cases
- public bool NegTest1()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest1: The argument is null reference");
-
- try
- {
- string str = null;
- NumberStyles numberstyle = NumberStyles.Any;
- Int16 i1 = Int16.Parse(str, numberstyle);
- TestLibrary.TestFramework.LogError("101", "the Method did not throw an ArgumentNullException");
- retVal = false;
- }
- catch (ArgumentNullException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("102", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest2()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest2: Test format exception 1");
-
- try
- {
- TestLibrary.Utilities.CurrentCulture = CustomCulture; //NegativeSign may be different
- string str = "-123567";
- NumberStyles numberstyle = NumberStyles.AllowTrailingSign;
- Int16 i1 = Int16.Parse(str, numberstyle);
- TestLibrary.TestFramework.LogError("103", "the Method did not throw a FormatException");
- retVal = false;
- }
- catch (FormatException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("104", "Unexpected exception: " + e);
- retVal = false;
- }
- finally
- {
- TestLibrary.Utilities.CurrentCulture = CurrentCulture;
- }
- return retVal;
- }
-
- public bool NegTest3()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest3: Test format exception 2");
-
- try
- {
- string str = "98d5t6w7";
- NumberStyles numberstyle = NumberStyles.Currency;
- Int16 i1 = Int16.Parse(str, numberstyle);
- TestLibrary.TestFramework.LogError("105", "the Method did not throw a FormatException");
- retVal = false;
- }
- catch (FormatException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("106", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest4()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest4: Test format exception 3, the string is white space");
-
- try
- {
- string str = " ";
- NumberStyles numberstyle = NumberStyles.None;
- Int16 i1 = Int16.Parse(str, numberstyle);
- TestLibrary.TestFramework.LogError("107", "the Method did not throw a FormatException");
- retVal = false;
- }
- catch (FormatException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("108", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest5()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest5: The string represents a number less than int16.minvalue");
-
- try
- {
- string str = (Int16.MinValue - 1).ToString();
- NumberStyles numberstyle = NumberStyles.Currency;
- Int16 i1 = Int16.Parse(str, numberstyle);
- TestLibrary.TestFramework.LogError("109", "the Method did not throw a OverflowException");
- retVal = false;
- }
- catch (OverflowException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("110", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest6()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest6: The string represents a number greater than int16.maxvalue");
-
- try
- {
- string str = (Int16.MaxValue + 1).ToString();
- NumberStyles numberstyle = NumberStyles.Currency;
- Int16 i1 = Int16.Parse(str, numberstyle);
- TestLibrary.TestFramework.LogError("111", "the Method did not throw a OverflowException");
- retVal = false;
- }
- catch (OverflowException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("112", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest7()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest7: style is not a NumberStyles value");
-
- try
- {
- string str = TestLibrary.Generator.GetInt16().ToString();
- int i2 = 24568;
- NumberStyles numberstyle = (NumberStyles)i2;
- Int16 i1 = Int16.Parse(str, numberstyle);
- TestLibrary.TestFramework.LogError("113", "the Method did not throw an ArgumentException,the string is:" + str);
- retVal = false;
- }
- catch (ArgumentException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("114", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest8()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest8: style is not a combination of AllowHexSpecifier and HexNumber");
-
- try
- {
- string str = "1df6";
- NumberStyles numberstyle = NumberStyles.HexNumber | NumberStyles.AllowTrailingSign;
- Int16 i1 = Int16.Parse(str, numberstyle);
- TestLibrary.TestFramework.LogError("115", "the Method did not throw an ArgumentException,the string is:");
- retVal = false;
- }
- catch (ArgumentException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("116", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
- #endregion
- #endregion
-
- public static int Main()
- {
- Int16Parse2 test = new Int16Parse2();
-
- TestLibrary.TestFramework.BeginTestCase("Int16Parse2");
-
- if (test.RunTests())
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("PASS");
- return 100;
- }
- else
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("FAIL");
- return 0;
- }
- }
-}
diff --git a/tests/src/CoreMangLib/cti/system/int16/int16parse3.cs b/tests/src/CoreMangLib/cti/system/int16/int16parse3.cs
deleted file mode 100644
index 1d889db032..0000000000
--- a/tests/src/CoreMangLib/cti/system/int16/int16parse3.cs
+++ /dev/null
@@ -1,454 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Globalization;
-
-/// <summary>
-/// Int16.Parse(string,numberstyle,iformatprovider)
-/// </summary>
-public class Int16Parse3
-{
- #region Privates
- private CultureInfo CurrentCulture = TestLibrary.Utilities.CurrentCulture;
- private CultureInfo customCulture = null;
- private CultureInfo CustomCulture
- {
- get
- {
- if (null == customCulture)
- {
- customCulture = new CultureInfo(CurrentCulture.Name);
- NumberFormatInfo nfi = customCulture.NumberFormat;
- nfi.NumberGroupSeparator = ",";
- nfi.NumberGroupSizes = new int[] { 3 };
- nfi.NegativeSign = "-";
- nfi.NumberNegativePattern = 1;
- customCulture.NumberFormat = nfi;
- }
- return customCulture;
- }
- }
- #endregion
-
- #region Public Methods
- public bool RunTests()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.LogInformation("[Positive]");
- retVal = PosTest1() && retVal;
- retVal = PosTest2() && retVal;
- retVal = PosTest3() && retVal;
- retVal = PosTest4() && retVal;
- retVal = PosTest5() && retVal;
- retVal = PosTest6() && retVal;
-
- TestLibrary.TestFramework.LogInformation("[Negative]");
- retVal = NegTest1() && retVal;
- retVal = NegTest2() && retVal;
- retVal = NegTest3() && retVal;
- retVal = NegTest4() && retVal;
- retVal = NegTest5() && retVal;
- retVal = NegTest6() && retVal;
- retVal = NegTest7() && retVal;
- retVal = NegTest8() && retVal;
-
- return retVal;
- }
-
- #region Positive Test Cases
- public bool PosTest1()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest1:Test the method with the cultureinfo parameter which implemented the IFormatProvider interface ");
-
- try
- {
- string s1 = "1,000";
- int i1 = Int16.Parse(s1, System.Globalization.NumberStyles.AllowThousands, CustomCulture);
- if (i1 != 1000)
- {
- TestLibrary.TestFramework.LogError("001", "The result is not the value as expected. ");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest2()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest2:Test the method with the numberformatinfo parameter which implemented the IFormatProvider interface ");
-
- try
- {
- TestLibrary.Utilities.CurrentCulture = CustomCulture; //Parse uses CurrentCulture since numberFormatInfo is created without any parameter.
- string s1 = " 3,000 ";
- int i1 = Int16.Parse(s1, System.Globalization.NumberStyles.AllowThousands | System.Globalization.NumberStyles.AllowLeadingWhite | System.Globalization.NumberStyles.AllowTrailingWhite, new NumberFormatInfo());
- if (i1 != 3000)
- {
- TestLibrary.TestFramework.LogError("003", "The result is not the value as expected. ");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
- retVal = false;
- }
- finally
- {
- TestLibrary.Utilities.CurrentCulture = CurrentCulture;
- }
- return retVal;
- }
-
- public bool PosTest3()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest3:Test the method with the DateTimeFormatInfo parameter which implemented the IFormatProvider interface ");
-
- try
- {
- TestLibrary.Utilities.CurrentCulture = CustomCulture;
- string s1 = "-16,466";
- int i1 = Int16.Parse(s1, System.Globalization.NumberStyles.AllowThousands | System.Globalization.NumberStyles.AllowLeadingSign, new DateTimeFormatInfo());
- if (i1 != -16466)
- {
- TestLibrary.TestFramework.LogError("005", "The result is not the value as expected. ");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
- retVal = false;
- }
- finally
- {
- TestLibrary.Utilities.CurrentCulture = CurrentCulture;
- }
- return retVal;
- }
-
- public bool PosTest4()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest4: Test special string \"-3.456\" using the cultureinfo parameter");
-
- try
- {
- string s1 = "-3.456";
- int i1 = Int16.Parse(s1, System.Globalization.NumberStyles.AllowThousands | System.Globalization.NumberStyles.AllowLeadingSign, new CultureInfo("pt-BR"));
- if (i1 != -3456)
- {
- TestLibrary.TestFramework.LogError("007", "The result is not the value as expected. ");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("008", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest5()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest5: Test special string \" 3 01 78\" using the cultureinfo parameter");
-
- try
- {
- string s1 = " 3 01 78";
- NumberFormatInfo nfi = new CultureInfo("pt-BR").NumberFormat;
- nfi.NumberGroupSizes = new int[] { 2 };
- nfi.NumberGroupSeparator = " ";
- int i1 = Int16.Parse(s1, System.Globalization.NumberStyles.AllowThousands | System.Globalization.NumberStyles.AllowLeadingWhite, nfi);
- if (i1 != 30178)
- {
- TestLibrary.TestFramework.LogError("009", "The result is not the value as expected. ");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("010", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool PosTest6()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("PosTest6: Using the null reference as the third parameter IFormatProvider");
-
- try
- {
- string s1 = " 3678";
- int i1 = Int16.Parse(s1, System.Globalization.NumberStyles.AllowThousands | System.Globalization.NumberStyles.AllowLeadingWhite, null);
- if (i1 != 3678)
- {
- TestLibrary.TestFramework.LogError("011", "The result is not the value as expected. ");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("012", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
- #endregion
-
- #region Nagetive Test Cases
- public bool NegTest1()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest1: The argument is null reference");
-
- try
- {
- string str = null;
- NumberStyles numberstyle = NumberStyles.Any;
- Int16 i1 = Int16.Parse(str, numberstyle, new CultureInfo("en-US"));
- TestLibrary.TestFramework.LogError("101", "the Method did not throw an ArgumentNullException");
- retVal = false;
- }
- catch (ArgumentNullException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("102", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest2()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest2: Test format exception 1");
-
- try
- {
- string str = "-123567";
- NumberStyles numberstyle = NumberStyles.AllowTrailingSign;
- Int16 i1 = Int16.Parse(str, numberstyle, CustomCulture);
- TestLibrary.TestFramework.LogError("103", "the Method did not throw a FormatException");
- retVal = false;
- }
- catch (FormatException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("104", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest3()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest3: Test format exception 2");
-
- try
- {
- string str = "98d5t6w7";
- NumberStyles numberstyle = NumberStyles.Currency;
- Int16 i1 = Int16.Parse(str, numberstyle, new CultureInfo("en-US"));
- TestLibrary.TestFramework.LogError("105", "the Method did not throw a FormatException");
- retVal = false;
- }
- catch (FormatException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("106", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest4()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest4: Test format exception 3, the string is white space");
-
- try
- {
- string str = " ";
- NumberStyles numberstyle = NumberStyles.None;
- Int16 i1 = Int16.Parse(str, numberstyle, new CultureInfo("en-US"));
- TestLibrary.TestFramework.LogError("107", "the Method did not throw a FormatException");
- retVal = false;
- }
- catch (FormatException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("108", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest5()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest5: The string represents a number less than int16.minvalue");
-
- try
- {
- string str = (Int16.MinValue - 1).ToString();
- NumberStyles numberstyle = NumberStyles.Currency;
- Int16 i1 = Int16.Parse(str, numberstyle, new CultureInfo("en-US"));
- TestLibrary.TestFramework.LogError("109", "the Method did not throw a OverflowException");
- retVal = false;
- }
- catch (OverflowException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("110", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest6()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest6: The string represents a number greater than int16.maxvalue");
-
- try
- {
- string str = (Int16.MaxValue + 1).ToString();
- NumberStyles numberstyle = NumberStyles.Currency;
- Int16 i1 = Int16.Parse(str, numberstyle, new CultureInfo("en-US"));
- TestLibrary.TestFramework.LogError("111", "the Method did not throw a OverflowException");
- retVal = false;
- }
- catch (OverflowException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("112", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest7()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest7: style is not a NumberStyles value");
-
- try
- {
- string str = TestLibrary.Generator.GetInt16().ToString();
- int i2 = 24568;
- NumberStyles numberstyle = (NumberStyles)i2;
- Int16 i1 = Int16.Parse(str, numberstyle, new CultureInfo("en-US"));
- TestLibrary.TestFramework.LogError("113", "the Method did not throw an ArgumentException,the string is:" + str);
- retVal = false;
- }
- catch (ArgumentException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("114", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
-
- public bool NegTest8()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.BeginScenario("NegTest8: style is not a combination of AllowHexSpecifier and HexNumber");
-
- try
- {
- string str = "1df6";
- NumberStyles numberstyle = NumberStyles.HexNumber | NumberStyles.AllowTrailingSign;
- Int16 i1 = Int16.Parse(str, numberstyle, new CultureInfo("en-US"));
- TestLibrary.TestFramework.LogError("115", "the Method did not throw an ArgumentException,the string is:");
- retVal = false;
- }
- catch (ArgumentException)
- {
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("116", "Unexpected exception: " + e);
- retVal = false;
- }
-
- return retVal;
- }
- #endregion
- #endregion
-
- public static int Main()
- {
- Int16Parse3 test = new Int16Parse3();
-
- TestLibrary.TestFramework.BeginTestCase("Int16Parse3");
-
- if (test.RunTests())
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("PASS");
- return 100;
- }
- else
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("FAIL");
- return 0;
- }
- }
-}
diff --git a/tests/src/CoreMangLib/cti/system/int16/int16tryparse.cs b/tests/src/CoreMangLib/cti/system/int16/int16tryparse.cs
deleted file mode 100644
index 58e14bcffe..0000000000
--- a/tests/src/CoreMangLib/cti/system/int16/int16tryparse.cs
+++ /dev/null
@@ -1,553 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Globalization;
-
-// Ported to CoreCLR from Co7525TryParse_all.cs
-// Tests Int16.TryParse(String), Int16.TryParse(String, NumberStyles, IFormatProvider, ref Int16)
-// 2003/04/01 KatyK
-// 2007/06/28 adapted by MarielY
-
-public class Int16TryParse
-{
- static bool verbose = false;
-
- public static int Main()
- {
- bool passed = true;
-
- try
- {
- // Make the test culture independent
- TestLibrary.Utilities.CurrentCulture = CultureInfo.InvariantCulture;
-
- // Set up NFIs to use
- NumberFormatInfo goodNFI = new NumberFormatInfo();
-
- NumberFormatInfo corruptNFI = new NumberFormatInfo(); // DecimalSeparator == GroupSeparator
- corruptNFI.NumberDecimalSeparator = ".";
- corruptNFI.NumberGroupSeparator = ".";
- corruptNFI.CurrencyDecimalSeparator = ".";
- corruptNFI.CurrencyGroupSeparator = ".";
- corruptNFI.CurrencySymbol = "$";
-
- NumberFormatInfo swappedNFI = new NumberFormatInfo(); // DecimalSeparator & GroupSeparator swapped
- swappedNFI.NumberDecimalSeparator = ".";
- swappedNFI.NumberGroupSeparator = ",";
- swappedNFI.CurrencyDecimalSeparator = ",";
- swappedNFI.CurrencyGroupSeparator = ".";
- swappedNFI.CurrencySymbol = "$";
-
- NumberFormatInfo distinctNFI = new NumberFormatInfo(); // DecimalSeparator & GroupSeparator distinct
- distinctNFI.NumberDecimalSeparator = ".";
- distinctNFI.NumberGroupSeparator = ",";
- distinctNFI.CurrencyDecimalSeparator = ":";
- distinctNFI.CurrencyGroupSeparator = ";";
- distinctNFI.CurrencySymbol = "$";
-
- NumberFormatInfo customNFI = new NumberFormatInfo();
- customNFI.NegativeSign = "^";
-
- NumberFormatInfo ambigNFI = new NumberFormatInfo();
- ambigNFI.NegativeSign = "^";
- ambigNFI.CurrencySymbol = "^";
-
- CultureInfo germanCulture = new CultureInfo("de-DE");
- CultureInfo japaneseCulture;
-
- try
- {
- japaneseCulture = new CultureInfo("ja-JP");
- }
- catch (Exception)
- {
- TestLibrary.Logging.WriteLine("East Asian Languages are not installed. Skiping Japanese culture tests.");
- japaneseCulture = null;
- }
-
- // Parse tests included for comparison/regression
- passed &= VerifyInt16Parse("5", 5);
- passed &= VerifyInt16Parse("-5", -5);
- passed &= VerifyInt16Parse("5 ", 5);
- passed &= VerifyInt16Parse("5\0", 5);
- passed &= VerifyInt16Parse("10000", 10000);
- passed &= VerifyInt16Parse("-10000", -10000);
- passed &= VerifyInt16Parse("5", NumberStyles.Integer, CultureInfo.InvariantCulture, 5);
- passed &= VerifyInt16Parse("-5", NumberStyles.Integer, CultureInfo.InvariantCulture, -5);
- passed &= VerifyInt16Parse("5 \0", NumberStyles.Integer, CultureInfo.InvariantCulture, 5);
- passed &= VerifyInt16Parse("5\0\0\0", NumberStyles.Integer, CultureInfo.InvariantCulture, 5);
- passed &= VerifyInt16Parse("12", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0x12);
- passed &= VerifyInt16Parse("fF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0xFF);
- passed &= VerifyInt16Parse("fFFF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, -1);
- passed &= VerifyInt16Parse("123", NumberStyles.Integer, germanCulture, 123);
- passed &= VerifyInt16Parse("123", NumberStyles.Integer, japaneseCulture, 123);
- passed &= VerifyInt16Parse("123,000", NumberStyles.AllowDecimalPoint, germanCulture, 123);
- passed &= VerifyInt16Parse("123.000", NumberStyles.AllowDecimalPoint, japaneseCulture, 123);
- passed &= VerifyInt16Parse("5,00 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Any, germanCulture, 5); // currency
- passed &= VerifyInt16Parse("5", NumberStyles.Integer, goodNFI, 5);
- //
- passed &= VerifyInt16Parse("5", NumberStyles.Integer, corruptNFI, 5);
- passed &= VerifyInt16Parse("5", NumberStyles.Number, corruptNFI, 5);
- passed &= VerifyInt16Parse("5.0", NumberStyles.Number, corruptNFI, 5);
- passed &= VerifyInt16ParseException("5,0", NumberStyles.Number, corruptNFI, typeof(FormatException));
- passed &= VerifyInt16ParseException("5.0.0", NumberStyles.Number, corruptNFI, typeof(FormatException));
- passed &= VerifyInt16Parse("$5.0", NumberStyles.Currency, corruptNFI, 5);
- passed &= VerifyInt16ParseException("$5,0", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyInt16ParseException("$5.0.0", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyInt16Parse("5.0", NumberStyles.Currency, corruptNFI, 5);
- passed &= VerifyInt16ParseException("5,0", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyInt16ParseException("5.0.0", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyInt16Parse("5.0", NumberStyles.Any, corruptNFI, 5);
- passed &= VerifyInt16ParseException("5,0", NumberStyles.Any, corruptNFI, typeof(FormatException));
- passed &= VerifyInt16ParseException("5.0.0", NumberStyles.Any, corruptNFI, typeof(FormatException));
- //
- passed &= VerifyInt16Parse("5", NumberStyles.Integer, swappedNFI, 5);
- passed &= VerifyInt16ParseException("1,234", NumberStyles.Integer, swappedNFI, typeof(FormatException));
- passed &= VerifyInt16Parse("5", NumberStyles.Number, swappedNFI, 5);
- passed &= VerifyInt16Parse("5.0", NumberStyles.Number, swappedNFI, 5);
- passed &= VerifyInt16Parse("1,234", NumberStyles.Number, swappedNFI, 1234);
- passed &= VerifyInt16Parse("1,234.0", NumberStyles.Number, swappedNFI, 1234);
- passed &= VerifyInt16ParseException("5.000.000", NumberStyles.Number, swappedNFI, typeof(FormatException));
- passed &= VerifyInt16ParseException("5.000,00", NumberStyles.Number, swappedNFI, typeof(FormatException));
- passed &= VerifyInt16Parse("5.000", NumberStyles.Currency, swappedNFI, 5); //???
- passed &= VerifyInt16ParseException("5.000,00", NumberStyles.Currency, swappedNFI, typeof(FormatException)); //???
- passed &= VerifyInt16Parse("$5.000", NumberStyles.Currency, swappedNFI, 5000);
- passed &= VerifyInt16Parse("$5.000,00", NumberStyles.Currency, swappedNFI, 5000);
- passed &= VerifyInt16Parse("5.000", NumberStyles.Any, swappedNFI, 5); //?
- passed &= VerifyInt16Parse("$5.000", NumberStyles.Any, swappedNFI, 5000);
- passed &= VerifyInt16ParseException("5.000,00", NumberStyles.Any, swappedNFI, typeof(FormatException)); //?
- passed &= VerifyInt16Parse("$5.000", NumberStyles.Any, swappedNFI, 5000);
- passed &= VerifyInt16Parse("$5.000,00", NumberStyles.Any, swappedNFI, 5000);
- passed &= VerifyInt16Parse("5,0", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyInt16Parse("$5,0", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyInt16Parse("5,000", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyInt16Parse("$5,000", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyInt16ParseException("5,000.0", NumberStyles.Currency, swappedNFI, typeof(FormatException));
- passed &= VerifyInt16ParseException("$5,000.0", NumberStyles.Currency, swappedNFI, typeof(FormatException));
- passed &= VerifyInt16Parse("5,000", NumberStyles.Any, swappedNFI, 5);
- passed &= VerifyInt16Parse("$5,000", NumberStyles.Any, swappedNFI, 5);
- //
- passed &= VerifyInt16Parse("5.0", NumberStyles.Number, distinctNFI, 5);
- passed &= VerifyInt16Parse("1,234.0", NumberStyles.Number, distinctNFI, 1234);
- passed &= VerifyInt16Parse("5.0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyInt16Parse("1,234.0", NumberStyles.Currency, distinctNFI, 1234);
- passed &= VerifyInt16Parse("5.0", NumberStyles.Any, distinctNFI, 5);
- passed &= VerifyInt16Parse("1,234.0", NumberStyles.Any, distinctNFI, 1234);
- passed &= VerifyInt16ParseException("$5.0", NumberStyles.Currency, distinctNFI, typeof(FormatException));
- passed &= VerifyInt16ParseException("$5.0", NumberStyles.Any, distinctNFI, typeof(FormatException));
- passed &= VerifyInt16ParseException("5:0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyInt16ParseException("5;0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyInt16ParseException("$5:0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyInt16Parse("5:0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyInt16Parse("5:000", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyInt16Parse("5;000", NumberStyles.Currency, distinctNFI, 5000);
- passed &= VerifyInt16Parse("$5:0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyInt16Parse("$5;0", NumberStyles.Currency, distinctNFI, 50);
- passed &= VerifyInt16Parse("5:0", NumberStyles.Any, distinctNFI, 5);
- passed &= VerifyInt16Parse("5;0", NumberStyles.Any, distinctNFI, 50);
- passed &= VerifyInt16Parse("$5:0", NumberStyles.Any, distinctNFI, 5);
- passed &= VerifyInt16Parse("$5;0", NumberStyles.Any, distinctNFI, 50);
- passed &= VerifyInt16ParseException("1,23;45.0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyInt16Parse("1,23;45.0", NumberStyles.Currency, distinctNFI, 12345);
- passed &= VerifyInt16Parse("1,23;45.0", NumberStyles.Any, distinctNFI, 12345);
- passed &= VerifyInt16ParseException("$1,23;45.0", NumberStyles.Any, distinctNFI, typeof(FormatException));
- //
- passed &= VerifyInt16ParseException("100000", typeof(OverflowException));
- passed &= VerifyInt16ParseException("-100000", typeof(OverflowException));
- passed &= VerifyInt16ParseException("Garbage", typeof(FormatException));
- passed &= VerifyInt16ParseException("5\0Garbage", typeof(FormatException));
- passed &= VerifyInt16ParseException(null, typeof(ArgumentNullException));
- passed &= VerifyInt16ParseException("1FFFF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, typeof(OverflowException));
- passed &= VerifyInt16ParseException("FFFFFFFF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, typeof(OverflowException));
- passed &= VerifyInt16ParseException("5", NumberStyles.AllowHexSpecifier | NumberStyles.AllowParentheses, null, typeof(ArgumentException));
- passed &= VerifyInt16ParseException("4", (NumberStyles)(-1), typeof(ArgumentException));
- passed &= VerifyInt16ParseException("4", (NumberStyles)0x10000, typeof(ArgumentException));
- passed &= VerifyInt16ParseException("4", (NumberStyles)(-1), CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifyInt16ParseException("4", (NumberStyles)0x10000, CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifyInt16ParseException("123.000", NumberStyles.Any, germanCulture, typeof(OverflowException));
- passed &= VerifyInt16ParseException("123,000", NumberStyles.Any, japaneseCulture, typeof(OverflowException));
- passed &= VerifyInt16ParseException("123,000", NumberStyles.Integer, germanCulture, typeof(FormatException));
- passed &= VerifyInt16ParseException("123.000", NumberStyles.Integer, japaneseCulture, typeof(FormatException));
- passed &= VerifyInt16ParseException("5,00 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Integer, germanCulture, typeof(FormatException)); // currency
-
- /////////// TryParse(String)
- //// Pass cases
- passed &= VerifyInt16TryParse("5", 5, true);
- passed &= VerifyInt16TryParse("-5", -5, true);
- passed &= VerifyInt16TryParse(" 5 ", 5, true);
- passed &= VerifyInt16TryParse("5\0", 5, true);
- passed &= VerifyInt16TryParse("5 \0", 5, true);
- passed &= VerifyInt16TryParse("5\0\0\0", 5, true);
- passed &= VerifyInt16TryParse("10000", 10000, true);
- passed &= VerifyInt16TryParse("-10000", -10000, true);
- passed &= VerifyInt16TryParse(Int16.MaxValue.ToString(), Int16.MaxValue, true);
- passed &= VerifyInt16TryParse(Int16.MinValue.ToString(), Int16.MinValue, true);
-
- //// Fail cases
- passed &= VerifyInt16TryParse(null, 0, false);
- passed &= VerifyInt16TryParse("", 0, false);
- passed &= VerifyInt16TryParse("Garbage", 0, false);
- passed &= VerifyInt16TryParse("5\0Garbage", 0, false);
- passed &= VerifyInt16TryParse("100000", 0, false);
- passed &= VerifyInt16TryParse("-100000", 0, false);
- passed &= VerifyInt16TryParse("FF", 0, false);
- passed &= VerifyInt16TryParse("27.3", 0, false);
- passed &= VerifyInt16TryParse("23 5", 0, false);
-
-
- /////////// TryParse(TryParse(String, NumberStyles, IFormatProvider, ref Int16)
- //// Pass cases
- passed &= VerifyInt16TryParse("5", NumberStyles.Integer, CultureInfo.InvariantCulture, 5, true);
- passed &= VerifyInt16TryParse("-5", NumberStyles.Integer, CultureInfo.InvariantCulture, -5, true);
- // Variations on NumberStyles
- passed &= VerifyInt16TryParse("12", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0x12, true);
- passed &= VerifyInt16TryParse("FF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0xFF, true);
- passed &= VerifyInt16TryParse("fF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0xFF, true);
- passed &= VerifyInt16TryParse("fFFF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, -1, true);
- passed &= VerifyInt16TryParse(" 5", NumberStyles.AllowLeadingWhite, goodNFI, 5, true);
- passed &= VerifyInt16TryParse("5", NumberStyles.Number, goodNFI, 5, true);
- // Variations on IFP
- passed &= VerifyInt16TryParse("5", NumberStyles.Integer, goodNFI, 5, true);
- passed &= VerifyInt16TryParse("5", NumberStyles.Integer, null, 5, true);
- passed &= VerifyInt16TryParse("5", NumberStyles.Integer, new DateTimeFormatInfo(), 5, true);
- passed &= VerifyInt16TryParse("^42", NumberStyles.Any, customNFI, -42, true);
- passed &= VerifyInt16TryParse("123", NumberStyles.Integer, germanCulture, 123, true);
- passed &= VerifyInt16TryParse("123", NumberStyles.Integer, japaneseCulture, 123, true);
- passed &= VerifyInt16TryParse("123,000", NumberStyles.AllowDecimalPoint, germanCulture, 123, true);
- passed &= VerifyInt16TryParse("123.000", NumberStyles.AllowDecimalPoint, japaneseCulture, 123, true);
- passed &= VerifyInt16TryParse("5,00 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Any, germanCulture, 5, true); // currency
-
- //// Fail cases
- passed &= VerifyInt16TryParse("FF", NumberStyles.Integer, CultureInfo.InvariantCulture, 0, false);
- passed &= VerifyInt16TryParse("1FFFF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0, false);
- passed &= VerifyInt16TryParse("FFFFFFFF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0, false);
- passed &= VerifyInt16TryParse("-42", NumberStyles.Any, customNFI, 0, false);
- passed &= VerifyInt16TryParse("5.3", NumberStyles.AllowDecimalPoint, goodNFI, 0, false);
- passed &= VerifyInt16TryParse("5 ", NumberStyles.AllowLeadingWhite, goodNFI, 0, false);
- passed &= VerifyInt16TryParse("123.000", NumberStyles.Any, germanCulture, 0, false);
- passed &= VerifyInt16TryParse("123,000", NumberStyles.Any, japaneseCulture, 0, false);
- passed &= VerifyInt16TryParse("123,000", NumberStyles.Integer, germanCulture, 0, false);
- passed &= VerifyInt16TryParse("123.000", NumberStyles.Integer, japaneseCulture, 0, false);
- passed &= VerifyInt16TryParse("5,00 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Integer, germanCulture, 0, false); // currency
-
- //// Exception cases
- passed &= VerifyInt16TryParseException("5", NumberStyles.AllowHexSpecifier | NumberStyles.AllowParentheses, null, typeof(ArgumentException));
- passed &= VerifyInt16TryParseException("4", (NumberStyles)(-1), CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifyInt16TryParseException("4", (NumberStyles)0x10000, CultureInfo.InvariantCulture, typeof(ArgumentException));
-
- // NumberStyles/NFI variations
- //
- passed &= VerifyInt16TryParse("5", NumberStyles.Integer, corruptNFI, 5, true);
- passed &= VerifyInt16TryParse("5", NumberStyles.Number, corruptNFI, 5, true);
- passed &= VerifyInt16TryParse("5.0", NumberStyles.Number, corruptNFI, 5, true);
- passed &= VerifyInt16TryParse("5,0", NumberStyles.Number, corruptNFI, 0, false);
- passed &= VerifyInt16TryParse("5.0.0", NumberStyles.Number, corruptNFI, 0, false);
- passed &= VerifyInt16TryParse("$5.0", NumberStyles.Currency, corruptNFI, 5, true);
- passed &= VerifyInt16TryParse("$5,0", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyInt16TryParse("$5.0.0", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyInt16TryParse("5.0", NumberStyles.Currency, corruptNFI, 5, true);
- passed &= VerifyInt16TryParse("5,0", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyInt16TryParse("5.0.0", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyInt16TryParse("5.0", NumberStyles.Any, corruptNFI, 5, true);
- passed &= VerifyInt16TryParse("5,0", NumberStyles.Any, corruptNFI, 0, false);
- passed &= VerifyInt16TryParse("5.0.0", NumberStyles.Any, corruptNFI, 0, false);
- //
- passed &= VerifyInt16TryParse("5", NumberStyles.Integer, swappedNFI, 5, true);
- passed &= VerifyInt16TryParse("1,234", NumberStyles.Integer, swappedNFI, 0, false);
- passed &= VerifyInt16TryParse("5", NumberStyles.Number, swappedNFI, 5, true);
- passed &= VerifyInt16TryParse("5.0", NumberStyles.Number, swappedNFI, 5, true);
- passed &= VerifyInt16TryParse("1,234", NumberStyles.Number, swappedNFI, 1234, true);
- passed &= VerifyInt16TryParse("1,234.0", NumberStyles.Number, swappedNFI, 1234, true);
- passed &= VerifyInt16TryParse("5.000.000", NumberStyles.Number, swappedNFI, 0, false);
- passed &= VerifyInt16TryParse("5.000,00", NumberStyles.Number, swappedNFI, 0, false);
- passed &= VerifyInt16TryParse("5.000", NumberStyles.Currency, swappedNFI, 5, true); //???
- passed &= VerifyInt16TryParse("5.000,00", NumberStyles.Currency, swappedNFI, 0, false); //???
- passed &= VerifyInt16TryParse("$5.000", NumberStyles.Currency, swappedNFI, 5000, true);
- passed &= VerifyInt16TryParse("$5.000,00", NumberStyles.Currency, swappedNFI, 5000, true);
- passed &= VerifyInt16TryParse("5.000", NumberStyles.Any, swappedNFI, 5, true); //?
- passed &= VerifyInt16TryParse("5.000,00", NumberStyles.Any, swappedNFI, 0, false); //?
- passed &= VerifyInt16TryParse("$5.000", NumberStyles.Any, swappedNFI, 5000, true);
- passed &= VerifyInt16TryParse("$5.000,00", NumberStyles.Any, swappedNFI, 5000, true);
- passed &= VerifyInt16TryParse("5,0", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyInt16TryParse("$5,0", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyInt16TryParse("5,000", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyInt16TryParse("$5,000", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyInt16TryParse("5,000.0", NumberStyles.Currency, swappedNFI, 0, false);
- passed &= VerifyInt16TryParse("$5,000.0", NumberStyles.Currency, swappedNFI, 0, false);
- passed &= VerifyInt16TryParse("5,000", NumberStyles.Any, swappedNFI, 5, true);
- passed &= VerifyInt16TryParse("$5,000", NumberStyles.Any, swappedNFI, 5, true);
- passed &= VerifyInt16TryParse("5,000.0", NumberStyles.Any, swappedNFI, 0, false);
- passed &= VerifyInt16TryParse("$5,000.0", NumberStyles.Any, swappedNFI, 0, false);
- //
- passed &= VerifyInt16TryParse("5.0", NumberStyles.Number, distinctNFI, 5, true);
- passed &= VerifyInt16TryParse("1,234.0", NumberStyles.Number, distinctNFI, 1234, true);
- passed &= VerifyInt16TryParse("5.0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyInt16TryParse("1,234.0", NumberStyles.Currency, distinctNFI, 1234, true);
- passed &= VerifyInt16TryParse("5.0", NumberStyles.Any, distinctNFI, 5, true);
- passed &= VerifyInt16TryParse("1,234.0", NumberStyles.Any, distinctNFI, 1234, true);
- passed &= VerifyInt16TryParse("$5.0", NumberStyles.Currency, distinctNFI, 0, false);
- passed &= VerifyInt16TryParse("$5.0", NumberStyles.Any, distinctNFI, 0, false);
- passed &= VerifyInt16TryParse("5:0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyInt16TryParse("5;0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyInt16TryParse("$5:0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyInt16TryParse("5:0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyInt16TryParse("5:000", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyInt16TryParse("5;000", NumberStyles.Currency, distinctNFI, 5000, true);
- passed &= VerifyInt16TryParse("$5:0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyInt16TryParse("$5;0", NumberStyles.Currency, distinctNFI, 50, true);
- passed &= VerifyInt16TryParse("5:0", NumberStyles.Any, distinctNFI, 5, true);
- passed &= VerifyInt16TryParse("5;0", NumberStyles.Any, distinctNFI, 50, true);
- passed &= VerifyInt16TryParse("$5:0", NumberStyles.Any, distinctNFI, 5, true);
- passed &= VerifyInt16TryParse("$5;0", NumberStyles.Any, distinctNFI, 50, true);
- passed &= VerifyInt16TryParse("1,23;45.0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyInt16TryParse("1,23;45.0", NumberStyles.Currency, distinctNFI, 12345, true);
- passed &= VerifyInt16TryParse("1,23;45.0", NumberStyles.Any, distinctNFI, 12345, true);
- passed &= VerifyInt16TryParse("$1,23;45.0", NumberStyles.Any, distinctNFI, 0, false);
-
-
- // Should these pass or fail? Current parse behavior is to pass, so they might be
- // parse bugs, but they're not tryparse bugs.
- passed &= VerifyInt16Parse("5", NumberStyles.Float, goodNFI, 5);
- passed &= VerifyInt16TryParse("5", NumberStyles.Float, goodNFI, 5, true);
- passed &= VerifyInt16Parse("5", NumberStyles.AllowDecimalPoint, goodNFI, 5);
- passed &= VerifyInt16TryParse("5", NumberStyles.AllowDecimalPoint, goodNFI, 5, true);
- // I expect ArgumentException with an ambiguous NFI
- passed &= VerifyInt16Parse("^42", NumberStyles.Any, ambigNFI, -42);
- passed &= VerifyInt16TryParse("^42", NumberStyles.Any, ambigNFI, -42, true);
-
- /// END TEST CASES
- }
- catch (Exception e)
- {
- TestLibrary.Logging.WriteLine("Unexpected exception!! " + e.ToString());
- passed = false;
- }
-
- if (passed)
- {
- TestLibrary.Logging.WriteLine("paSs");
- return 100;
- }
- else
- {
- TestLibrary.Logging.WriteLine("FAiL");
- return 1;
- }
- }
-
- public static bool VerifyInt16TryParse(string value, Int16 expectedResult, bool expectedReturn)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Int16.TryParse, Value = '{0}', Expected Result = {1}, Expected Return = {2}",
- value, expectedResult, expectedReturn);
- }
- Int16 result = 0;
- try
- {
- bool returnValue = Int16.TryParse(value, out result);
- if (returnValue != expectedReturn)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedReturn, returnValue);
- return false;
- }
- if (result != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, result);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyInt16TryParse(string value, NumberStyles style, IFormatProvider provider, Int16 expectedResult, bool expectedReturn)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Int16.TryParse, Value = '{0}', Style = {1}, Provider = {2}, Expected Result = {3}, Expected Return = {4}",
- value, style, provider, expectedResult, expectedReturn);
- }
- Int16 result = 0;
- try
- {
- bool returnValue = Int16.TryParse(value, style, provider, out result);
- if (returnValue != expectedReturn)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Style = {1}, Provider = {2}, Expected Return = {3}, Actual Return = {4}",
- value, style, provider, expectedReturn, returnValue);
- return false;
- }
- if (result != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, result);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyInt16TryParseException(string value, NumberStyles style, IFormatProvider provider, Type exceptionType)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Int16.TryParse, Value = '{0}', Style = {1}, Provider = {2}, Expected Exception = {3}",
- value, style, provider, exceptionType);
- }
- try
- {
- Int16 result = 0;
- Boolean returnValue = Int16.TryParse(value, style, provider, out result);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifyInt16Parse(string value, Int16 expectedResult)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Int16.Parse, Value = '{0}', Expected Result, {1}",
- value, expectedResult);
- }
- try
- {
- Int16 returnValue = Int16.Parse(value);
- if (returnValue != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, returnValue);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyInt16Parse(string value, NumberStyles style, IFormatProvider provider, Int16 expectedResult)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Int16.Parse, Value = '{0}', Style = {1}, provider = {2}, Expected Result = {3}",
- value, style, provider, expectedResult);
- }
- try
- {
- Int16 returnValue = Int16.Parse(value, style, provider);
- if (returnValue != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, returnValue);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyInt16ParseException(string value, Type exceptionType)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Int16.Parse, Value = '{0}', Expected Exception, {1}",
- value, exceptionType);
- }
- try
- {
- Int16 returnValue = Int16.Parse(value);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifyInt16ParseException(string value, NumberStyles style, Type exceptionType)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Int16.Parse, Value = '{0}', Style = {1}, Expected Exception = {3}",
- value, style, exceptionType);
- }
- try
- {
- Int16 returnValue = Int16.Parse(value, style);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifyInt16ParseException(string value, NumberStyles style, IFormatProvider provider, Type exceptionType)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Int16.Parse, Value = '{0}', Style = {1}, Provider = {2}, Expected Exception = {3}",
- value, style, provider, exceptionType);
- }
- try
- {
- Int16 returnValue = Int16.Parse(value, style, provider);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-}
-
diff --git a/tests/src/CoreMangLib/cti/system/int64/Int64Parse1.csproj b/tests/src/CoreMangLib/cti/system/int64/Int64Parse1.csproj
deleted file mode 100644
index 9cba741ee4..0000000000
--- a/tests/src/CoreMangLib/cti/system/int64/Int64Parse1.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="int64parse1.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/int64/Int64Parse2.csproj b/tests/src/CoreMangLib/cti/system/int64/Int64Parse2.csproj
deleted file mode 100644
index acb66f3de4..0000000000
--- a/tests/src/CoreMangLib/cti/system/int64/Int64Parse2.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="int64parse2.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/int64/Int64Parse3.csproj b/tests/src/CoreMangLib/cti/system/int64/Int64Parse3.csproj
deleted file mode 100644
index 4d84683dce..0000000000
--- a/tests/src/CoreMangLib/cti/system/int64/Int64Parse3.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="int64parse3.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/int64/Int64TryParse.csproj b/tests/src/CoreMangLib/cti/system/int64/Int64TryParse.csproj
deleted file mode 100644
index 2c3fe7fa6e..0000000000
--- a/tests/src/CoreMangLib/cti/system/int64/Int64TryParse.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="int64tryparse.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/int64/int64parse1.cs b/tests/src/CoreMangLib/cti/system/int64/int64parse1.cs
deleted file mode 100644
index 3b27436a44..0000000000
--- a/tests/src/CoreMangLib/cti/system/int64/int64parse1.cs
+++ /dev/null
@@ -1,341 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-/// <summary>
-/// Int64.Parse(string)
-/// </summary>
-public class Int64Parse1
-{
- private long c_INT64_MinValue = -9223372036854775808;
- private long c_INT64_MaxValue = 9223372036854775807;
- public static int Main()
- {
- Int64Parse1 int64parse1 = new Int64Parse1();
- TestLibrary.TestFramework.BeginTestCase("Int64Parse1");
- if (int64parse1.RunTests())
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("PASS");
- return 100;
- }
- else
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("FAIL");
- return 0;
- }
- }
- public bool RunTests()
- {
- bool retVal = true;
- TestLibrary.TestFramework.LogInformation("[PosTest]");
- retVal = PosTest1() && retVal;
- retVal = PosTest2() && retVal;
- retVal = PosTest3() && retVal;
- retVal = PosTest4() && retVal;
- retVal = PosTest5() && retVal;
- retVal = PosTest6() && retVal;
- retVal = PosTest7() && retVal;
- retVal = PosTest8() && retVal;
- TestLibrary.TestFramework.LogInformation("[NegTest]");
- retVal = NegTest1() && retVal;
- retVal = NegTest2() && retVal;
- retVal = NegTest3() && retVal;
- retVal = NegTest4() && retVal;
- return retVal;
- }
- #region PositiveTest
- public bool PosTest1()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest1: the string corresponding Int64 is Int64 MinValue");
-
- try
- {
- string strA = Int64.MinValue.ToString();
- long int64A = Int64.Parse(strA);
- if (int64A != c_INT64_MinValue)
- {
- TestLibrary.TestFramework.LogError("001", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest2()
- {
- bool retVal = true;
- Int64 int64A;
- TestLibrary.TestFramework.BeginScenario("PosTest2: the string corresponding Int64 is Int64 MaxValue ");
-
- try
- {
- string strA = Int64.MaxValue.ToString();
- int64A = Int64.Parse(strA);
- if (int64A != c_INT64_MaxValue)
- {
- TestLibrary.TestFramework.LogError("003", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest3()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest3: the string corresponding Int64 is normal Int64 ");
-
- try
- {
- long intTest = TestLibrary.Generator.GetInt64(-55);
- string strA = intTest.ToString();
- long int64A= Int64.Parse(strA);
- if (int64A != intTest)
- {
- TestLibrary.TestFramework.LogError("005", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest4()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest4: the string format is [ws][sign]digits[ws] 1");
- try
- {
- long int64A = TestLibrary.Generator.GetInt64(-55);
- string strA = "+" + int64A.ToString();
- long result = Int64.Parse(strA);
- if (result != int64A)
- {
- TestLibrary.TestFramework.LogError("007", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("008", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest5()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest5: the string format is [ws][sign]digits[ws] 2");
-
- try
- {
- long int64A = TestLibrary.Generator.GetInt64(-55);
- string strA = "-" + int64A.ToString();
- long result = Int64.Parse(strA);
- long int64B = int64A * (-1);
- if (result != int64B)
- {
- TestLibrary.TestFramework.LogError("009", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("010", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest6()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest6: the string format is [ws][sign]digits[ws] 3");
-
- try
- {
- long int64A = TestLibrary.Generator.GetInt64(-55);
- string strA = "\u0020"+ "-" + int64A.ToString();
- long result = Int64.Parse(strA);
- long int64B = int64A * (-1);
- if (result != int64B)
- {
- TestLibrary.TestFramework.LogError("011", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("012", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest7()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest7: the string format is [ws][sign]digits[ws] 4");
- try
- {
- long int64A = TestLibrary.Generator.GetInt64(-55);
- string strA = "\u0020" + "-" + int64A.ToString() + "\u0020";
- long result = Int64.Parse(strA);
- long int64B = int64A * (-1);
- if (result != int64B)
- {
- TestLibrary.TestFramework.LogError("013", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("014", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest8()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest8: the string formed by acceptable charactors");
- try
- {
- long int64A = 0xabcdefabcdeffff;
- string strA = "\u0020" + "-" + int64A.ToString() + "\u0020";
- long result = Int64.Parse(strA);
- long int64B = int64A * (-1);
- if (result != int64B)
- {
- TestLibrary.TestFramework.LogError("013", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("014", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- #endregion
- #region NegativeTest
- public bool NegTest1()
- {
- bool retVal = true;
- long int64A;
- TestLibrary.TestFramework.BeginScenario("NegTest1: the parameter string is null");
-
- try
- {
- string strA = null;
- int64A = Int64.Parse(strA);
- retVal = false;
- TestLibrary.TestFramework.LogError("N001", "the param string is null but not throw exception");
- }
- catch (ArgumentNullException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N002", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest2()
- {
- bool retVal = true;
- long int64A;
- TestLibrary.TestFramework.BeginScenario("NegTest2: the parameter string is not correct format");
-
- try
- {
- string strA = "#$%abc";
- int64A = Int64.Parse(strA);
- retVal = false;
- TestLibrary.TestFramework.LogError("N003", "the param string is null but not throw exception");
- }
- catch (FormatException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N004", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest3()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("NegTest3: the parameter string parsed number is less than the Int64 minValue");
-
- try
- {
- string strA = "-9223372036854775809";
- Int64 int64A = Int64.Parse(strA);
- retVal = false;
- TestLibrary.TestFramework.LogError("N005", "the param string parsed number is less than MinValue but not throw exception");
- }
- catch (OverflowException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N006", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest4()
- {
- bool retVal = true;
- long int64A;
- TestLibrary.TestFramework.BeginScenario("NegTest4: the parameter string parsed number is greater than the Int64 maxValue");
-
- try
- {
- string strA = "9223372036854775808";
- int64A = Int64.Parse(strA);
- retVal = false;
- TestLibrary.TestFramework.LogError("N007", "the param string parsed number is greater than MaxValue but not throw exception");
- }
- catch (OverflowException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N008", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- #endregion
- #region HelpMethod
- private Int32 GetInt32(Int32 minValue, Int32 maxValue)
- {
- try
- {
- if (minValue == maxValue)
- {
- return minValue;
- }
- if (minValue < maxValue)
- {
- return minValue + TestLibrary.Generator.GetInt32(-55) % (maxValue - minValue);
- }
- }
- catch
- {
- throw;
- }
-
- return minValue;
- }
- #endregion
-}
diff --git a/tests/src/CoreMangLib/cti/system/int64/int64parse2.cs b/tests/src/CoreMangLib/cti/system/int64/int64parse2.cs
deleted file mode 100644
index c20c71c129..0000000000
--- a/tests/src/CoreMangLib/cti/system/int64/int64parse2.cs
+++ /dev/null
@@ -1,326 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Globalization;
-/// <summary>
-/// Int64.Parse(string,NumberStyles)
-/// </summary>
-public class Int64Parse2
-{
- private long c_INT64_MinValue = -9223372036854775808;
- private long c_INT64_MaxValue = 9223372036854775807;
- public static int Main()
- {
- Int64Parse2 int64parse2 = new Int64Parse2();
- TestLibrary.TestFramework.BeginTestCase("Int64Parse2");
- if (int64parse2.RunTests())
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("PASS");
- return 100;
- }
- else
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("FAIL");
- return 0;
- }
- }
- public bool RunTests()
- {
- bool retVal = true;
- TestLibrary.TestFramework.LogInformation("[PosTest]");
- retVal = PosTest1() && retVal;
- retVal = PosTest2() && retVal;
- retVal = PosTest3() && retVal;
- retVal = PosTest4() && retVal;
- retVal = PosTest5() && retVal;
- retVal = PosTest6() && retVal;
- retVal = PosTest7() && retVal;
- TestLibrary.TestFramework.LogInformation("[NegTest]");
- retVal = NegTest1() && retVal;
- retVal = NegTest2() && retVal;
- retVal = NegTest3() && retVal;
- retVal = NegTest4() && retVal;
- retVal = NegTest5() && retVal;
- return retVal;
- }
- #region PositiveTest
- public bool PosTest1()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest1: the string corresponding Int64 is Int64 MaxValue 1");
- try
- {
- string strA = Int64.MaxValue.ToString();
- NumberStyles style = NumberStyles.Any;
- long int64A = Int64.Parse(strA, style);
- if (int64A != c_INT64_MaxValue)
- {
- TestLibrary.TestFramework.LogError("001", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest2()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest2: the string corresponding Int64 is Int64 MaxValue 2");
- try
- {
- string strA = "7fffffffffffffff";
- NumberStyles style = NumberStyles.HexNumber;
- long int64A = Int64.Parse(strA, style);
- if (int64A != c_INT64_MaxValue)
- {
- TestLibrary.TestFramework.LogError("003", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest3()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest3: the string corresponding Int64 is Int64 MinValue");
- try
- {
- string strA = Int64.MinValue.ToString();
- NumberStyles style = NumberStyles.Any;
- long int64A = Int64.Parse(strA, style);
- if (int64A != c_INT64_MinValue)
- {
- TestLibrary.TestFramework.LogError("005", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest4()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest4: the string format is [ws][sign]digits[ws] 1");
- try
- {
- long int64A = TestLibrary.Generator.GetInt64(-55);
- string strA = "\u0020" + "+" + int64A.ToString();
- NumberStyles style = NumberStyles.Any;
- long result = Int64.Parse(strA, style);
- if (result != int64A)
- {
- TestLibrary.TestFramework.LogError("007", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("008", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest5()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest5: the string format is [ws][sign]digits[ws] 2");
-
- try
- {
- long int64A = TestLibrary.Generator.GetInt64(-55);
- string strA = "\u0020" + "-" + int64A.ToString();
- NumberStyles style = NumberStyles.Any;
- long result = Int64.Parse(strA, style);
- long int64B = int64A * (-1);
- if (result != int64B)
- {
- TestLibrary.TestFramework.LogError("009", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("010", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest6()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest6: the string format is [ws][sign]digits[ws] 3");
-
- try
- {
- long int64A = TestLibrary.Generator.GetInt64(-55);
- string strA = "\u0020" + "-" + int64A.ToString() + "\u0020";
- NumberStyles style = NumberStyles.Any;
- long result = Int64.Parse(strA,style);
- long int64B = int64A * (-1);
- if (result != int64B)
- {
- TestLibrary.TestFramework.LogError("011", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("012", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest7()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest7: the string format is [ws][sign]digits[ws] 4");
-
- try
- {
- long int64A = TestLibrary.Generator.GetInt64(-55);
- string strA = "\u0020" + "-0" + int64A.ToString() + "\u0020";
- NumberStyles style = NumberStyles.Any;
- long result = Int64.Parse(strA, style);
- long int64B = int64A * (-1);
- if (result != int64B)
- {
- TestLibrary.TestFramework.LogError("013", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("014", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- #endregion
- #region NegativeTest
- public bool NegTest1()
- {
- bool retVal = true;
- long int64A;
- TestLibrary.TestFramework.BeginScenario("NegTest1: the parameter string is null");
-
- try
- {
- string strA = null;
- NumberStyles style = NumberStyles.Any;
- int64A = Int64.Parse(strA, style);
- retVal = false;
- TestLibrary.TestFramework.LogError("N001", "the param string is null but not throw exception");
- }
- catch (ArgumentNullException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N002", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest2()
- {
- bool retVal = true;
- long int64A;
- TestLibrary.TestFramework.BeginScenario("NegTest2: the parameter string is not correct format");
-
- try
- {
- string strA = "#$%abc";
- NumberStyles style = NumberStyles.Any;
- int64A = Int64.Parse(strA, style);
- retVal = false;
- TestLibrary.TestFramework.LogError("N003", "the param string is null but not throw exception");
- }
- catch (FormatException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N004", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest3()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("NegTest3: the parameter string parsed number is less than the Int64 minValue");
-
- try
- {
- string strA = "-9223372036854775809";
- NumberStyles style = NumberStyles.Any;
- Int64 int64A = Int64.Parse(strA, style);
- retVal = false;
- TestLibrary.TestFramework.LogError("N005", "the param string parsed number is less than MinValue but not throw exception");
- }
- catch (OverflowException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N006", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest4()
- {
- bool retVal = true;
- long int64A;
- TestLibrary.TestFramework.BeginScenario("NegTest4: the parameter string parsed number is greater than the Int64 maxValue");
-
- try
- {
- string strA = "9223372036854775808";
- NumberStyles style = NumberStyles.Any;
- int64A = Int64.Parse(strA, style);
- retVal = false;
- TestLibrary.TestFramework.LogError("N007", "the param string parsed number is greater than MaxValue but not throw exception");
- }
- catch (OverflowException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N008", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest5()
- {
- bool retVal = true;
- long int64A;
- TestLibrary.TestFramework.BeginScenario("NegTest5: the param of style is not NumberStyles value");
-
- try
- {
- string strA = TestLibrary.Generator.GetInt64(-55).ToString();
- NumberStyles style = (NumberStyles)(Int32.MaxValue);
- int64A = Int64.Parse(strA, style);
- retVal = false;
- TestLibrary.TestFramework.LogError("N009", "the param of style is not NumberStyles value but not throw exception");
- }
- catch (ArgumentException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N010", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- #endregion
-}
diff --git a/tests/src/CoreMangLib/cti/system/int64/int64parse3.cs b/tests/src/CoreMangLib/cti/system/int64/int64parse3.cs
deleted file mode 100644
index 870320b963..0000000000
--- a/tests/src/CoreMangLib/cti/system/int64/int64parse3.cs
+++ /dev/null
@@ -1,398 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Globalization;
-/// <summary>
-/// Int64.Parse(string,NumberStyle,IFormatProvider)
-/// </summary>
-public class Int64Parse3
-{
- private long c_INT64_MinValue = -9223372036854775808;
- private long c_INT64_MaxValue = 9223372036854775807;
- public static int Main()
- {
- Int64Parse3 int64parse3 = new Int64Parse3();
- TestLibrary.TestFramework.BeginTestCase("Int64Parse3");
- if (int64parse3.RunTests())
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("PASS");
- return 100;
- }
- else
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("FAIL");
- return 0;
- }
- }
- public bool RunTests()
- {
- bool retVal = true;
- TestLibrary.TestFramework.LogInformation("[PosTest]");
- retVal = PosTest1() && retVal;
- retVal = PosTest2() && retVal;
- retVal = PosTest3() && retVal;
- retVal = PosTest4() && retVal;
- retVal = PosTest5() && retVal;
- retVal = PosTest6() && retVal;
- retVal = PosTest7() && retVal;
- retVal = PosTest8() && retVal;
- retVal = PosTest9() && retVal;
- TestLibrary.TestFramework.LogInformation("[NegTest]");
- retVal = NegTest1() && retVal;
- retVal = NegTest2() && retVal;
- retVal = NegTest3() && retVal;
- retVal = NegTest4() && retVal;
- retVal = NegTest5() && retVal;
- return retVal;
- }
- #region PositiveTest
- public bool PosTest1()
- {
- bool retVal = true;
- CultureInfo myculture = new CultureInfo("en-us");
- IFormatProvider provider = myculture.NumberFormat;
- TestLibrary.TestFramework.BeginScenario("PosTest1: the string corresponding Int64 is Int64 MaxValue 1");
- try
- {
- string strA = Int64.MaxValue.ToString();
- NumberStyles style = NumberStyles.Any;
- long int64A = Int64.Parse(strA, style, provider);
- if (int64A != c_INT64_MaxValue)
- {
- TestLibrary.TestFramework.LogError("001", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest2()
- {
- bool retVal = true;
- CultureInfo myculture = new CultureInfo("el-GR");
- IFormatProvider provider = myculture.NumberFormat;
- TestLibrary.TestFramework.BeginScenario("PosTest2: the string corresponding Int64 is Int64 MaxValue 2");
- try
- {
- string strA = Int64.MaxValue.ToString();
- NumberStyles style = NumberStyles.Any;
- long int64A = Int64.Parse(strA, style, provider);
- if (int64A != c_INT64_MaxValue)
- {
- TestLibrary.TestFramework.LogError("003", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest3()
- {
- bool retVal = true;
- CultureInfo myculture = new CultureInfo("en-us");
- IFormatProvider provider = myculture.NumberFormat;
- TestLibrary.TestFramework.BeginScenario("PosTest3: the string corresponding Int64 is Int64 MinValue 1");
- try
- {
- string strA = Int64.MinValue.ToString();
- NumberStyles style = NumberStyles.Any;
- long int64A = Int64.Parse(strA, style, provider);
- if (int64A != c_INT64_MinValue)
- {
- TestLibrary.TestFramework.LogError("005", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest4()
- {
- bool retVal = true;
- CultureInfo myculture = new CultureInfo("el-GR");
- IFormatProvider provider = myculture.NumberFormat;
- TestLibrary.TestFramework.BeginScenario("PosTest4: the string corresponding Int64 is Int64 MinValue 2");
- try
- {
- string strA = Int64.MinValue.ToString();
- NumberStyles style = NumberStyles.Any;
- long int64A = Int64.Parse(strA, style, provider);
- if (int64A != c_INT64_MinValue)
- {
- TestLibrary.TestFramework.LogError("007", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("008", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest5()
- {
- bool retVal = true;
- CultureInfo mycultrue = new CultureInfo("en-us");
- IFormatProvider provider = mycultrue.NumberFormat;
- TestLibrary.TestFramework.BeginScenario("PosTest5: the string format is [ws][sign]digits[ws] 1");
- try
- {
- long int64A = TestLibrary.Generator.GetInt64(-55);
- string strA = "\u0020" + "+" + int64A.ToString();
- NumberStyles style = NumberStyles.Any;
- long result = Int64.Parse(strA, style, provider);
- if (result != int64A)
- {
- TestLibrary.TestFramework.LogError("009", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("010", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest6()
- {
- bool retVal = true;
- CultureInfo mycultrue = new CultureInfo("en-us");
- IFormatProvider provider = mycultrue.NumberFormat;
- TestLibrary.TestFramework.BeginScenario("PosTest5: the string format is [ws][sign]digits[ws] 2");
-
- try
- {
- long int64A = TestLibrary.Generator.GetInt64(-55);
- string strA = "\u0020" + "-" + int64A.ToString();
- NumberStyles style = NumberStyles.Any;
- long result = Int64.Parse(strA, style, provider);
- long int64B = int64A * (-1);
- if (result != int64B)
- {
- TestLibrary.TestFramework.LogError("011", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("012", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest7()
- {
- bool retVal = true;
- CultureInfo mycultrue = new CultureInfo("en-us");
- IFormatProvider provider = mycultrue.NumberFormat;
- TestLibrary.TestFramework.BeginScenario("PosTest7: the string format is [ws][sign]digits[ws] 3");
-
- try
- {
- long int64A = TestLibrary.Generator.GetInt64(-55);
- string strA = "\u0020" + "-" + int64A.ToString() + "\u0020";
- NumberStyles style = NumberStyles.Any;
- long result = Int64.Parse(strA, style, provider);
- long int64B = int64A * (-1);
- if (result != int64B)
- {
- TestLibrary.TestFramework.LogError("013", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("014", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest8()
- {
- bool retVal = true;
- CultureInfo mycultrue = new CultureInfo("en-us");
- IFormatProvider provider = mycultrue.NumberFormat;
- TestLibrary.TestFramework.BeginScenario("PosTest8: the string format is [ws][sign]digits[ws] 4");
-
- try
- {
- long int64A = TestLibrary.Generator.GetInt64(-55);
- string strA = "\u0020" + "-0" + int64A.ToString() + "\u0020";
- NumberStyles style = NumberStyles.Any;
- long result = Int64.Parse(strA, style, provider);
- long int64B = int64A * (-1);
- if (result != int64B)
- {
- TestLibrary.TestFramework.LogError("015", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("016", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest9()
- {
- bool retVal = true;
- CultureInfo mycultrue = new CultureInfo("en-us");
- IFormatProvider provider = mycultrue.NumberFormat;
- TestLibrary.TestFramework.BeginScenario("PosTest9: the string formed with acceptable characters");
-
- try
- {
- long int64A = 0xabcdfffffabc;
- string strA = "\u0020" + "-0" + int64A.ToString() + "\u0020";
- NumberStyles style = NumberStyles.Any;
- long result = Int64.Parse(strA, style, provider);
- long int64B = int64A * (-1);
- if (result != int64B)
- {
- TestLibrary.TestFramework.LogError("017", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("018", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- #endregion
- #region NegativeTest
- public bool NegTest1()
- {
- bool retVal = true;
- long int64A;
- IFormatProvider provider = null;
- TestLibrary.TestFramework.BeginScenario("NegTest1: the parameter string is null");
-
- try
- {
- string strA = null;
- NumberStyles style = NumberStyles.Any;
- int64A = Int64.Parse(strA, style, provider);
- retVal = false;
- TestLibrary.TestFramework.LogError("N001", "the param string is null but not throw exception");
- }
- catch (ArgumentNullException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N002", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest2()
- {
- bool retVal = true;
- long int64A;
- IFormatProvider provider = null;
- TestLibrary.TestFramework.BeginScenario("NegTest2: the parameter string is not correct format");
-
- try
- {
- string strA = "#$%abc";
- NumberStyles style = NumberStyles.Any;
- int64A = Int64.Parse(strA, style, provider);
- retVal = false;
- TestLibrary.TestFramework.LogError("N003", "the param string is null but not throw exception");
- }
- catch (FormatException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N004", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest3()
- {
- bool retVal = true;
- IFormatProvider provider = null;
- TestLibrary.TestFramework.BeginScenario("NegTest3: the parameter string parsed number is less than the Int64 minValue");
-
- try
- {
- string strA = "-9223372036854775809";
- NumberStyles style = NumberStyles.Any;
- Int64 int64A = Int64.Parse(strA, style, provider);
- retVal = false;
- TestLibrary.TestFramework.LogError("N005", "the param string parsed number is less than MinValue but not throw exception");
- }
- catch (OverflowException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N006", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest4()
- {
- bool retVal = true;
- long int64A;
- IFormatProvider provider = null;
- TestLibrary.TestFramework.BeginScenario("NegTest4: the parameter string parsed number is greater than the Int64 maxValue");
-
- try
- {
- string strA = "9223372036854775808";
- NumberStyles style = NumberStyles.Any;
- int64A = Int64.Parse(strA, style, provider);
- retVal = false;
- TestLibrary.TestFramework.LogError("N007", "the param string parsed number is greater than MaxValue but not throw exception");
- }
- catch (OverflowException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N008", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest5()
- {
- bool retVal = true;
- long int64A;
- IFormatProvider provider = null;
- TestLibrary.TestFramework.BeginScenario("NegTest5: the param of style is not NumberStyles value");
-
- try
- {
- string strA = TestLibrary.Generator.GetInt64(-55).ToString();
- NumberStyles style = (NumberStyles)(Int32.MaxValue);
- int64A = Int64.Parse(strA, style, provider);
- retVal = false;
- TestLibrary.TestFramework.LogError("N009", "the param of style is not NumberStyles value but not throw exception");
- }
- catch (ArgumentException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N010", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- #endregion
-}
diff --git a/tests/src/CoreMangLib/cti/system/int64/int64tryparse.cs b/tests/src/CoreMangLib/cti/system/int64/int64tryparse.cs
deleted file mode 100644
index 6e8834af31..0000000000
--- a/tests/src/CoreMangLib/cti/system/int64/int64tryparse.cs
+++ /dev/null
@@ -1,571 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Globalization;
-
-// Ported over to CoreCLR from Co7529TryParse_all.cs
-// Tests Int64.TryParse(String), Int64.TryParse(String, NumberStyles, IFormatProvider, ref Int64)
-// 2003/04/01 KatyK
-// 2007/06/28 adapted by MarielY
-
-public class Int64TryParse
-{
- static bool verbose = false;
-
- public static int Main()
- {
- bool passed = true;
-
- try
- {
- // Make the test culture independent
- TestLibrary.Utilities.CurrentCulture = CultureInfo.InvariantCulture;
-
- // Set up NFIs to use
- NumberFormatInfo goodNFI = new NumberFormatInfo();
-
- NumberFormatInfo corruptNFI = new NumberFormatInfo(); // DecimalSeparator == GroupSeparator
- corruptNFI.NumberDecimalSeparator = ".";
- corruptNFI.NumberGroupSeparator = ".";
- corruptNFI.CurrencyDecimalSeparator = ".";
- corruptNFI.CurrencyGroupSeparator = ".";
- corruptNFI.CurrencySymbol = "$";
-
- NumberFormatInfo swappedNFI = new NumberFormatInfo(); // DecimalSeparator & GroupSeparator swapped
- swappedNFI.NumberDecimalSeparator = ".";
- swappedNFI.NumberGroupSeparator = ",";
- swappedNFI.CurrencyDecimalSeparator = ",";
- swappedNFI.CurrencyGroupSeparator = ".";
- swappedNFI.CurrencySymbol = "$";
-
- NumberFormatInfo distinctNFI = new NumberFormatInfo(); // DecimalSeparator & GroupSeparator distinct
- distinctNFI.NumberDecimalSeparator = ".";
- distinctNFI.NumberGroupSeparator = ",";
- distinctNFI.CurrencyDecimalSeparator = ":";
- distinctNFI.CurrencyGroupSeparator = ";";
- distinctNFI.CurrencySymbol = "$";
-
- NumberFormatInfo customNFI = new NumberFormatInfo();
- customNFI.NegativeSign = "^";
-
- NumberFormatInfo ambigNFI = new NumberFormatInfo();
- ambigNFI.NegativeSign = "^";
- ambigNFI.CurrencySymbol = "^";
-
- CultureInfo germanCulture = new CultureInfo("de-DE");
- CultureInfo japaneseCulture;
-
- try
- {
- japaneseCulture = new CultureInfo("ja-JP");
- }
- catch (Exception)
- {
- TestLibrary.Logging.WriteLine("East Asian Languages are not installed. Skiping Japanese culture tests.");
- japaneseCulture = null;
- }
-
- // Parse tests included for comparison/regression
- passed &= VerifyInt64Parse("5", 5);
- passed &= VerifyInt64Parse("-5", -5);
- passed &= VerifyInt64Parse("5 ", 5);
- passed &= VerifyInt64Parse("5\0", 5);
- passed &= VerifyInt64Parse("893382737", 893382737);
- passed &= VerifyInt64Parse("-893382737", -893382737);
- passed &= VerifyInt64Parse("1234567891", 1234567891);
- passed &= VerifyInt64Parse("-1234567891", -1234567891);
- passed &= VerifyInt64Parse("123456789123456789", 123456789123456789);
- passed &= VerifyInt64Parse("-123456789123456789", -123456789123456789);
- passed &= VerifyInt64Parse("5", NumberStyles.Integer, CultureInfo.InvariantCulture, 5);
- passed &= VerifyInt64Parse("-5", NumberStyles.Integer, CultureInfo.InvariantCulture, -5);
- passed &= VerifyInt64Parse("5 \0", NumberStyles.Integer, CultureInfo.InvariantCulture, 5);
- passed &= VerifyInt64Parse("5\0\0\0", NumberStyles.Integer, CultureInfo.InvariantCulture, 5);
- passed &= VerifyInt64Parse("12", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0x12);
- passed &= VerifyInt64Parse("fF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0xFF);
- passed &= VerifyInt64Parse("FFFFFFFF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0xFFFFFFFF);
- passed &= VerifyInt64Parse("FFFFFFFFFFFFFFFF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, -1);
- passed &= VerifyInt64Parse("123", NumberStyles.Integer, germanCulture, 123);
- passed &= VerifyInt64Parse("123", NumberStyles.Integer, japaneseCulture, 123);
- passed &= VerifyInt64Parse("123.000", NumberStyles.Any, germanCulture, 123000);
- passed &= VerifyInt64Parse("123,000", NumberStyles.Any, japaneseCulture, 123000);
- passed &= VerifyInt64Parse("123,000", NumberStyles.AllowDecimalPoint, germanCulture, 123);
- passed &= VerifyInt64Parse("123.000", NumberStyles.AllowDecimalPoint, japaneseCulture, 123);
- passed &= VerifyInt64Parse("5,00 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Any, germanCulture, 5); // currency
- passed &= VerifyInt64Parse("5", NumberStyles.Integer, goodNFI, 5);
- passed &= VerifyInt64Parse("5.0", NumberStyles.AllowDecimalPoint, goodNFI, 5);
- //
- passed &= VerifyInt64Parse("5", NumberStyles.Integer, corruptNFI, 5);
- passed &= VerifyInt64Parse("5", NumberStyles.Number, corruptNFI, 5);
- passed &= VerifyInt64Parse("5.0", NumberStyles.Number, corruptNFI, 5);
- passed &= VerifyInt64ParseException("5,0", NumberStyles.Number, corruptNFI, typeof(FormatException));
- passed &= VerifyInt64ParseException("5.0.0", NumberStyles.Number, corruptNFI, typeof(FormatException));
- passed &= VerifyInt64Parse("$5.0", NumberStyles.Currency, corruptNFI, 5);
- passed &= VerifyInt64ParseException("$5,0", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyInt64ParseException("$5.0.0", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyInt64Parse("5.0", NumberStyles.Currency, corruptNFI, 5);
- passed &= VerifyInt64ParseException("5,0", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyInt64ParseException("5.0.0", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyInt64Parse("5.0", NumberStyles.Any, corruptNFI, 5);
- passed &= VerifyInt64ParseException("5,0", NumberStyles.Any, corruptNFI, typeof(FormatException));
- passed &= VerifyInt64ParseException("5.0.0", NumberStyles.Any, corruptNFI, typeof(FormatException));
- //
- passed &= VerifyInt64Parse("5", NumberStyles.Integer, swappedNFI, 5);
- passed &= VerifyInt64ParseException("1,234", NumberStyles.Integer, swappedNFI, typeof(FormatException));
- passed &= VerifyInt64Parse("5", NumberStyles.Number, swappedNFI, 5);
- passed &= VerifyInt64Parse("5.0", NumberStyles.Number, swappedNFI, 5);
- passed &= VerifyInt64Parse("1,234", NumberStyles.Number, swappedNFI, 1234);
- passed &= VerifyInt64Parse("1,234.0", NumberStyles.Number, swappedNFI, 1234);
- passed &= VerifyInt64ParseException("5.000.000", NumberStyles.Number, swappedNFI, typeof(FormatException));
- passed &= VerifyInt64ParseException("5.000,00", NumberStyles.Number, swappedNFI, typeof(FormatException));
- passed &= VerifyInt64Parse("5.000", NumberStyles.Currency, swappedNFI, 5); //???
- passed &= VerifyInt64ParseException("5.000,00", NumberStyles.Currency, swappedNFI, typeof(FormatException)); //???
- passed &= VerifyInt64Parse("$5.000", NumberStyles.Currency, swappedNFI, 5000);
- passed &= VerifyInt64Parse("$5.000,00", NumberStyles.Currency, swappedNFI, 5000);
- passed &= VerifyInt64Parse("5.000", NumberStyles.Any, swappedNFI, 5); //?
- passed &= VerifyInt64ParseException("5.000,00", NumberStyles.Any, swappedNFI, typeof(FormatException)); //?
- passed &= VerifyInt64Parse("$5.000", NumberStyles.Any, swappedNFI, 5000);
- passed &= VerifyInt64Parse("$5.000,00", NumberStyles.Any, swappedNFI, 5000);
- passed &= VerifyInt64Parse("5,0", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyInt64Parse("$5,0", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyInt64Parse("5,000", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyInt64Parse("$5,000", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyInt64ParseException("5,000.0", NumberStyles.Currency, swappedNFI, typeof(FormatException));
- passed &= VerifyInt64ParseException("$5,000.0", NumberStyles.Currency, swappedNFI, typeof(FormatException));
- passed &= VerifyInt64Parse("5,000", NumberStyles.Any, swappedNFI, 5);
- passed &= VerifyInt64Parse("$5,000", NumberStyles.Any, swappedNFI, 5);
- passed &= VerifyInt64ParseException("5,000.0", NumberStyles.Any, swappedNFI, typeof(FormatException));
- passed &= VerifyInt64ParseException("$5,000.0", NumberStyles.Any, swappedNFI, typeof(FormatException));
- //
- passed &= VerifyInt64Parse("5.0", NumberStyles.Number, distinctNFI, 5);
- passed &= VerifyInt64Parse("1,234.0", NumberStyles.Number, distinctNFI, 1234);
- passed &= VerifyInt64Parse("5.0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyInt64Parse("1,234.0", NumberStyles.Currency, distinctNFI, 1234);
- passed &= VerifyInt64Parse("5.0", NumberStyles.Any, distinctNFI, 5);
- passed &= VerifyInt64Parse("1,234.0", NumberStyles.Any, distinctNFI, 1234);
- passed &= VerifyInt64ParseException("$5.0", NumberStyles.Currency, distinctNFI, typeof(FormatException));
- passed &= VerifyInt64ParseException("$5.0", NumberStyles.Any, distinctNFI, typeof(FormatException));
- passed &= VerifyInt64ParseException("5:0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyInt64ParseException("5;0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyInt64ParseException("$5:0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyInt64Parse("5:0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyInt64Parse("5:000", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyInt64Parse("5;000", NumberStyles.Currency, distinctNFI, 5000);
- passed &= VerifyInt64Parse("$5:0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyInt64Parse("$5;0", NumberStyles.Currency, distinctNFI, 50);
- passed &= VerifyInt64Parse("5:0", NumberStyles.Any, distinctNFI, 5);
- passed &= VerifyInt64Parse("5;0", NumberStyles.Any, distinctNFI, 50);
- passed &= VerifyInt64Parse("$5:0", NumberStyles.Any, distinctNFI, 5);
- passed &= VerifyInt64Parse("$5;0", NumberStyles.Any, distinctNFI, 50);
- passed &= VerifyInt64ParseException("123,456;789.0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyInt64Parse("123,456;789.0", NumberStyles.Currency, distinctNFI, 123456789);
- passed &= VerifyInt64Parse("123,456;789.0", NumberStyles.Any, distinctNFI, 123456789);
- passed &= VerifyInt64ParseException("$123,456;789.0", NumberStyles.Any, distinctNFI, typeof(FormatException));
- //
- passed &= VerifyInt64ParseException("123456789123456789123", typeof(OverflowException));
- passed &= VerifyInt64ParseException("-123456789123456789123", typeof(OverflowException));
- passed &= VerifyInt64ParseException("18446744073709551615", typeof(OverflowException));
- passed &= VerifyInt64ParseException("Garbage", typeof(FormatException));
- passed &= VerifyInt64ParseException("5\0Garbage", typeof(FormatException));
- passed &= VerifyInt64ParseException(null, typeof(ArgumentNullException));
- passed &= VerifyInt64ParseException("123456789123456789", NumberStyles.HexNumber, CultureInfo.InvariantCulture, typeof(OverflowException));
- passed &= VerifyInt64ParseException("5.3", NumberStyles.AllowDecimalPoint, goodNFI, typeof(OverflowException)); //weird that it's Overflow, but consistent with v1
- passed &= VerifyInt64ParseException("5", NumberStyles.AllowHexSpecifier | NumberStyles.AllowParentheses, null, typeof(ArgumentException));
- passed &= VerifyInt64ParseException("4", (NumberStyles)(-1), typeof(ArgumentException));
- passed &= VerifyInt64ParseException("4", (NumberStyles)0x10000, typeof(ArgumentException));
- passed &= VerifyInt64ParseException("4", (NumberStyles)(-1), CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifyInt64ParseException("4", (NumberStyles)0x10000, CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifyInt64ParseException("123.000.000.000.000.000.000", NumberStyles.Any, germanCulture, typeof(OverflowException));
- passed &= VerifyInt64ParseException("123,000,000,000,000,000,000", NumberStyles.Any, japaneseCulture, typeof(OverflowException));
- passed &= VerifyInt64ParseException("123,000,000,000,000,000,000", NumberStyles.Integer, germanCulture, typeof(FormatException));
- passed &= VerifyInt64ParseException("123.000.000.000.000.000.000", NumberStyles.Integer, japaneseCulture, typeof(FormatException));
- passed &= VerifyInt64ParseException("5,00 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Integer, germanCulture, typeof(FormatException)); // currency
-
-
- /////////// TryParse(String)
- //// Pass cases
- passed &= VerifyInt64TryParse("5", 5, true);
- passed &= VerifyInt64TryParse("-5", -5, true);
- passed &= VerifyInt64TryParse(" 5 ", 5, true);
- passed &= VerifyInt64TryParse("5\0", 5, true);
- passed &= VerifyInt64TryParse("5 \0", 5, true);
- passed &= VerifyInt64TryParse("5\0\0\0", 5, true);
- passed &= VerifyInt64TryParse("10000", 10000, true);
- passed &= VerifyInt64TryParse("893382737", 893382737, true);
- passed &= VerifyInt64TryParse("-893382737", -893382737, true);
- passed &= VerifyInt64TryParse("1234567891", 1234567891, true);
- passed &= VerifyInt64TryParse("-1234567891", -1234567891, true);
- passed &= VerifyInt64TryParse("123456789123456789", 123456789123456789, true);
- passed &= VerifyInt64TryParse("-123456789123456789", -123456789123456789, true);
- passed &= VerifyInt64TryParse(Int64.MaxValue.ToString(), Int64.MaxValue, true);
- passed &= VerifyInt64TryParse(Int64.MinValue.ToString(), Int64.MinValue, true);
-
- //// Fail cases
- passed &= VerifyInt64TryParse(null, 0, false);
- passed &= VerifyInt64TryParse("", 0, false);
- passed &= VerifyInt64TryParse("Garbage", 0, false);
- passed &= VerifyInt64TryParse("5\0Garbage", 0, false);
- passed &= VerifyInt64TryParse("18446744073709551615", 0, false);
- passed &= VerifyInt64TryParse("123456789123456789123", 0, false);
- passed &= VerifyInt64TryParse("-123456789123456789123", 0, false);
- passed &= VerifyInt64TryParse("FF", 0, false);
- passed &= VerifyInt64TryParse("27.3", 0, false);
- passed &= VerifyInt64TryParse("23 5", 0, false);
-
-
- /////////// TryParse(TryParse(String, NumberStyles, IFormatProvider, ref Int64)
- //// Pass cases
- passed &= VerifyInt64TryParse("5", NumberStyles.Integer, CultureInfo.InvariantCulture, 5, true);
- passed &= VerifyInt64TryParse("-5", NumberStyles.Integer, CultureInfo.InvariantCulture, -5, true);
- // Variations on NumberStyles
- passed &= VerifyInt64TryParse("12", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0x12, true);
- passed &= VerifyInt64TryParse("FF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0xFF, true);
- passed &= VerifyInt64TryParse("fF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0xFF, true);
- passed &= VerifyInt64TryParse("FFFFFFFF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0xFFFFFFFF, true);
- passed &= VerifyInt64TryParse("FFFFFFFFFFFFFFFF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, -1, true);
- passed &= VerifyInt64TryParse(" 5", NumberStyles.AllowLeadingWhite, goodNFI, 5, true);
- passed &= VerifyInt64TryParse("5", NumberStyles.Number, goodNFI, 5, true);
- passed &= VerifyInt64TryParse("5.0", NumberStyles.AllowDecimalPoint, goodNFI, 5, true);
- // Variations on IFP
- passed &= VerifyInt64TryParse("5", NumberStyles.Integer, goodNFI, 5, true);
- passed &= VerifyInt64TryParse("5", NumberStyles.Integer, null, 5, true);
- passed &= VerifyInt64TryParse("5", NumberStyles.Integer, new DateTimeFormatInfo(), 5, true);
- passed &= VerifyInt64TryParse("^42", NumberStyles.Any, customNFI, -42, true);
- passed &= VerifyInt64TryParse("123", NumberStyles.Integer, germanCulture, 123, true);
- passed &= VerifyInt64TryParse("123", NumberStyles.Integer, japaneseCulture, 123, true);
- passed &= VerifyInt64TryParse("123.000", NumberStyles.Any, germanCulture, 123000, true);
- passed &= VerifyInt64TryParse("123,000", NumberStyles.Any, japaneseCulture, 123000, true);
- passed &= VerifyInt64TryParse("123,000", NumberStyles.AllowDecimalPoint, germanCulture, 123, true);
- passed &= VerifyInt64TryParse("123.000", NumberStyles.AllowDecimalPoint, japaneseCulture, 123, true);
- passed &= VerifyInt64TryParse("5,00 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Any, germanCulture, 5, true); // currency
-
- //// Fail cases
- passed &= VerifyInt64TryParse("FF", NumberStyles.Integer, CultureInfo.InvariantCulture, 0, false);
- passed &= VerifyInt64TryParse("123456789123456789", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0, false);
- passed &= VerifyInt64TryParse("-42", NumberStyles.Any, customNFI, 0, false);
- passed &= VerifyInt64TryParse("5.3", NumberStyles.AllowDecimalPoint, goodNFI, 0, false);
- passed &= VerifyInt64TryParse("5 ", NumberStyles.AllowLeadingWhite, goodNFI, 0, false);
- passed &= VerifyInt64TryParse("123.000.000.000.000.000.000", NumberStyles.Any, germanCulture, 0, false);
- passed &= VerifyInt64TryParse("123,000,000,000,000,000,000", NumberStyles.Any, japaneseCulture, 0, false);
- passed &= VerifyInt64TryParse("123,000,000,000,000,000,000", NumberStyles.Integer, germanCulture, 0, false);
- passed &= VerifyInt64TryParse("123.000.000.000.000.000.000", NumberStyles.Integer, japaneseCulture, 0, false);
-
- //// Exception cases
- passed &= VerifyInt64TryParseException("5", NumberStyles.AllowHexSpecifier | NumberStyles.AllowParentheses, null, typeof(ArgumentException));
- passed &= VerifyInt64TryParseException("4", (NumberStyles)(-1), CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifyInt64TryParseException("4", (NumberStyles)0x10000, CultureInfo.InvariantCulture, typeof(ArgumentException));
-
- // NumberStyles/NFI variations
- //
- passed &= VerifyInt64TryParse("5", NumberStyles.Integer, corruptNFI, 5, true);
- passed &= VerifyInt64TryParse("5", NumberStyles.Number, corruptNFI, 5, true);
- passed &= VerifyInt64TryParse("5.0", NumberStyles.Number, corruptNFI, 5, true);
- passed &= VerifyInt64TryParse("5,0", NumberStyles.Number, corruptNFI, 0, false);
- passed &= VerifyInt64TryParse("5.0.0", NumberStyles.Number, corruptNFI, 0, false);
- passed &= VerifyInt64TryParse("$5.0", NumberStyles.Currency, corruptNFI, 5, true);
- passed &= VerifyInt64TryParse("$5,0", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyInt64TryParse("$5.0.0", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyInt64TryParse("5.0", NumberStyles.Currency, corruptNFI, 5, true);
- passed &= VerifyInt64TryParse("5,0", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyInt64TryParse("5.0.0", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyInt64TryParse("5.0", NumberStyles.Any, corruptNFI, 5, true);
- passed &= VerifyInt64TryParse("5,0", NumberStyles.Any, corruptNFI, 0, false);
- passed &= VerifyInt64TryParse("5.0.0", NumberStyles.Any, corruptNFI, 0, false);
- //
- passed &= VerifyInt64TryParse("5", NumberStyles.Integer, swappedNFI, 5, true);
- passed &= VerifyInt64TryParse("1,234", NumberStyles.Integer, swappedNFI, 0, false);
- passed &= VerifyInt64TryParse("5", NumberStyles.Number, swappedNFI, 5, true);
- passed &= VerifyInt64TryParse("5.0", NumberStyles.Number, swappedNFI, 5, true);
- passed &= VerifyInt64TryParse("1,234", NumberStyles.Number, swappedNFI, 1234, true);
- passed &= VerifyInt64TryParse("1,234.0", NumberStyles.Number, swappedNFI, 1234, true);
- passed &= VerifyInt64TryParse("5.000.000", NumberStyles.Number, swappedNFI, 0, false);
- passed &= VerifyInt64TryParse("5.000,00", NumberStyles.Number, swappedNFI, 0, false);
- passed &= VerifyInt64TryParse("5.000", NumberStyles.Currency, swappedNFI, 5, true); //???
- passed &= VerifyInt64TryParse("5.000,00", NumberStyles.Currency, swappedNFI, 0, false); //???
- passed &= VerifyInt64TryParse("$5.000", NumberStyles.Currency, swappedNFI, 5000, true);
- passed &= VerifyInt64TryParse("$5.000,00", NumberStyles.Currency, swappedNFI, 5000, true);
- passed &= VerifyInt64TryParse("5.000", NumberStyles.Any, swappedNFI, 5, true); //?
- passed &= VerifyInt64TryParse("5.000,00", NumberStyles.Any, swappedNFI, 0, false); //?
- passed &= VerifyInt64TryParse("$5.000", NumberStyles.Any, swappedNFI, 5000, true);
- passed &= VerifyInt64TryParse("$5.000,00", NumberStyles.Any, swappedNFI, 5000, true);
- passed &= VerifyInt64TryParse("5,0", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyInt64TryParse("$5,0", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyInt64TryParse("5,000", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyInt64TryParse("$5,000", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyInt64TryParse("5,000.0", NumberStyles.Currency, swappedNFI, 0, false);
- passed &= VerifyInt64TryParse("$5,000.0", NumberStyles.Currency, swappedNFI, 0, false);
- passed &= VerifyInt64TryParse("5,000", NumberStyles.Any, swappedNFI, 5, true);
- passed &= VerifyInt64TryParse("$5,000", NumberStyles.Any, swappedNFI, 5, true);
- passed &= VerifyInt64TryParse("5,000.0", NumberStyles.Any, swappedNFI, 0, false);
- passed &= VerifyInt64TryParse("$5,000.0", NumberStyles.Any, swappedNFI, 0, false);
- //
- passed &= VerifyInt64TryParse("5.0", NumberStyles.Number, distinctNFI, 5, true);
- passed &= VerifyInt64TryParse("1,234.0", NumberStyles.Number, distinctNFI, 1234, true);
- passed &= VerifyInt64TryParse("5.0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyInt64TryParse("1,234.0", NumberStyles.Currency, distinctNFI, 1234, true);
- passed &= VerifyInt64TryParse("5.0", NumberStyles.Any, distinctNFI, 5, true);
- passed &= VerifyInt64TryParse("1,234.0", NumberStyles.Any, distinctNFI, 1234, true);
- passed &= VerifyInt64TryParse("$5.0", NumberStyles.Currency, distinctNFI, 0, false);
- passed &= VerifyInt64TryParse("$5.0", NumberStyles.Any, distinctNFI, 0, false);
- passed &= VerifyInt64TryParse("5:0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyInt64TryParse("5;0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyInt64TryParse("$5:0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyInt64TryParse("5:0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyInt64TryParse("5:000", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyInt64TryParse("5;000", NumberStyles.Currency, distinctNFI, 5000, true);
- passed &= VerifyInt64TryParse("$5:0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyInt64TryParse("$5;0", NumberStyles.Currency, distinctNFI, 50, true);
- passed &= VerifyInt64TryParse("5:0", NumberStyles.Any, distinctNFI, 5, true);
- passed &= VerifyInt64TryParse("5;0", NumberStyles.Any, distinctNFI, 50, true);
- passed &= VerifyInt64TryParse("$5:0", NumberStyles.Any, distinctNFI, 5, true);
- passed &= VerifyInt64TryParse("$5;0", NumberStyles.Any, distinctNFI, 50, true);
- passed &= VerifyInt64TryParse("123,456;789.0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyInt64TryParse("123,456;789.0", NumberStyles.Currency, distinctNFI, 123456789, true);
- passed &= VerifyInt64TryParse("123,456;789.0", NumberStyles.Any, distinctNFI, 123456789, true);
- passed &= VerifyInt64TryParse("$123,456;789.0", NumberStyles.Any, distinctNFI, 0, false);
-
-
- // Should these pass or fail? Current parse behavior is to pass, so they might be
- // parse bugs, but they're not tryparse bugs.
- passed &= VerifyInt64Parse("5", NumberStyles.Float, goodNFI, 5);
- passed &= VerifyInt64TryParse("5", NumberStyles.Float, goodNFI, 5, true);
- passed &= VerifyInt64Parse("5", NumberStyles.AllowDecimalPoint, goodNFI, 5);
- passed &= VerifyInt64TryParse("5", NumberStyles.AllowDecimalPoint, goodNFI, 5, true);
- // I expect ArgumentException with an ambiguous NFI
- passed &= VerifyInt64Parse("^42", NumberStyles.Any, ambigNFI, -42);
- passed &= VerifyInt64TryParse("^42", NumberStyles.Any, ambigNFI, -42, true);
-
- /// END TEST CASES
- }
- catch (Exception e)
- {
- TestLibrary.Logging.WriteLine("Unexpected exception!! " + e.ToString());
- passed = false;
- }
-
- if (passed)
- {
- TestLibrary.Logging.WriteLine("paSs");
- return 100;
- }
- else
- {
- TestLibrary.Logging.WriteLine("FAiL");
- return 1;
- }
- }
-
- public static bool VerifyInt64TryParse(string value, Int64 expectedResult, bool expectedReturn)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Int64.TryParse, Value = '{0}', Expected Result = {1}, Expected Return = {2}",
- value, expectedResult, expectedReturn);
- }
- Int64 result = 0;
- try
- {
- bool returnValue = Int64.TryParse(value, out result);
- if (returnValue != expectedReturn)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedReturn, returnValue);
- return false;
- }
- if (result != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, result);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyInt64TryParse(string value, NumberStyles style, IFormatProvider provider, Int64 expectedResult, bool expectedReturn)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Int64.TryParse, Value = '{0}', Style = {1}, Provider = {2}, Expected Result = {3}, Expected Return = {4}",
- value, style, provider, expectedResult, expectedReturn);
- }
- Int64 result = 0;
- try
- {
- bool returnValue = Int64.TryParse(value, style, provider, out result);
- if (returnValue != expectedReturn)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Style = {1}, Provider = {2}, Expected Return = {3}, Actual Return = {4}",
- value, style, provider, expectedReturn, returnValue);
- return false;
- }
- if (result != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, result);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyInt64TryParseException(string value, NumberStyles style, IFormatProvider provider, Type exceptionType)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Int64.TryParse, Value = '{0}', Style = {1}, Provider = {2}, Expected Exception = {3}",
- value, style, provider, exceptionType);
- }
- try
- {
- Int64 result = 0;
- Boolean returnValue = Int64.TryParse(value, style, provider, out result);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifyInt64Parse(string value, Int64 expectedResult)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Int64.Parse, Value = '{0}', Expected Result, {1}",
- value, expectedResult);
- }
- try
- {
- Int64 returnValue = Int64.Parse(value);
- if (returnValue != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, returnValue);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyInt64Parse(string value, NumberStyles style, IFormatProvider provider, Int64 expectedResult)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Int64.Parse, Value = '{0}', Style = {1}, provider = {2}, Expected Result = {3}",
- value, style, provider, expectedResult);
- }
- try
- {
- Int64 returnValue = Int64.Parse(value, style, provider);
- if (returnValue != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, returnValue);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyInt64ParseException(string value, Type exceptionType)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Int64.Parse, Value = '{0}', Expected Exception, {1}",
- value, exceptionType);
- }
- try
- {
- Int64 returnValue = Int64.Parse(value);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifyInt64ParseException(string value, NumberStyles style, Type exceptionType)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Int64.Parse, Value = '{0}', Style = {1}, Expected Exception = {3}",
- value, style, exceptionType);
- }
- try
- {
- Int64 returnValue = Int64.Parse(value, style);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifyInt64ParseException(string value, NumberStyles style, IFormatProvider provider, Type exceptionType)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Int64.Parse, Value = '{0}', Style = {1}, Provider = {2}, Expected Exception = {3}",
- value, style, provider, exceptionType);
- }
- try
- {
- Int64 returnValue = Int64.Parse(value, style, provider);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-}
diff --git a/tests/src/CoreMangLib/cti/system/sbyte/SByteParse1.csproj b/tests/src/CoreMangLib/cti/system/sbyte/SByteParse1.csproj
deleted file mode 100644
index bbfa9b66cd..0000000000
--- a/tests/src/CoreMangLib/cti/system/sbyte/SByteParse1.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="sbyteparse1.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/sbyte/SByteParse2.csproj b/tests/src/CoreMangLib/cti/system/sbyte/SByteParse2.csproj
deleted file mode 100644
index f2a4de111e..0000000000
--- a/tests/src/CoreMangLib/cti/system/sbyte/SByteParse2.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="sbyteparse2.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/sbyte/SByteParse3.csproj b/tests/src/CoreMangLib/cti/system/sbyte/SByteParse3.csproj
deleted file mode 100644
index 61908510b4..0000000000
--- a/tests/src/CoreMangLib/cti/system/sbyte/SByteParse3.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="sbyteparse3.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/sbyte/SByteTryParse.csproj b/tests/src/CoreMangLib/cti/system/sbyte/SByteTryParse.csproj
deleted file mode 100644
index d428a3c246..0000000000
--- a/tests/src/CoreMangLib/cti/system/sbyte/SByteTryParse.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="sbytetryparse.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/sbyte/sbyteparse1.cs b/tests/src/CoreMangLib/cti/system/sbyte/sbyteparse1.cs
deleted file mode 100644
index 99227105cb..0000000000
--- a/tests/src/CoreMangLib/cti/system/sbyte/sbyteparse1.cs
+++ /dev/null
@@ -1,253 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-/// <summary>
-/// SByte.Parse(string)
-/// </summary>
-public class SByteParse1
-{
- public static int Main()
- {
- SByteParse1 sbyteParse1 = new SByteParse1();
- TestLibrary.TestFramework.BeginTestCase("SByteParse1");
- if (sbyteParse1.RunTests())
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("PASS");
- return 100;
- }
- else
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("FAIL");
- return 0;
- }
- }
- public bool RunTests()
- {
- bool retVal = true;
- TestLibrary.TestFramework.LogInformation("[Positive]");
- retVal = PosTest1() && retVal;
- retVal = PosTest2() && retVal;
- retVal = PosTest3() && retVal;
- retVal = PosTest4() && retVal;
- retVal = PosTest5() && retVal;
- TestLibrary.TestFramework.LogInformation("[Negative]");
- retVal = NegTest1() && retVal;
- retVal = NegTest2() && retVal;
- retVal = NegTest3() && retVal;
- retVal = NegTest4() && retVal;
- return retVal;
- }
- #region PositiveTest
- public bool PosTest1()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest1: the string represents SByte maxValue");
- try
- {
- string sourceStr = SByte.MaxValue.ToString();
- sbyte desSByte = sbyte.Parse(sourceStr);
- if (desSByte != SByte.MaxValue)
- {
- TestLibrary.TestFramework.LogError("001", "the ExpectResult is not the ActualResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("002", "Unexpect exception:" + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest2()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest2: the string represents SByte minValue");
- try
- {
- string sourceStr = SByte.MinValue.ToString();
- sbyte desSByte = sbyte.Parse(sourceStr);
- if (desSByte != SByte.MinValue)
- {
- TestLibrary.TestFramework.LogError("003", "the ExpectResult is not the ActualResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("004", "Unexpect exception:" + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest3()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest3: the string represents random SByte 1");
- try
- {
- SByte SByteVal = -012;
- string sourceStr = SByteVal.ToString();
- sbyte desSByte = sbyte.Parse(sourceStr);
- if (desSByte != -12)
- {
- TestLibrary.TestFramework.LogError("005", "the ExpectResult is not the ActualResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("006", "Unexpect exception:" + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest4()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest4: the string represents random SByte 2");
- try
- {
- SByte SByteVal = +012;
- string sourceStr = SByteVal.ToString();
- sbyte desSByte = sbyte.Parse(sourceStr);
- if (desSByte != 12)
- {
- TestLibrary.TestFramework.LogError("007", "the ExpectResult is not the ActualResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("008", "Unexpect exception:" + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest5()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest5: the string represents random SByte 3");
- try
- {
- SByte SByteVal = (sbyte)this.GetInt32(0, 127);
- string sourceStr = "\u0020" + "-" + SByteVal.ToString() + "\u0020";
- sbyte desSByte = sbyte.Parse(sourceStr);
- if (desSByte != SByteVal * (-1))
- {
- TestLibrary.TestFramework.LogError("009", "the ExpectResult is not the ActualResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("010", "Unexpect exception:" + e);
- retVal = false;
- }
- return retVal;
- }
- #endregion
- #region NegativeTest
- public bool NegTest1()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("NegTest1: the string is null");
- try
- {
- string sourceStr = null;
- sbyte desSByte = sbyte.Parse(sourceStr);
- TestLibrary.TestFramework.LogError("N001", "the string is null but not throw exception");
- retVal = false;
- }
- catch (ArgumentException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N002", "Unexpect exception:" + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest2()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("NegTest2: the string does not consist of an optional sign follow by a sequence of digit");
- try
- {
- string sourceStr = "helloworld";
- sbyte desSByte = sbyte.Parse(sourceStr);
- TestLibrary.TestFramework.LogError("N003", "the string does not consist of an optional sign follow by a sequence of digit but not throw exception");
- retVal = false;
- }
- catch (FormatException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N004", "Unexpect exception:" + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest3()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("NegTest3: the string represents digit less than SByte MinValue");
- try
- {
- string sourceStr = "-129";
- sbyte desSByte = sbyte.Parse(sourceStr);
- TestLibrary.TestFramework.LogError("N005", "the string represents digit less than SByte MinValue");
- retVal = false;
- }
- catch (OverflowException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N006", "Unexpect exception:" + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest4()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("NegTest4: the string represents digit greater than SByte MaxValue");
- try
- {
- string sourceStr = "128";
- sbyte desSByte = sbyte.Parse(sourceStr);
- TestLibrary.TestFramework.LogError("N007", "the string represents digit greater than SByte MaxValue but not throw exception");
- retVal = false;
- }
- catch (OverflowException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N008", "Unexpect exception:" + e);
- retVal = false;
- }
- return retVal;
- }
- #endregion
- #region HelpMethod
- private Int32 GetInt32(Int32 minValue, Int32 maxValue)
- {
- try
- {
- if (minValue == maxValue)
- {
- return minValue;
- }
- if (minValue < maxValue)
- {
- return minValue + TestLibrary.Generator.GetInt32(-55) % (maxValue - minValue);
- }
- }
- catch
- {
- throw;
- }
-
- return minValue;
- }
- #endregion
-}
diff --git a/tests/src/CoreMangLib/cti/system/sbyte/sbyteparse2.cs b/tests/src/CoreMangLib/cti/system/sbyte/sbyteparse2.cs
deleted file mode 100644
index 377168f7df..0000000000
--- a/tests/src/CoreMangLib/cti/system/sbyte/sbyteparse2.cs
+++ /dev/null
@@ -1,330 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Globalization;
-/// <summary>
-/// SByte.Parse(String,NumberStyle)
-/// </summary>
-public class SByteParse2
-{
- public static int Main()
- {
- SByteParse2 sbyteParse2 = new SByteParse2();
- TestLibrary.TestFramework.BeginTestCase("SByteParse2");
- if (sbyteParse2.RunTests())
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("PASS");
- return 100;
- }
- else
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("FAIL");
- return 0;
- }
- }
- public bool RunTests()
- {
- bool retVal = true;
- TestLibrary.TestFramework.LogInformation("[Positive]");
- retVal = PosTest1() && retVal;
- retVal = PosTest2() && retVal;
- retVal = PosTest3() && retVal;
- retVal = PosTest4() && retVal;
- retVal = PosTest5() && retVal;
- retVal = PosTest6() && retVal;
- retVal = PosTest7() && retVal;
- TestLibrary.TestFramework.LogInformation("[Negative]");
- retVal = NegTest1() && retVal;
- retVal = NegTest2() && retVal;
- retVal = NegTest3() && retVal;
- retVal = NegTest4() && retVal;
- retVal = NegTest5() && retVal;
- return retVal;
- }
- #region PositiveTest
- public bool PosTest1()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest1: the string represents SByte maxValue 1");
- try
- {
- string sourceStr = SByte.MaxValue.ToString();
- NumberStyles style = NumberStyles.Any;
- sbyte SByteVal = sbyte.Parse(sourceStr, style);
- if (SByteVal != sbyte.MaxValue)
- {
- TestLibrary.TestFramework.LogError("001", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest2()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest2: the string represents SByte maxValue 2");
- try
- {
- string sourceStr = "7f";
- NumberStyles style = NumberStyles.HexNumber;
- sbyte SByteVal = sbyte.Parse(sourceStr, style);
- if (SByteVal != sbyte.MaxValue)
- {
- TestLibrary.TestFramework.LogError("003", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest3()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest3: the string represents SByte minValue 1");
- try
- {
- string sourceStr = sbyte.MinValue.ToString();
- NumberStyles style = NumberStyles.Any;
- sbyte SByteVal = sbyte.Parse(sourceStr, style);
- if (SByteVal != sbyte.MinValue)
- {
- TestLibrary.TestFramework.LogError("005", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest4()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest4: the string represents SByte minValue 2");
- try
- {
- string sourceStr = "080";
- NumberStyles style = NumberStyles.HexNumber;
- sbyte SByteVal = sbyte.Parse(sourceStr, style);
- if (SByteVal != sbyte.MinValue)
- {
- TestLibrary.TestFramework.LogError("007", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("008", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest5()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest5: the string represents random SByte 1");
- try
- {
- SByte SByteVal = (sbyte)this.GetInt32(0, 127);
- NumberStyles style = NumberStyles.Any;
- string sourceStr = SByteVal.ToString();
- sbyte desSByte = sbyte.Parse(sourceStr, style);
- if (desSByte != SByteVal)
- {
- TestLibrary.TestFramework.LogError("009", "the ExpectResult is not the ActualResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("010", "Unexpect exception:" + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest6()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest6: the string represents random SByte 2");
- try
- {
- SByte SByteVal = (sbyte)this.GetInt32(0, 127);
- NumberStyles style = NumberStyles.Any;
- string sourceStr = "\u0020" + SByteVal.ToString() + "\u0020";
- sbyte desSByte = sbyte.Parse(sourceStr, style);
- if (desSByte != SByteVal)
- {
- TestLibrary.TestFramework.LogError("011", "the ExpectResult is not the ActualResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("012", "Unexpect exception:" + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest7()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("PosTest7: the string represents random SByte 3");
- try
- {
- SByte SByteVal = (sbyte)this.GetInt32(0, 127);
- NumberStyles style = NumberStyles.Any;
- string sourceStr = "\u0020" + "-" + SByteVal.ToString() + "\u0020";
- sbyte desSByte = sbyte.Parse(sourceStr, style);
- if (desSByte != SByteVal * (-1))
- {
- TestLibrary.TestFramework.LogError("013", "the ExpectResult is not the ActualResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("014", "Unexpect exception:" + e);
- retVal = false;
- }
- return retVal;
- }
- #endregion
- #region NegativeTest
- public bool NegTest1()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("NegTest1: the string is null");
- try
- {
- string sourceStr = null;
- NumberStyles style = NumberStyles.Any;
- sbyte desSByte = sbyte.Parse(sourceStr, style);
- TestLibrary.TestFramework.LogError("N001", "the string is null but not throw exception");
- retVal = false;
- }
- catch (ArgumentNullException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N002", "Unexpect exception:" + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest2()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("NegTest2: the string does not consist of an optional sign follow by a sequence of digit");
- try
- {
- string sourceStr = "helloworld";
- NumberStyles style = NumberStyles.Any;
- sbyte desSByte = sbyte.Parse(sourceStr, style);
- TestLibrary.TestFramework.LogError("N003", "the string does not consist of an optional sign follow by a sequence of digit but not throw exception");
- retVal = false;
- }
- catch (FormatException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N004", "Unexpect exception:" + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest3()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("NegTest3: the string represents digit less than SByte MinValue");
- try
- {
- string sourceStr = "-129";
- NumberStyles style = NumberStyles.Any;
- sbyte desSByte = sbyte.Parse(sourceStr, style);
- TestLibrary.TestFramework.LogError("N005", "the string represents digit less than SByte MinValue");
- retVal = false;
- }
- catch (OverflowException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N006", "Unexpect exception:" + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest4()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("NegTest4: the string represents digit greater than SByte MaxValue");
- try
- {
- string sourceStr = "128";
- NumberStyles style = NumberStyles.Any;
- sbyte desSByte = sbyte.Parse(sourceStr,style);
- TestLibrary.TestFramework.LogError("N007", "the string represents digit greater than SByte MaxValue but not throw exception");
- retVal = false;
- }
- catch (OverflowException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N008", "Unexpect exception:" + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest5()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("NegTest5: the NumberStyle value is not a NumberStyle");
- try
- {
- string sourceStr = this.GetInt32(0, 128).ToString();
- NumberStyles style = (NumberStyles)(-1);
- sbyte desSByte = sbyte.Parse(sourceStr, style);
- TestLibrary.TestFramework.LogError("N009", "the NumberStyle value is not a NumberStyle but not throw exception");
- retVal = false;
- }
- catch (ArgumentException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N010", "Unexpect exception:" + e);
- retVal = false;
- }
- return retVal;
- }
- #endregion
- #region HelpMethod
- private Int32 GetInt32(Int32 minValue, Int32 maxValue)
- {
- try
- {
- if (minValue == maxValue)
- {
- return minValue;
- }
- if (minValue < maxValue)
- {
- return minValue + TestLibrary.Generator.GetInt32(-55) % (maxValue - minValue);
- }
- }
- catch
- {
- throw;
- }
-
- return minValue;
- }
- #endregion
-}
diff --git a/tests/src/CoreMangLib/cti/system/sbyte/sbyteparse3.cs b/tests/src/CoreMangLib/cti/system/sbyte/sbyteparse3.cs
deleted file mode 100644
index db9939429d..0000000000
--- a/tests/src/CoreMangLib/cti/system/sbyte/sbyteparse3.cs
+++ /dev/null
@@ -1,402 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Globalization;
-/// <summary>
-/// SByte.Parse(String,NumberStyle,IFormatProvider)
-/// </summary>
-public class SByteParse3
-{
- public static int Main()
- {
- SByteParse3 sbyteParse3 = new SByteParse3();
- TestLibrary.TestFramework.BeginTestCase("SByteParse3");
- if (sbyteParse3.RunTests())
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("PASS");
- return 100;
- }
- else
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("FAIL");
- return 0;
- }
- }
- public bool RunTests()
- {
- bool retVal = true;
- TestLibrary.TestFramework.LogInformation("[Positive]");
- retVal = PosTest1() && retVal;
- retVal = PosTest2() && retVal;
- retVal = PosTest3() && retVal;
- retVal = PosTest4() && retVal;
- retVal = PosTest5() && retVal;
- retVal = PosTest6() && retVal;
- retVal = PosTest7() && retVal;
- retVal = PosTest8() && retVal;
- retVal = PosTest9() && retVal;
- TestLibrary.TestFramework.LogInformation("[Negative]");
- retVal = NegTest1() && retVal;
- retVal = NegTest2() && retVal;
- retVal = NegTest3() && retVal;
- retVal = NegTest4() && retVal;
- retVal = NegTest5() && retVal;
- return retVal;
- }
- #region PositiveTest
- public bool PosTest1()
- {
- bool retVal = true;
- IFormatProvider provider = new CultureInfo("en-us");
- TestLibrary.TestFramework.BeginScenario("PosTest1: the string represents SByte MaxValue 1");
- try
- {
- string sourceStr = SByte.MaxValue.ToString();
- NumberStyles style = NumberStyles.Any;
- sbyte SByteVale = sbyte.Parse(sourceStr, style, provider);
- if (SByteVale != sbyte.MaxValue)
- {
- TestLibrary.TestFramework.LogError("001", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest2()
- {
- bool retVal = true;
- IFormatProvider provider = new CultureInfo("el-GR");
- TestLibrary.TestFramework.BeginScenario("PosTest2: the string represents sbyte MaxValue 2");
- try
- {
- string sourceStr = sbyte.MaxValue.ToString();
- NumberStyles style = NumberStyles.Any;
- sbyte SByteVal = sbyte.Parse(sourceStr, style, provider);
- if (SByteVal != sbyte.MaxValue)
- {
- TestLibrary.TestFramework.LogError("003", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest3()
- {
- bool retVal = true;
- CultureInfo myculture = new CultureInfo("en-us");
- IFormatProvider provider = myculture.NumberFormat;
- TestLibrary.TestFramework.BeginScenario("PosTest3: the string represents sbyte MinValue 1");
- try
- {
- string sourceStr= sbyte.MinValue.ToString();
- NumberStyles style = NumberStyles.Any;
- sbyte SByteVal = sbyte.Parse(sourceStr, style, provider);
- if (SByteVal != sbyte.MinValue)
- {
- TestLibrary.TestFramework.LogError("005", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest4()
- {
- bool retVal = true;
- CultureInfo myculture = new CultureInfo("el-GR");
- IFormatProvider provider = myculture.NumberFormat;
- TestLibrary.TestFramework.BeginScenario("PosTest4: the string represents sbyte MinValue 2");
- try
- {
- string sourceStr= sbyte.MinValue.ToString();
- NumberStyles style = NumberStyles.Any;
- sbyte SByteVal = sbyte.Parse(sourceStr, style, provider);
- if (SByteVal != sbyte.MinValue)
- {
- TestLibrary.TestFramework.LogError("007", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("008", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest5()
- {
- bool retVal = true;
- CultureInfo mycultrue = new CultureInfo("en-us");
- IFormatProvider provider = mycultrue.NumberFormat;
- TestLibrary.TestFramework.BeginScenario("PosTest5: the string format is [ws][sign]digits[ws] 1");
- try
- {
- sbyte SByteVal = (sbyte)this.GetInt32(0, 127);
- string sourceStr = "\u0020" + "+" + SByteVal.ToString();
- NumberStyles style = NumberStyles.Any;
- sbyte result = sbyte.Parse(sourceStr, style, provider);
- if (result != SByteVal)
- {
- TestLibrary.TestFramework.LogError("009", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("010", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest6()
- {
- bool retVal = true;
- CultureInfo mycultrue = new CultureInfo("en-us");
- IFormatProvider provider = mycultrue.NumberFormat;
- TestLibrary.TestFramework.BeginScenario("PosTest6: the string format is [ws][sign]digits[ws] 2");
-
- try
- {
- sbyte SByteVal = (sbyte)this.GetInt32(0, 128);
- string sourceStr = "\u0020" + "-" + SByteVal.ToString();
- NumberStyles style = NumberStyles.Any;
- sbyte result = sbyte.Parse(sourceStr, style, provider);
- if (result != SByteVal * (-1))
- {
- TestLibrary.TestFramework.LogError("011", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("012", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest7()
- {
- bool retVal = true;
- CultureInfo mycultrue = new CultureInfo("en-us");
- IFormatProvider provider = mycultrue.NumberFormat;
- TestLibrary.TestFramework.BeginScenario("PosTest7: the string format is [ws][sign]digits[ws] 3");
-
- try
- {
- sbyte SByteVal = (sbyte)this.GetInt32(0, 128);
- string sourceStr = "\u0020" + "-" + SByteVal.ToString() + "\u0020";
- NumberStyles style = NumberStyles.Any;
- sbyte result = sbyte.Parse(sourceStr, style, provider);
- if (result != SByteVal * (-1))
- {
- TestLibrary.TestFramework.LogError("013", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("014", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest8()
- {
- bool retVal = true;
- CultureInfo mycultrue = new CultureInfo("en-us");
- IFormatProvider provider = mycultrue.NumberFormat;
- TestLibrary.TestFramework.BeginScenario("PosTest8: the string format is [ws][sign]digits[ws] 4");
-
- try
- {
- sbyte SByteVal = (sbyte)this.GetInt32(0, 128);
- string sourceStr = "\u0020" + "-0" + SByteVal.ToString() + "\u0020";
- NumberStyles style = NumberStyles.Any;
- sbyte result = sbyte.Parse(sourceStr, style, provider);
- if (result != SByteVal * (-1))
- {
- TestLibrary.TestFramework.LogError("015", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("016", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest9()
- {
- bool retVal = true;
- CultureInfo mycultrue = new CultureInfo("en-us");
- IFormatProvider provider = mycultrue.NumberFormat;
- TestLibrary.TestFramework.BeginScenario("PosTest9: the string formed with acceptable characters");
-
- try
- {
- string sourceStr = "\u0020" + "7f" + "\u0020";
- NumberStyles style = NumberStyles.HexNumber;
- sbyte result = sbyte.Parse(sourceStr, style, provider);
- if (result != sbyte.MaxValue)
- {
- TestLibrary.TestFramework.LogError("017", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("018", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- #endregion
- #region NegativeTest
- public bool NegTest1()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("NegTest1: the string is null");
- try
- {
- string sourceStr = null;
- NumberStyles style = NumberStyles.Any;
- IFormatProvider provider = new CultureInfo("en-us");
- sbyte desSByte = sbyte.Parse(sourceStr, style, provider);
- TestLibrary.TestFramework.LogError("N001", "the string is null but not throw exception");
- retVal = false;
- }
- catch (ArgumentNullException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N002", "Unexpect exception:" + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest2()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("NegTest2: the string does not consist of an optional sign follow by a sequence of digit");
- try
- {
- string sourceStr = "helloworld";
- NumberStyles style = NumberStyles.Any;
- IFormatProvider provider = new CultureInfo("en-us");
- sbyte desSByte = sbyte.Parse(sourceStr, style, provider);
- TestLibrary.TestFramework.LogError("N003", "the string does not consist of an optional sign follow by a sequence of digit but not throw exception");
- retVal = false;
- }
- catch (FormatException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N004", "Unexpect exception:" + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest3()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("NegTest3: the string represents digit less than SByte MinValue");
- try
- {
- string sourceStr = "-129";
- NumberStyles style = NumberStyles.Any;
- IFormatProvider provider = new CultureInfo("en-us");
- sbyte desSByte = sbyte.Parse(sourceStr, style, provider);
- TestLibrary.TestFramework.LogError("N005", "the string represents digit less than SByte MinValue");
- retVal = false;
- }
- catch (OverflowException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N006", "Unexpect exception:" + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest4()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("NegTest4: the string represents digit greater than SByte MaxValue");
- try
- {
- string sourceStr = "128";
- NumberStyles style = NumberStyles.Any;
- IFormatProvider provider = new CultureInfo("en-us");
- sbyte desSByte = sbyte.Parse(sourceStr, style, provider);
- TestLibrary.TestFramework.LogError("N007", "the string represents digit greater than SByte MaxValue but not throw exception");
- retVal = false;
- }
- catch (OverflowException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N008", "Unexpect exception:" + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest5()
- {
- bool retVal = true;
- TestLibrary.TestFramework.BeginScenario("NegTest5: the NumberStyle value is not a NumberStyle");
- try
- {
- string sourceStr = this.GetInt32(0, 128).ToString();
- NumberStyles style = (NumberStyles)(-1);
- IFormatProvider provider = new CultureInfo("en-us");
- sbyte desSByte = sbyte.Parse(sourceStr, style, provider);
- TestLibrary.TestFramework.LogError("N009", "the NumberStyle value is not a NumberStyle but not throw exception");
- retVal = false;
- }
- catch (ArgumentException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N010", "Unexpect exception:" + e);
- retVal = false;
- }
- return retVal;
- }
- #endregion
- #region HelpMethod
- private Int32 GetInt32(Int32 minValue, Int32 maxValue)
- {
- try
- {
- if (minValue == maxValue)
- {
- return minValue;
- }
- if (minValue < maxValue)
- {
- return minValue + TestLibrary.Generator.GetInt32(-55) % (maxValue - minValue);
- }
- }
- catch
- {
- throw;
- }
-
- return minValue;
- }
- #endregion
-}
diff --git a/tests/src/CoreMangLib/cti/system/sbyte/sbytetryparse.cs b/tests/src/CoreMangLib/cti/system/sbyte/sbytetryparse.cs
deleted file mode 100644
index b9490e5b23..0000000000
--- a/tests/src/CoreMangLib/cti/system/sbyte/sbytetryparse.cs
+++ /dev/null
@@ -1,499 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Globalization;
-
-// CoreCLR Port from Co7524TryParse_all.cs
-// Tests SByte.TryParse(String), SByte.TryParse(String, NumberStyles, IFormatProvider, ref SByte)
-// 2003/04/01 KatyK
-// 2007/06/28 adapted by MarielY
-
-public class SByteTryParse
-{
- static bool verbose = false;
-
- public static int Main()
- {
- bool passed = true;
-
- try
- {
- // Make the test culture independent
- TestLibrary.Utilities.CurrentCulture = CultureInfo.InvariantCulture;
-
- // Set up NFIs to use
- NumberFormatInfo goodNFI = new NumberFormatInfo();
-
- NumberFormatInfo corruptNFI = new NumberFormatInfo(); // DecimalSeparator == GroupSeparator
- corruptNFI.NumberDecimalSeparator = ".";
- corruptNFI.NumberGroupSeparator = ".";
- corruptNFI.CurrencyDecimalSeparator = ".";
- corruptNFI.CurrencyGroupSeparator = ".";
- corruptNFI.CurrencySymbol = "$";
-
- NumberFormatInfo swappedNFI = new NumberFormatInfo(); // DecimalSeparator & GroupSeparator swapped
- swappedNFI.NumberDecimalSeparator = ".";
- swappedNFI.NumberGroupSeparator = ",";
- swappedNFI.CurrencyDecimalSeparator = ",";
- swappedNFI.CurrencyGroupSeparator = ".";
- swappedNFI.CurrencySymbol = "$";
-
- NumberFormatInfo distinctNFI = new NumberFormatInfo(); // DecimalSeparator & GroupSeparator distinct
- distinctNFI.NumberDecimalSeparator = ".";
- distinctNFI.NumberGroupSeparator = ",";
- distinctNFI.CurrencyDecimalSeparator = ":";
- distinctNFI.CurrencyGroupSeparator = ";";
- distinctNFI.CurrencySymbol = "$";
-
- NumberFormatInfo customNFI = new NumberFormatInfo();
- customNFI.NegativeSign = "^";
-
- NumberFormatInfo ambigNFI = new NumberFormatInfo();
- ambigNFI.NegativeSign = "^";
- ambigNFI.CurrencySymbol = "^";
-
- CultureInfo germanCulture = new CultureInfo("de-DE");
- CultureInfo japaneseCulture;
-
- try
- {
- japaneseCulture = new CultureInfo("ja-JP");
- }
- catch (Exception)
- {
- TestLibrary.Logging.WriteLine("East Asian Languages are not installed. Skiping Japanese culture tests.");
- japaneseCulture = null;
- }
-
- /////////// Parse(String) - We include Parse for comparison
- passed &= VerifySByteParse("5", 5);
- passed &= VerifySByteParse("-5", -5);
- passed &= VerifySByteParse("5 ", 5);
- passed &= VerifySByteParse("5\0", 5);
- passed &= VerifySByteParse("5", NumberStyles.Integer, CultureInfo.InvariantCulture, 5);
- passed &= VerifySByteParse("-5", NumberStyles.Integer, CultureInfo.InvariantCulture, -5);
- passed &= VerifySByteParse("5 \0", NumberStyles.Integer, CultureInfo.InvariantCulture, 5);
- passed &= VerifySByteParse("5\0\0\0", NumberStyles.Integer, CultureInfo.InvariantCulture, 5);
- passed &= VerifySByteParse("12", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0x12);
- passed &= VerifySByteParse("fF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, -1);
- passed &= VerifySByteParse("5", NumberStyles.Integer, goodNFI, 5);
- passed &= VerifySByteParse("123", NumberStyles.Integer, germanCulture, 123);
- passed &= VerifySByteParse("123", NumberStyles.Integer, japaneseCulture, 123);
- passed &= VerifySByteParse("123,000", NumberStyles.AllowDecimalPoint, germanCulture, 123);
- passed &= VerifySByteParse("123.000", NumberStyles.AllowDecimalPoint, japaneseCulture, 123);
- passed &= VerifySByteParse("5,00 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Any, germanCulture, 5); // currency
- //
- passed &= VerifySByteParse("5", NumberStyles.Integer, corruptNFI, 5);
- passed &= VerifySByteParse("5", NumberStyles.Number, corruptNFI, 5);
- passed &= VerifySByteParse("5.0", NumberStyles.Number, corruptNFI, 5);
- passed &= VerifySByteParseException("5,0", NumberStyles.Number, corruptNFI, typeof(FormatException));
- passed &= VerifySByteParseException("5.0.0", NumberStyles.Number, corruptNFI, typeof(FormatException));
- passed &= VerifySByteParse("$5.0", NumberStyles.Currency, corruptNFI, 5);
- passed &= VerifySByteParseException("$5,0", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifySByteParseException("$5.0.0", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifySByteParse("5.0", NumberStyles.Currency, corruptNFI, 5);
- passed &= VerifySByteParseException("5,0", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifySByteParseException("5.0.0", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifySByteParse("5.0", NumberStyles.Any, corruptNFI, 5);
- passed &= VerifySByteParseException("5,0", NumberStyles.Any, corruptNFI, typeof(FormatException));
- passed &= VerifySByteParseException("5.0.0", NumberStyles.Any, corruptNFI, typeof(FormatException));
- //
- passed &= VerifySByteParse("5", NumberStyles.Integer, swappedNFI, 5);
- passed &= VerifySByteParse("5", NumberStyles.Number, swappedNFI, 5);
- passed &= VerifySByteParse("5.0", NumberStyles.Number, swappedNFI, 5);
- passed &= VerifySByteParseException("5.000.000", NumberStyles.Number, swappedNFI, typeof(FormatException));
- passed &= VerifySByteParse("5.0", NumberStyles.Currency, swappedNFI, 5); //???
- passed &= VerifySByteParse("$5.0", NumberStyles.Currency, swappedNFI, 50);
- passed &= VerifySByteParse("5.0", NumberStyles.Any, swappedNFI, 5); //?
- passed &= VerifySByteParse("$5.0", NumberStyles.Any, swappedNFI, 50);
- passed &= VerifySByteParse("5,0", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifySByteParse("$5,0", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifySByteParse("5,000", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifySByteParse("$5,000", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifySByteParse("5,000", NumberStyles.Any, swappedNFI, 5);
- passed &= VerifySByteParse("$5,000", NumberStyles.Any, swappedNFI, 5);
- //
- passed &= VerifySByteParse("5.0", NumberStyles.Number, distinctNFI, 5);
- passed &= VerifySByteParse("5.0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifySByteParse("5.0", NumberStyles.Any, distinctNFI, 5);
- passed &= VerifySByteParseException("$5.0", NumberStyles.Currency, distinctNFI, typeof(FormatException));
- passed &= VerifySByteParseException("$5.0", NumberStyles.Any, distinctNFI, typeof(FormatException));
- passed &= VerifySByteParseException("5:0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifySByteParseException("$5:0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifySByteParse("5:0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifySByteParse("$5:0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifySByteParse("5:0", NumberStyles.Any, distinctNFI, 5);
- passed &= VerifySByteParse("$5:0", NumberStyles.Any, distinctNFI, 5);
- //
- passed &= VerifySByteParseException("200", typeof(OverflowException));
- passed &= VerifySByteParseException("-200", typeof(OverflowException));
- passed &= VerifySByteParseException("Garbage", typeof(FormatException));
- passed &= VerifySByteParseException("5\0Garbage", typeof(FormatException));
- passed &= VerifySByteParseException(null, typeof(ArgumentNullException));
- passed &= VerifySByteParseException("1FF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, typeof(OverflowException));
- passed &= VerifySByteParseException("FFFFFFFF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, typeof(OverflowException));
- passed &= VerifySByteParseException("5", NumberStyles.AllowHexSpecifier | NumberStyles.AllowParentheses, null, typeof(ArgumentException));
- passed &= VerifySByteParseException("4", (NumberStyles)(-1), typeof(ArgumentException));
- passed &= VerifySByteParseException("4", (NumberStyles)0x10000, typeof(ArgumentException));
- passed &= VerifySByteParseException("4", (NumberStyles)(-1), CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifySByteParseException("4", (NumberStyles)0x10000, CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifySByteParseException("123.000", NumberStyles.Any, germanCulture, typeof(OverflowException));
- passed &= VerifySByteParseException("123,000", NumberStyles.Any, japaneseCulture, typeof(OverflowException));
- passed &= VerifySByteParseException("123,000", NumberStyles.Integer, germanCulture, typeof(FormatException));
- passed &= VerifySByteParseException("123.000", NumberStyles.Integer, japaneseCulture, typeof(FormatException));
- passed &= VerifySByteParseException("5,00 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Integer, germanCulture, typeof(FormatException)); // currency
-
-
- /////////// TryParse(String)
- //// Pass cases
- passed &= VerifySByteTryParse("5", 5, true);
- passed &= VerifySByteTryParse("-5", -5, true);
- passed &= VerifySByteTryParse(" 5 ", 5, true);
- passed &= VerifySByteTryParse("5\0", 5, true);
- passed &= VerifySByteTryParse("5 \0", 5, true);
- passed &= VerifySByteTryParse("5\0\0\0", 5, true);
- passed &= VerifySByteTryParse(SByte.MaxValue.ToString(), SByte.MaxValue, true);
- passed &= VerifySByteTryParse(SByte.MinValue.ToString(), SByte.MinValue, true);
-
- //// Fail cases
- passed &= VerifySByteTryParse(null, 0, false);
- passed &= VerifySByteTryParse("", 0, false);
- passed &= VerifySByteTryParse("Garbage", 0, false);
- passed &= VerifySByteTryParse("5\0Garbage", 0, false);
- passed &= VerifySByteTryParse("300", 0, false);
- passed &= VerifySByteTryParse("FF", 0, false);
- passed &= VerifySByteTryParse("27.3", 0, false);
- passed &= VerifySByteTryParse("23 5", 0, false);
- passed &= VerifySByteTryParse("200", 0, false);
- passed &= VerifySByteTryParse("-200", 0, false);
-
-
- /////////// TryParse(TryParse(String, NumberStyles, IFormatProvider, ref SByte)
- //// Pass cases
- passed &= VerifySByteTryParse("5", NumberStyles.Integer, CultureInfo.InvariantCulture, 5, true);
- passed &= VerifySByteTryParse("-5", NumberStyles.Integer, CultureInfo.InvariantCulture, -5, true);
- // Variations on NumberStyles
- passed &= VerifySByteTryParse("12", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0x12, true);
- passed &= VerifySByteTryParse("FF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, -1, true);
- passed &= VerifySByteTryParse("fF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, -1, true);
- passed &= VerifySByteTryParse(" 5", NumberStyles.AllowLeadingWhite, goodNFI, 5, true);
- passed &= VerifySByteTryParse("5", NumberStyles.Number, goodNFI, 5, true);
- // Variations on IFP
- passed &= VerifySByteTryParse("5", NumberStyles.Integer, goodNFI, 5, true);
- passed &= VerifySByteTryParse("5", NumberStyles.Integer, null, 5, true);
- passed &= VerifySByteTryParse("5", NumberStyles.Integer, new DateTimeFormatInfo(), 5, true);
- passed &= VerifySByteTryParse("^42", NumberStyles.Any, customNFI, -42, true);
- passed &= VerifySByteTryParse("123", NumberStyles.Integer, germanCulture, 123, true);
- passed &= VerifySByteTryParse("123", NumberStyles.Integer, japaneseCulture, 123, true);
- passed &= VerifySByteTryParse("123,000", NumberStyles.AllowDecimalPoint, germanCulture, 123, true);
- passed &= VerifySByteTryParse("123.000", NumberStyles.AllowDecimalPoint, japaneseCulture, 123, true);
- passed &= VerifySByteTryParse("5,00 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Any, germanCulture, 5, true); // currency
-
- //// Fail cases
- passed &= VerifySByteTryParse("FF", NumberStyles.Integer, CultureInfo.InvariantCulture, 0, false);
- passed &= VerifySByteTryParse("1FF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0, false);
- passed &= VerifySByteTryParse("FFFFFFFF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0, false);
- passed &= VerifySByteTryParse("-42", NumberStyles.Any, customNFI, 0, false);
- passed &= VerifySByteTryParse("5.3", NumberStyles.AllowDecimalPoint, goodNFI, 0, false);
- passed &= VerifySByteTryParse("5 ", NumberStyles.AllowLeadingWhite, goodNFI, 0, false);
- passed &= VerifySByteTryParse("123.000", NumberStyles.Any, germanCulture, 0, false);
- passed &= VerifySByteTryParse("123,000", NumberStyles.Any, japaneseCulture, 0, false);
- passed &= VerifySByteTryParse("123,000", NumberStyles.Integer, germanCulture, 0, false);
- passed &= VerifySByteTryParse("123.000", NumberStyles.Integer, japaneseCulture, 0, false);
- passed &= VerifySByteTryParse("5,00 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Integer, germanCulture, 0, false); // currency
-
- //// Exception cases
- passed &= VerifySByteTryParseException("5", NumberStyles.AllowHexSpecifier | NumberStyles.AllowParentheses, null, typeof(ArgumentException));
- passed &= VerifySByteTryParseException("4", (NumberStyles)(-1), CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifySByteTryParseException("4", (NumberStyles)0x10000, CultureInfo.InvariantCulture, typeof(ArgumentException));
-
- // NumberStyles/NFI variations
- //
- passed &= VerifySByteTryParse("5", NumberStyles.Integer, corruptNFI, 5, true);
- passed &= VerifySByteTryParse("5", NumberStyles.Number, corruptNFI, 5, true);
- passed &= VerifySByteTryParse("5.0", NumberStyles.Number, corruptNFI, 5, true);
- passed &= VerifySByteTryParse("5,0", NumberStyles.Number, corruptNFI, 0, false);
- passed &= VerifySByteTryParse("5.0.0", NumberStyles.Number, corruptNFI, 0, false);
- passed &= VerifySByteTryParse("$5.0", NumberStyles.Currency, corruptNFI, 5, true);
- passed &= VerifySByteTryParse("$5,0", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifySByteTryParse("$5.0.0", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifySByteTryParse("5.0", NumberStyles.Currency, corruptNFI, 5, true);
- passed &= VerifySByteTryParse("5,0", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifySByteTryParse("5.0.0", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifySByteTryParse("5.0", NumberStyles.Any, corruptNFI, 5, true);
- passed &= VerifySByteTryParse("5,0", NumberStyles.Any, corruptNFI, 0, false);
- passed &= VerifySByteTryParse("5.0.0", NumberStyles.Any, corruptNFI, 0, false);
- //
- passed &= VerifySByteTryParse("5", NumberStyles.Integer, swappedNFI, 5, true);
- passed &= VerifySByteTryParse("5", NumberStyles.Number, swappedNFI, 5, true);
- passed &= VerifySByteTryParse("5.0", NumberStyles.Number, swappedNFI, 5, true);
- passed &= VerifySByteTryParse("5.000.000", NumberStyles.Number, swappedNFI, 0, false);
- passed &= VerifySByteTryParse("5.0", NumberStyles.Currency, swappedNFI, 5, true); //???
- passed &= VerifySByteTryParse("$5.0", NumberStyles.Currency, swappedNFI, 50, true);
- passed &= VerifySByteTryParse("5.0", NumberStyles.Any, swappedNFI, 5, true); //?
- passed &= VerifySByteTryParse("$5.0", NumberStyles.Any, swappedNFI, 50, true);
- passed &= VerifySByteTryParse("5,0", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifySByteTryParse("$5,0", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifySByteTryParse("5,000", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifySByteTryParse("$5,000", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifySByteTryParse("5,000", NumberStyles.Any, swappedNFI, 5, true);
- passed &= VerifySByteTryParse("$5,000", NumberStyles.Any, swappedNFI, 5, true);
- //
- passed &= VerifySByteTryParse("5.0", NumberStyles.Number, distinctNFI, 5, true);
- passed &= VerifySByteTryParse("5.0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifySByteTryParse("5.0", NumberStyles.Any, distinctNFI, 5, true);
- passed &= VerifySByteTryParse("$5.0", NumberStyles.Currency, distinctNFI, 0, false);
- passed &= VerifySByteTryParse("$5.0", NumberStyles.Any, distinctNFI, 0, false);
- passed &= VerifySByteTryParse("5:0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifySByteTryParse("$5:0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifySByteTryParse("5:0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifySByteTryParse("$5:0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifySByteTryParse("5:0", NumberStyles.Any, distinctNFI, 5, true);
- passed &= VerifySByteTryParse("$5:0", NumberStyles.Any, distinctNFI, 5, true);
-
-
- // Should these pass or fail? Current parse behavior is to pass, so they might be
- // parse bugs, but they're not tryparse bugs.
- passed &= VerifySByteParse("5", NumberStyles.Float, goodNFI, 5);
- passed &= VerifySByteTryParse("5", NumberStyles.Float, goodNFI, 5, true);
- passed &= VerifySByteParse("5", NumberStyles.AllowDecimalPoint, goodNFI, 5);
- passed &= VerifySByteTryParse("5", NumberStyles.AllowDecimalPoint, goodNFI, 5, true);
- // I expect ArgumentException with an ambiguous NFI
- passed &= VerifySByteParse("^42", NumberStyles.Any, ambigNFI, -42);
- passed &= VerifySByteTryParse("^42", NumberStyles.Any, ambigNFI, -42, true);
-
- /// END TEST CASES
- }
- catch (Exception e)
- {
- TestLibrary.Logging.WriteLine("Unexpected exception!! " + e.ToString());
- passed = false;
- }
-
- if (passed)
- {
- TestLibrary.Logging.WriteLine("paSs");
- return 100;
- }
- else
- {
- TestLibrary.Logging.WriteLine("FAiL");
- return 1;
- }
- }
-
- public static bool VerifySByteTryParse(string value, SByte expectedResult, bool expectedReturn)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: SByte.TryParse, Value = '{0}', Expected Result = {1}, Expected Return = {2}",
- value, expectedResult, expectedReturn);
- }
- SByte result = 0;
- try
- {
- bool returnValue = SByte.TryParse(value, out result);
- if (returnValue != expectedReturn)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedReturn, returnValue);
- return false;
- }
- if (result != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, result);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifySByteTryParse(string value, NumberStyles style, IFormatProvider provider, SByte expectedResult, bool expectedReturn)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: SByte.TryParse, Value = '{0}', Style = {1}, Provider = {2}, Expected Result = {3}, Expected Return = {4}",
- value, style, provider, expectedResult, expectedReturn);
- }
- SByte result = 0;
- try
- {
- bool returnValue = SByte.TryParse(value, style, provider, out result);
- if (returnValue != expectedReturn)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Style = {1}, Provider = {2}, Expected Return = {3}, Actual Return = {4}",
- value, style, provider, expectedReturn, returnValue);
- return false;
- }
- if (result != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, result);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifySByteTryParseException(string value, NumberStyles style, IFormatProvider provider, Type exceptionType)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: SByte.TryParse, Value = '{0}', Style = {1}, Provider = {2}, Expected Exception = {3}",
- value, style, provider, exceptionType);
- }
- try
- {
- SByte result = 0;
- Boolean returnValue = SByte.TryParse(value, style, provider, out result);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifySByteParse(string value, SByte expectedResult)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: SByte.Parse, Value = '{0}', Expected Result, {1}",
- value, expectedResult);
- }
- try
- {
- SByte returnValue = SByte.Parse(value);
- if (returnValue != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, returnValue);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifySByteParse(string value, NumberStyles style, IFormatProvider provider, SByte expectedResult)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: SByte.Parse, Value = '{0}', Style = {1}, provider = {2}, Expected Result = {3}",
- value, style, provider, expectedResult);
- }
- try
- {
- SByte returnValue = SByte.Parse(value, style, provider);
- if (returnValue != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, returnValue);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifySByteParseException(string value, Type exceptionType)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: SByte.Parse, Value = '{0}', Expected Exception, {1}",
- value, exceptionType);
- }
- try
- {
- SByte returnValue = SByte.Parse(value);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifySByteParseException(string value, NumberStyles style, Type exceptionType)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: SByte.Parse, Value = '{0}', Style = {1}, Expected Exception = {3}",
- value, style, exceptionType);
- }
- try
- {
- SByte returnValue = SByte.Parse(value, style);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifySByteParseException(string value, NumberStyles style, IFormatProvider provider, Type exceptionType)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: SByte.Parse, Value = '{0}', Style = {1}, Provider = {2}, Expected Exception = {3}",
- value, style, provider, exceptionType);
- }
- try
- {
- SByte returnValue = SByte.Parse(value, style, provider);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-}
diff --git a/tests/src/CoreMangLib/cti/system/single/SingleParse1.csproj b/tests/src/CoreMangLib/cti/system/single/SingleParse1.csproj
deleted file mode 100644
index 77cdfff06e..0000000000
--- a/tests/src/CoreMangLib/cti/system/single/SingleParse1.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="singleparse1.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/single/SingleParse2.csproj b/tests/src/CoreMangLib/cti/system/single/SingleParse2.csproj
deleted file mode 100644
index 34932f0b32..0000000000
--- a/tests/src/CoreMangLib/cti/system/single/SingleParse2.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="singleparse2.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/single/SingleTryParse.csproj b/tests/src/CoreMangLib/cti/system/single/SingleTryParse.csproj
deleted file mode 100644
index ccec436685..0000000000
--- a/tests/src/CoreMangLib/cti/system/single/SingleTryParse.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="singletryparse.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/single/singleparse1.cs b/tests/src/CoreMangLib/cti/system/single/singleparse1.cs
deleted file mode 100644
index 16429b9da3..0000000000
--- a/tests/src/CoreMangLib/cti/system/single/singleparse1.cs
+++ /dev/null
Binary files differ
diff --git a/tests/src/CoreMangLib/cti/system/single/singleparse2.cs b/tests/src/CoreMangLib/cti/system/single/singleparse2.cs
deleted file mode 100644
index 654dc704e3..0000000000
--- a/tests/src/CoreMangLib/cti/system/single/singleparse2.cs
+++ /dev/null
Binary files differ
diff --git a/tests/src/CoreMangLib/cti/system/single/singletryparse.cs b/tests/src/CoreMangLib/cti/system/single/singletryparse.cs
deleted file mode 100644
index 9c4392ec06..0000000000
--- a/tests/src/CoreMangLib/cti/system/single/singletryparse.cs
+++ /dev/null
@@ -1,615 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Globalization;
-
-// CoreCLR Port from Co7533TryParse_all.cs
-// Tests Single.TryParse(String), Single.TryParse(String, NumberStyles, IFormatProvider, ref Single)
-// 2003/04/02 KatyK
-// 2007/06/28 adapted by MarielY
-
-public class SingleTryParse
-{
- static bool verbose = false;
-
- public static int Main()
- {
- bool passed = true;
-
- try
- {
- // Make the test culture independent
- TestLibrary.Utilities.CurrentCulture = CultureInfo.InvariantCulture;
-
- // Set up NFIs to use
- NumberFormatInfo goodNFI = new NumberFormatInfo();
-
- NumberFormatInfo corruptNFI = new NumberFormatInfo(); // DecimalSeparator == GroupSeparator
- corruptNFI.NumberDecimalSeparator = ".";
- corruptNFI.NumberGroupSeparator = ".";
- corruptNFI.CurrencyDecimalSeparator = ".";
- corruptNFI.CurrencyGroupSeparator = ".";
- corruptNFI.CurrencySymbol = "$";
-
- NumberFormatInfo swappedNFI = new NumberFormatInfo(); // DecimalSeparator & GroupSeparator swapped
- swappedNFI.NumberDecimalSeparator = ".";
- swappedNFI.NumberGroupSeparator = ",";
- swappedNFI.CurrencyDecimalSeparator = ",";
- swappedNFI.CurrencyGroupSeparator = ".";
- swappedNFI.CurrencySymbol = "$";
-
- NumberFormatInfo distinctNFI = new NumberFormatInfo(); // DecimalSeparator & GroupSeparator distinct
- distinctNFI.NumberDecimalSeparator = ".";
- distinctNFI.NumberGroupSeparator = ",";
- distinctNFI.CurrencyDecimalSeparator = ":";
- distinctNFI.CurrencyGroupSeparator = ";";
- distinctNFI.CurrencySymbol = "$";
-
- NumberFormatInfo customNFI = new NumberFormatInfo();
- customNFI.NegativeSign = "^";
-
- NumberFormatInfo ambigNFI = new NumberFormatInfo();
- ambigNFI.NegativeSign = "^";
- ambigNFI.CurrencySymbol = "^";
-
- CultureInfo germanCulture = new CultureInfo("de-DE");
- CultureInfo japaneseCulture;
-
- try
- {
- japaneseCulture = new CultureInfo("ja-JP");
- }
- catch (Exception)
- {
- TestLibrary.Logging.WriteLine("East Asian Languages are not installed. Skiping Japanese culture tests.");
- japaneseCulture = null;
- }
-
- // Parse tests included for comparison/regression
- passed &= VerifySingleParse("0", 0);
- passed &= VerifySingleParse("5", 5);
- passed &= VerifySingleParse("-5", -5);
- passed &= VerifySingleParse("5 ", 5);
- passed &= VerifySingleParse("5\0", 5);
- passed &= VerifySingleParse("893382737", 893382737);
- passed &= VerifySingleParse("-893382737", -893382737);
- passed &= VerifySingleParse("1234567891", 1234567891);
- passed &= VerifySingleParse("-1234567891", -1234567891);
- passed &= VerifySingleParse("123456789123456789", 123456789123456789);
- passed &= VerifySingleParse("-123456789123456789", -123456789123456789);
- passed &= VerifySingleParse("5", NumberStyles.Integer, CultureInfo.InvariantCulture, 5);
- passed &= VerifySingleParse("-5", NumberStyles.Integer, CultureInfo.InvariantCulture, -5);
- passed &= VerifySingleParse("5 \0", NumberStyles.Integer, CultureInfo.InvariantCulture, 5);
- passed &= VerifySingleParse("5\0\0\0", NumberStyles.Integer, CultureInfo.InvariantCulture, 5);
- passed &= VerifySingleParse("5", NumberStyles.Integer, goodNFI, 5);
- passed &= VerifySingleParse("5.0", NumberStyles.AllowDecimalPoint, goodNFI, 5);
- passed &= VerifySingleParse("5.3", NumberStyles.AllowDecimalPoint, goodNFI, 5.3f);
- passed &= VerifySingleParse("123456789123456789123", 123456789123456789123.0f);
- passed &= VerifySingleParse("-123456789123456789123", -123456789123456789123.0f);
- passed &= VerifySingleParse("18446744073709551615", 18446744073709551615.0f);
- passed &= VerifySingleParse("79228162514264337593543950335", 79228162514264337593543950335.0f);
- passed &= VerifySingleParse("-79228162514264337593543950335", -79228162514264337593543950335.0f);
- passed &= VerifySingleParse("5.555555555", 5.555555555f);
- passed &= VerifySingleParse("1.000000", 1.0f);
- passed &= VerifySingleParse("79228162514264337593543950336", 79228162514264337593543950336.0f);
- passed &= VerifySingleParse("-79228162514264337593543950336", -79228162514264337593543950336.0f);
- passed &= VerifySingleParse("3.40282347E+38", NumberStyles.Float | NumberStyles.AllowExponent, null, (float)3.40282347E+38);
- passed &= VerifySingleParse("-3.40282347E+38 ", NumberStyles.Float | NumberStyles.AllowExponent, null, (float)-3.40282347E+38);
- passed &= VerifySingleParse("3.402822E+38", NumberStyles.Float | NumberStyles.AllowExponent, null, 3.402822E+38f);
- passed &= VerifySingleParse("-3.402822E+38", NumberStyles.Float | NumberStyles.AllowExponent, null, -3.402822E+38f);
- passed &= VerifySingleParse("NaN", NumberStyles.Float, NumberFormatInfo.InvariantInfo, Single.NaN);
- passed &= VerifySingleParse("Infinity", NumberStyles.Float, NumberFormatInfo.InvariantInfo, Single.PositiveInfinity);
- passed &= VerifySingleParse("-Infinity", NumberStyles.Float, NumberFormatInfo.InvariantInfo, Single.NegativeInfinity);
- passed &= VerifySingleParse("123", NumberStyles.Integer, germanCulture, 123);
- passed &= VerifySingleParse("123", NumberStyles.Integer, japaneseCulture, 123);
- passed &= VerifySingleParse("123.456", NumberStyles.Any, germanCulture, 123456);
- passed &= VerifySingleParse("123,456", NumberStyles.Any, japaneseCulture, 123456);
- passed &= VerifySingleParse("123,456", NumberStyles.AllowDecimalPoint, germanCulture, 123.456f);
- passed &= VerifySingleParse("123.456", NumberStyles.AllowDecimalPoint, japaneseCulture, 123.456f);
- passed &= VerifySingleParse("5,23 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Any, germanCulture, 5.23f); // currency
- passed &= VerifySingleParse("5.23 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Any, germanCulture, 523); // currency
- //
- passed &= VerifySingleParse("5", NumberStyles.Integer, corruptNFI, 5f);
- passed &= VerifySingleParse("5", NumberStyles.Number, corruptNFI, 5f);
- passed &= VerifySingleParse("5.3", NumberStyles.Number, corruptNFI, 5.3f);
- passed &= VerifySingleParseException("5,3", NumberStyles.Number, corruptNFI, typeof(FormatException));
- passed &= VerifySingleParseException("5.2.3", NumberStyles.Number, corruptNFI, typeof(FormatException));
- passed &= VerifySingleParse("$5.3", NumberStyles.Currency, corruptNFI, 5.3f);
- passed &= VerifySingleParseException("$5,3", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifySingleParseException("$5.2.3", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifySingleParse("5.3", NumberStyles.Currency, corruptNFI, 5.3f);
- passed &= VerifySingleParseException("5,3", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifySingleParseException("5.2.3", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifySingleParse("5.3", NumberStyles.Any, corruptNFI, 5.3f);
- passed &= VerifySingleParseException("5,3", NumberStyles.Any, corruptNFI, typeof(FormatException));
- passed &= VerifySingleParseException("5.2.3", NumberStyles.Any, corruptNFI, typeof(FormatException));
- //
- passed &= VerifySingleParse("5", NumberStyles.Integer, swappedNFI, 5);
- passed &= VerifySingleParseException("1,234", NumberStyles.Integer, swappedNFI, typeof(FormatException));
- passed &= VerifySingleParse("5", NumberStyles.Number, swappedNFI, 5);
- passed &= VerifySingleParse("5.0", NumberStyles.Number, swappedNFI, 5);
- passed &= VerifySingleParse("1,234", NumberStyles.Number, swappedNFI, 1234);
- passed &= VerifySingleParse("1,234.0", NumberStyles.Number, swappedNFI, 1234);
- passed &= VerifySingleParseException("5.000.000", NumberStyles.Number, swappedNFI, typeof(FormatException));
- passed &= VerifySingleParseException("5.000,00", NumberStyles.Number, swappedNFI, typeof(FormatException));
- passed &= VerifySingleParse("5.000", NumberStyles.Currency, swappedNFI, 5); //???
- passed &= VerifySingleParseException("5.000,00", NumberStyles.Currency, swappedNFI, typeof(FormatException)); //???
- passed &= VerifySingleParse("$5.000", NumberStyles.Currency, swappedNFI, 5000);
- passed &= VerifySingleParse("$5.000,00", NumberStyles.Currency, swappedNFI, 5000);
- passed &= VerifySingleParse("5.000", NumberStyles.Any, swappedNFI, 5); //?
- passed &= VerifySingleParseException("5.000,00", NumberStyles.Any, swappedNFI, typeof(FormatException)); //?
- passed &= VerifySingleParse("$5.000", NumberStyles.Any, swappedNFI, 5000);
- passed &= VerifySingleParse("$5.000,00", NumberStyles.Any, swappedNFI, 5000);
- passed &= VerifySingleParse("5,0", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifySingleParse("$5,0", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifySingleParse("5,000", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifySingleParse("$5,000", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifySingleParseException("5,000.0", NumberStyles.Currency, swappedNFI, typeof(FormatException));
- passed &= VerifySingleParseException("$5,000.0", NumberStyles.Currency, swappedNFI, typeof(FormatException));
- passed &= VerifySingleParse("5,000", NumberStyles.Any, swappedNFI, 5);
- passed &= VerifySingleParse("$5,000", NumberStyles.Any, swappedNFI, 5);
- passed &= VerifySingleParseException("5,000.0", NumberStyles.Any, swappedNFI, typeof(FormatException));
- passed &= VerifySingleParseException("$5,000.0", NumberStyles.Any, swappedNFI, typeof(FormatException));
- //
- passed &= VerifySingleParse("5.0", NumberStyles.Number, distinctNFI, 5);
- passed &= VerifySingleParse("1,234.0", NumberStyles.Number, distinctNFI, 1234);
- passed &= VerifySingleParse("5.0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifySingleParse("1,234.0", NumberStyles.Currency, distinctNFI, 1234);
- passed &= VerifySingleParse("5.0", NumberStyles.Any, distinctNFI, 5);
- passed &= VerifySingleParse("1,234.0", NumberStyles.Any, distinctNFI, 1234);
- passed &= VerifySingleParseException("$5.0", NumberStyles.Currency, distinctNFI, typeof(FormatException));
- passed &= VerifySingleParseException("$5.0", NumberStyles.Any, distinctNFI, typeof(FormatException));
- passed &= VerifySingleParseException("5:0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifySingleParseException("5;0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifySingleParseException("$5:0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifySingleParse("5:0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifySingleParse("5:000", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifySingleParse("5;000", NumberStyles.Currency, distinctNFI, 5000);
- passed &= VerifySingleParse("$5:0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifySingleParse("$5;0", NumberStyles.Currency, distinctNFI, 50);
- passed &= VerifySingleParse("5:0", NumberStyles.Any, distinctNFI, 5);
- passed &= VerifySingleParse("5;0", NumberStyles.Any, distinctNFI, 50);
- passed &= VerifySingleParse("$5:0", NumberStyles.Any, distinctNFI, 5);
- passed &= VerifySingleParse("$5;0", NumberStyles.Any, distinctNFI, 50);
- passed &= VerifySingleParseException("123,456;789.0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifySingleParse("123,456;789.0", NumberStyles.Currency, distinctNFI, 123456789);
- passed &= VerifySingleParse("123,456;789.0", NumberStyles.Any, distinctNFI, 123456789);
- passed &= VerifySingleParseException("$123,456;789.0", NumberStyles.Any, distinctNFI, typeof(FormatException));
- //
- passed &= VerifySingleParseException("3.402822E+39", NumberStyles.Float | NumberStyles.AllowExponent, null, typeof(OverflowException));
- passed &= VerifySingleParseException("-3.402822E+39", NumberStyles.Float | NumberStyles.AllowExponent, null, typeof(OverflowException));
- passed &= VerifySingleParseException("1.89769313486231E+308", NumberStyles.Float | NumberStyles.AllowExponent, null, typeof(OverflowException));
- passed &= VerifySingleParseException("-1.89769313486231E+308", NumberStyles.Float | NumberStyles.AllowExponent, null, typeof(OverflowException));
- passed &= VerifySingleParseException("Garbage", typeof(FormatException));
- passed &= VerifySingleParseException("5\0Garbage", typeof(FormatException));
- passed &= VerifySingleParseException(null, typeof(ArgumentNullException));
- passed &= VerifySingleParseException("FF", NumberStyles.HexNumber, goodNFI, typeof(ArgumentException));
- passed &= VerifySingleParseException("4", (NumberStyles)(-1), typeof(ArgumentException));
- passed &= VerifySingleParseException("4", (NumberStyles)0x10000, typeof(ArgumentException));
- passed &= VerifySingleParseException("4", (NumberStyles)(-1), CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifySingleParseException("4", (NumberStyles)0x10000, CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifySingleParseException("123,000,000,000,000,000,000", NumberStyles.Any, germanCulture, typeof(FormatException));
- passed &= VerifySingleParseException("123.000.000.000.000.000.000", NumberStyles.Any, japaneseCulture, typeof(FormatException));
- passed &= VerifySingleParseException("5,00 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Integer, germanCulture, typeof(FormatException)); // currency
-
-
- /////////// TryParse(String)
- //// Pass cases
- passed &= VerifySingleTryParse("0", 0, true);
- passed &= VerifySingleTryParse("-0", 0, true);
- passed &= VerifySingleTryParse("5", 5, true);
- passed &= VerifySingleTryParse(" 5 ", 5, true);
- passed &= VerifySingleTryParse("-5", -5, true);
- passed &= VerifySingleTryParse("5\0", 5, true);
- passed &= VerifySingleTryParse("5 \0", 5, true);
- passed &= VerifySingleTryParse("5\0\0\0", 5, true);
- passed &= VerifySingleTryParse("893382737", 893382737, true);
- passed &= VerifySingleTryParse("-893382737", -893382737, true);
- passed &= VerifySingleTryParse("1234567891", 1234567891, true);
- passed &= VerifySingleTryParse("-1234567891", -1234567891, true);
- passed &= VerifySingleTryParse("123456789123456789", 123456789123456789, true);
- passed &= VerifySingleTryParse("-123456789123456789", -123456789123456789, true);
- passed &= VerifySingleTryParse("123456789123456789123", 123456789123456789123.0f, true);
- passed &= VerifySingleTryParse("-123456789123456789123", -123456789123456789123.0f, true);
- passed &= VerifySingleTryParse("18446744073709551615", 18446744073709551615, true);
- passed &= VerifySingleTryParse("79228162514264337593543950335", 79228162514264337593543950335.0f, true);
- passed &= VerifySingleTryParse("-79228162514264337593543950335", -79228162514264337593543950335.0f, true);
- passed &= VerifySingleTryParse("79228162514264337593543950336", 79228162514264337593543950336.0f, true);
- passed &= VerifySingleTryParse("-79228162514264337593543950336", -79228162514264337593543950336.0f, true);
- passed &= VerifySingleTryParse("7.3", 7.3f, true);
- passed &= VerifySingleTryParse(".297", 0.297f, true);
- passed &= VerifySingleTryParse("5.555555555", 5.555555555f, true);
- passed &= VerifySingleTryParse("1.000000", 1.0f, true);
- passed &= VerifySingleTryParse("1.234E+05", 123400, true);
- passed &= VerifySingleTryParse("NaN", Single.NaN, true);
- passed &= VerifySingleTryParse("Infinity", Single.PositiveInfinity, true);
- passed &= VerifySingleTryParse("-Infinity", Single.NegativeInfinity, true);
-
- //// Fail cases
- passed &= VerifySingleTryParse(null, 0, false);
- passed &= VerifySingleTryParse("", 0, false);
- passed &= VerifySingleTryParse("Garbage", 0, false);
- passed &= VerifySingleTryParse("5\0Garbage", 0, false);
- passed &= VerifySingleTryParse("FF", 0, false);
- passed &= VerifySingleTryParse("23 5", 0, false);
- passed &= VerifySingleTryParse("1.234+E05", 0, false);
-
-
- /////////// TryParse(TryParse(String, NumberStyles, IFormatProvider, ref Single)
- //// Pass cases
- passed &= VerifySingleTryParse("5", NumberStyles.Integer, CultureInfo.InvariantCulture, 5, true);
- passed &= VerifySingleTryParse("-5", NumberStyles.Integer, CultureInfo.InvariantCulture, -5, true);
- passed &= VerifySingleTryParse("-79228162514264337593543950336", NumberStyles.Integer, CultureInfo.InvariantCulture, -79228162514264337593543950336.0f, true);
- passed &= VerifySingleTryParse("NaN", NumberStyles.Float, NumberFormatInfo.InvariantInfo, Single.NaN, true);
- passed &= VerifySingleTryParse("Infinity", NumberStyles.Float, NumberFormatInfo.InvariantInfo, Single.PositiveInfinity, true);
- passed &= VerifySingleTryParse("-Infinity", NumberStyles.Float, NumberFormatInfo.InvariantInfo, Single.NegativeInfinity, true);
- // Variations on NumberStyles
- passed &= VerifySingleTryParse(" 5", NumberStyles.AllowLeadingWhite, goodNFI, 5, true);
- passed &= VerifySingleTryParse("5", NumberStyles.Number, goodNFI, 5, true);
- passed &= VerifySingleTryParse("5.0", NumberStyles.AllowDecimalPoint, goodNFI, 5.0f, true);
- passed &= VerifySingleTryParse("5.3", NumberStyles.AllowDecimalPoint, goodNFI, 5.3f, true);
- passed &= VerifySingleTryParse("1.234E+05", NumberStyles.Float | NumberStyles.AllowExponent, goodNFI, 123400, true);
- passed &= VerifySingleTryParse("3.40282347E+38", NumberStyles.Float | NumberStyles.AllowExponent, null, (float)3.40282347E+38, true);
- passed &= VerifySingleTryParse("-3.40282347E+38 ", NumberStyles.Float | NumberStyles.AllowExponent, null, (float)-3.40282347E+38, true);
- // Variations on IFP
- passed &= VerifySingleTryParse("5", NumberStyles.Integer, goodNFI, 5, true);
- passed &= VerifySingleTryParse("5", NumberStyles.Integer, null, 5, true);
- passed &= VerifySingleTryParse("5", NumberStyles.Integer, new DateTimeFormatInfo(), 5, true);
- passed &= VerifySingleTryParse("^42", NumberStyles.Any, customNFI, -42, true);
- passed &= VerifySingleTryParse("123", NumberStyles.Integer, germanCulture, 123, true);
- passed &= VerifySingleTryParse("123", NumberStyles.Integer, japaneseCulture, 123, true);
- passed &= VerifySingleTryParse("123.456", NumberStyles.Any, germanCulture, 123456, true);
- passed &= VerifySingleTryParse("123,456", NumberStyles.Any, japaneseCulture, 123456, true);
- passed &= VerifySingleTryParse("123,456", NumberStyles.AllowDecimalPoint, germanCulture, 123.456f, true);
- passed &= VerifySingleTryParse("123.456", NumberStyles.AllowDecimalPoint, japaneseCulture, 123.456f, true);
- passed &= VerifySingleTryParse("5,23 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Any, germanCulture, 5.23f, true); // currency
- passed &= VerifySingleTryParse("5.23 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Any, germanCulture, 523, true); // currency
- //
- //// Fail cases
- passed &= VerifySingleTryParse("-42", NumberStyles.Any, customNFI, 0, false);
- passed &= VerifySingleTryParse("5 ", NumberStyles.AllowLeadingWhite, goodNFI, 0, false);
- passed &= VerifySingleTryParse("5.3", NumberStyles.None, goodNFI, 0, false);
- passed &= VerifySingleTryParse("1.234E+05", NumberStyles.AllowExponent, goodNFI, 0, false);
- passed &= VerifySingleTryParse("3.40282347E+39", NumberStyles.Float | NumberStyles.AllowExponent, null, 0, false);
- passed &= VerifySingleTryParse("-3.40282347E+39", NumberStyles.Float | NumberStyles.AllowExponent, null, 0, false);
- passed &= VerifySingleTryParse("1.79769313486231E+308", NumberStyles.Float | NumberStyles.AllowExponent, null, 0, false);
- passed &= VerifySingleTryParse("-1.79769313486231E+308", NumberStyles.Float | NumberStyles.AllowExponent, null, 0, false);
- passed &= VerifySingleTryParse("-1.79769313486231E+309", NumberStyles.Float | NumberStyles.AllowExponent, null, 0, false);
- passed &= VerifySingleTryParse("1.89769313486231E+308", NumberStyles.Float | NumberStyles.AllowExponent, null, 0, false);
- passed &= VerifySingleTryParse("-1.89769313486231E+308", NumberStyles.Float | NumberStyles.AllowExponent, null, 0, false);
- passed &= VerifySingleTryParse("123,000,000,000,000,000,000", NumberStyles.Any, germanCulture, 0, false);
- passed &= VerifySingleTryParse("123.000.000.000.000.000.000", NumberStyles.Any, japaneseCulture, 0, false);
-
- //// Exception cases
- passed &= VerifySingleTryParseException("12", NumberStyles.HexNumber, CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifySingleTryParseException("5", NumberStyles.AllowHexSpecifier | NumberStyles.AllowParentheses, null, typeof(ArgumentException));
- passed &= VerifySingleTryParseException("4", (NumberStyles)(-1), CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifySingleTryParseException("4", (NumberStyles)0x10000, CultureInfo.InvariantCulture, typeof(ArgumentException));
-
- // NumberStyles/NFI variations
- //
- passed &= VerifySingleTryParse("5", NumberStyles.Integer, corruptNFI, 5, true);
- passed &= VerifySingleTryParse("5", NumberStyles.Number, corruptNFI, 5, true);
- passed &= VerifySingleTryParse("5.3", NumberStyles.Number, corruptNFI, 5.3f, true);
- passed &= VerifySingleTryParse("5,3", NumberStyles.Number, corruptNFI, 0, false);
- passed &= VerifySingleTryParse("5.2.3", NumberStyles.Number, corruptNFI, 0, false);
- passed &= VerifySingleTryParse("$5.3", NumberStyles.Currency, corruptNFI, 5.3f, true);
- passed &= VerifySingleTryParse("$5,3", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifySingleTryParse("$5.2.3", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifySingleTryParse("5.3", NumberStyles.Currency, corruptNFI, 5.3f, true);
- passed &= VerifySingleTryParse("5,3", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifySingleTryParse("5.2.3", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifySingleTryParse("5.3", NumberStyles.Any, corruptNFI, 5.3f, true);
- passed &= VerifySingleTryParse("5,3", NumberStyles.Any, corruptNFI, 0, false);
- passed &= VerifySingleTryParse("5.2.3", NumberStyles.Any, corruptNFI, 0, false);
- //
- passed &= VerifySingleTryParse("5", NumberStyles.Integer, swappedNFI, 5, true);
- passed &= VerifySingleTryParse("1,234", NumberStyles.Integer, swappedNFI, 0, false);
- passed &= VerifySingleTryParse("5", NumberStyles.Number, swappedNFI, 5, true);
- passed &= VerifySingleTryParse("5.0", NumberStyles.Number, swappedNFI, 5, true);
- passed &= VerifySingleTryParse("1,234", NumberStyles.Number, swappedNFI, 1234, true);
- passed &= VerifySingleTryParse("1,234.0", NumberStyles.Number, swappedNFI, 1234, true);
- passed &= VerifySingleTryParse("5.000.000", NumberStyles.Number, swappedNFI, 0, false);
- passed &= VerifySingleTryParse("5.000,00", NumberStyles.Number, swappedNFI, 0, false);
- passed &= VerifySingleTryParse("5.000", NumberStyles.Currency, swappedNFI, 5, true); //???
- passed &= VerifySingleTryParse("5.000,00", NumberStyles.Currency, swappedNFI, 0, false); //???
- passed &= VerifySingleTryParse("$5.000", NumberStyles.Currency, swappedNFI, 5000, true);
- passed &= VerifySingleTryParse("$5.000,00", NumberStyles.Currency, swappedNFI, 5000, true);
- passed &= VerifySingleTryParse("5.000", NumberStyles.Any, swappedNFI, 5, true); //?
- passed &= VerifySingleTryParse("5.000,00", NumberStyles.Any, swappedNFI, 0, false); //?
- passed &= VerifySingleTryParse("$5.000", NumberStyles.Any, swappedNFI, 5000, true);
- passed &= VerifySingleTryParse("$5.000,00", NumberStyles.Any, swappedNFI, 5000, true);
- passed &= VerifySingleTryParse("5,0", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifySingleTryParse("$5,0", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifySingleTryParse("5,000", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifySingleTryParse("$5,000", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifySingleTryParse("5,000.0", NumberStyles.Currency, swappedNFI, 0, false);
- passed &= VerifySingleTryParse("$5,000.0", NumberStyles.Currency, swappedNFI, 0, false);
- passed &= VerifySingleTryParse("5,000", NumberStyles.Any, swappedNFI, 5, true);
- passed &= VerifySingleTryParse("$5,000", NumberStyles.Any, swappedNFI, 5, true);
- passed &= VerifySingleTryParse("5,000.0", NumberStyles.Any, swappedNFI, 0, false);
- passed &= VerifySingleTryParse("$5,000.0", NumberStyles.Any, swappedNFI, 0, false);
- //
- passed &= VerifySingleTryParse("5.0", NumberStyles.Number, distinctNFI, 5, true);
- passed &= VerifySingleTryParse("1,234.0", NumberStyles.Number, distinctNFI, 1234, true);
- passed &= VerifySingleTryParse("5.0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifySingleTryParse("1,234.0", NumberStyles.Currency, distinctNFI, 1234, true);
- passed &= VerifySingleTryParse("5.0", NumberStyles.Any, distinctNFI, 5, true);
- passed &= VerifySingleTryParse("1,234.0", NumberStyles.Any, distinctNFI, 1234, true);
- passed &= VerifySingleTryParse("$5.0", NumberStyles.Currency, distinctNFI, 0, false);
- passed &= VerifySingleTryParse("$5.0", NumberStyles.Any, distinctNFI, 0, false);
- passed &= VerifySingleTryParse("5:0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifySingleTryParse("5;0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifySingleTryParse("$5:0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifySingleTryParse("5:0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifySingleTryParse("5:000", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifySingleTryParse("5;000", NumberStyles.Currency, distinctNFI, 5000, true);
- passed &= VerifySingleTryParse("$5:0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifySingleTryParse("$5;0", NumberStyles.Currency, distinctNFI, 50, true);
- passed &= VerifySingleTryParse("5:0", NumberStyles.Any, distinctNFI, 5, true);
- passed &= VerifySingleTryParse("5;0", NumberStyles.Any, distinctNFI, 50, true);
- passed &= VerifySingleTryParse("$5:0", NumberStyles.Any, distinctNFI, 5, true);
- passed &= VerifySingleTryParse("$5;0", NumberStyles.Any, distinctNFI, 50, true);
- passed &= VerifySingleTryParse("123,456;789.0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifySingleTryParse("123,456;789.0", NumberStyles.Currency, distinctNFI, 123456789, true);
- passed &= VerifySingleTryParse("123,456;789.0", NumberStyles.Any, distinctNFI, 123456789, true);
- passed &= VerifySingleTryParse("$123,456;789.0", NumberStyles.Any, distinctNFI, 0, false);
-
-
- // Should these pass or fail? Current parse behavior is to pass, so they might be
- // parse bugs, but they're not tryparse bugs.
- // I expect ArgumentException with an ambiguous NFI
- passed &= VerifySingleParse("^42", NumberStyles.Any, ambigNFI, -42);
- passed &= VerifySingleTryParse("^42", NumberStyles.Any, ambigNFI, -42, true);
-
- /// END TEST CASES
- }
- catch (Exception e)
- {
- TestLibrary.Logging.WriteLine("Unexpected exception!! " + e.ToString());
- passed = false;
- }
-
- if (passed)
- {
- TestLibrary.Logging.WriteLine("paSs");
- return 100;
- }
- else
- {
- TestLibrary.Logging.WriteLine("FAiL");
- return 1;
- }
- }
-
- public static bool VerifySingleTryParse(string value, Single expectedResult, bool expectedReturn)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Single.TryParse, Value = '{0}', Expected Result = {1}, Expected Return = {2}",
- value, expectedResult, expectedReturn);
- }
- Single result = 0;
- try
- {
- bool returnValue = Single.TryParse(value, out result);
- if (returnValue != expectedReturn)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedReturn, returnValue);
- return false;
- }
- if (Single.IsNaN(expectedResult) && Single.IsNaN(result))
- {
- return true;
- }
- if (result != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, result);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifySingleTryParse(string value, NumberStyles style, IFormatProvider provider, Single expectedResult, bool expectedReturn)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Single.TryParse, Value = '{0}', Style = {1}, Provider = {2}, Expected Result = {3}, Expected Return = {4}",
- value, style, provider, expectedResult, expectedReturn);
- }
- Single result = 0;
- try
- {
- bool returnValue = Single.TryParse(value, style, provider, out result);
- if (returnValue != expectedReturn)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Style = {1}, Provider = {2}, Expected Return = {3}, Actual Return = {4}",
- value, style, provider, expectedReturn, returnValue);
- return false;
- }
- if (Single.IsNaN(expectedResult) && Single.IsNaN(result))
- {
- return true;
- }
- if (result != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, result);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifySingleTryParseException(string value, NumberStyles style, IFormatProvider provider, Type exceptionType)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Single.TryParse, Value = '{0}', Style = {1}, Provider = {2}, Expected Exception = {3}",
- value, style, provider, exceptionType);
- }
- try
- {
- Single result = 0;
- Boolean returnValue = Single.TryParse(value, style, provider, out result);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifySingleParse(string value, Single expectedResult)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Single.Parse, Value = '{0}', Expected Result, {1}",
- value, expectedResult);
- }
- try
- {
- Single returnValue = Single.Parse(value);
- if (Single.IsNaN(expectedResult) && Single.IsNaN(returnValue))
- {
- return true;
- }
- if (returnValue != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, returnValue);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifySingleParse(string value, NumberStyles style, IFormatProvider provider, Single expectedResult)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Single.Parse, Value = '{0}', Style = {1}, provider = {2}, Expected Result = {3}",
- value, style, provider, expectedResult);
- }
- try
- {
- Single returnValue = Single.Parse(value, style, provider);
- if (Single.IsNaN(expectedResult) && Single.IsNaN(returnValue))
- {
- return true;
- }
- if (returnValue != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, returnValue);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifySingleParseException(string value, Type exceptionType)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Single.Parse, Value = '{0}', Expected Exception, {1}",
- value, exceptionType);
- }
- try
- {
- Single returnValue = Single.Parse(value);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifySingleParseException(string value, NumberStyles style, Type exceptionType)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Single.Parse, Value = '{0}', Style = {1}, Expected Exception = {3}",
- value, style, exceptionType);
- }
- try
- {
- Single returnValue = Single.Parse(value, style);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifySingleParseException(string value, NumberStyles style, IFormatProvider provider, Type exceptionType)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: Single.Parse, Value = '{0}', Style = {1}, Provider = {2}, Expected Exception = {3}",
- value, style, provider, exceptionType);
- }
- try
- {
- Single returnValue = Single.Parse(value, style, provider);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-}
diff --git a/tests/src/CoreMangLib/cti/system/uint16/UInt16Parse1.csproj b/tests/src/CoreMangLib/cti/system/uint16/UInt16Parse1.csproj
deleted file mode 100644
index 36fa138004..0000000000
--- a/tests/src/CoreMangLib/cti/system/uint16/UInt16Parse1.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="uint16parse1.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/uint16/UInt16Parse2.csproj b/tests/src/CoreMangLib/cti/system/uint16/UInt16Parse2.csproj
deleted file mode 100644
index 8e57df1186..0000000000
--- a/tests/src/CoreMangLib/cti/system/uint16/UInt16Parse2.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="uint16parse2.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/uint16/UInt16Parse3.csproj b/tests/src/CoreMangLib/cti/system/uint16/UInt16Parse3.csproj
deleted file mode 100644
index f65ffb3419..0000000000
--- a/tests/src/CoreMangLib/cti/system/uint16/UInt16Parse3.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="uint16parse3.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/uint16/UInt16TryParse.csproj b/tests/src/CoreMangLib/cti/system/uint16/UInt16TryParse.csproj
deleted file mode 100644
index e70827f3e6..0000000000
--- a/tests/src/CoreMangLib/cti/system/uint16/UInt16TryParse.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="uint16tryparse.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/uint16/uint16parse1.cs b/tests/src/CoreMangLib/cti/system/uint16/uint16parse1.cs
deleted file mode 100644
index 7cb17e0fc2..0000000000
--- a/tests/src/CoreMangLib/cti/system/uint16/uint16parse1.cs
+++ /dev/null
@@ -1,284 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-
-/// <summary>
-/// UInt16.Parse(string)
-/// </summary>
-public class UInt16Parse
-{
- public static int Main()
- {
- UInt16Parse ui32ct2 = new UInt16Parse();
- TestLibrary.TestFramework.BeginTestCase("for method: UInt16.Parse(string)");
-
- if (ui32ct2.RunTests())
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("PASS");
- return 100;
- }
- else
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("FAIL");
- return 0;
- }
- }
- public bool RunTests()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.LogInformation("[Positive]");
- retVal = PosTest1() && retVal;
- retVal = PosTest2() && retVal;
- retVal = PosTest3() && retVal;
-
- TestLibrary.TestFramework.LogInformation("[Negative]");
- retVal = NegTest1() && retVal;
- retVal = NegTest2() && retVal;
- retVal = NegTest3() && retVal;
- retVal = NegTest4() && retVal;
-
-
- return retVal;
- }
- #region PositiveTest
- public bool PosTest1()
- {
- bool retVal = true;
- string errorDesc;
- UInt16 actualValue;
- TestLibrary.TestFramework.BeginScenario("PosTest1: UInt16.MaxValue.");
- try
- {
- string strValue = UInt16.MaxValue.ToString();
- actualValue = UInt16.Parse(strValue);
- if (actualValue != UInt16.MaxValue)
- {
- errorDesc = "The parse value of " + strValue + " is not the value " + UInt16.MaxValue +
- " as expected: actual(" + actualValue + ")";
- TestLibrary.TestFramework.LogError("001", errorDesc);
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("002", "Unexpect exception:" + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest2()
- {
- bool retVal = true;
- string errorDesc;
- UInt16 actualValue;
- TestLibrary.TestFramework.BeginScenario("PosTest2: UInt16.MinValue.");
- try
- {
- string strValue = UInt16.MinValue.ToString();
- actualValue = UInt16.Parse(strValue);
- if (actualValue != UInt16.MinValue)
- {
- errorDesc = "The parse value of " + strValue + " is not the value " + UInt16.MinValue +
- " as expected: actual(" + actualValue + ")";
- TestLibrary.TestFramework.LogError("003", errorDesc);
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("004", "Unexpect exception:" + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest3()
- {
- bool retVal = true;
- string errorDesc;
-
- UInt16 expectedValue;
- UInt16 actualValue;
- TestLibrary.TestFramework.BeginScenario("PosTest3: random UInt16 value between 0 and UInt16.MaxValue");
- try
- {
- expectedValue = (UInt16)this.GetInt32(0, UInt16.MaxValue);
- string strValue = expectedValue.ToString();
- actualValue = UInt16.Parse(strValue);
- if (actualValue != expectedValue)
- {
- errorDesc = "The parse value of " + strValue + " is not the value " + expectedValue +
- " as expected: actual(" + actualValue + ")";
- TestLibrary.TestFramework.LogError("005", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("006", "Unexpect exception:" + e);
- retVal = false;
- }
- return retVal;
- }
- #endregion
-
- #region Negative tests
- //ArgumentNullException
- public bool NegTest1()
- {
- bool retVal = true;
-
- const string c_TEST_ID = "N001";
- const string c_TEST_DESC = "NegTest1: string representation is a null reference";
- string errorDesc;
-
- TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
- try
- {
- UInt16.Parse(null);
- errorDesc = "ArgumentNullException is not thrown as expected.";
- TestLibrary.TestFramework.LogError("007" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
-
- }
- catch (ArgumentNullException)
- { }
- catch (Exception e)
- {
- errorDesc = "Unexpected exception: " + e;
- TestLibrary.TestFramework.LogError("008" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- return retVal;
- }
-
- //FormatException
- public bool NegTest2()
- {
- bool retVal = true;
-
- const string c_TEST_ID = "N002";
- const string c_TEST_DESC = "NegTest2: String representation is not in the correct format";
- string errorDesc;
-
- string strValue;
-
- TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
- try
- {
- strValue = "Incorrect";
- UInt16.Parse(strValue);
- errorDesc = "FormatException is not thrown as expected.";
- TestLibrary.TestFramework.LogError("009" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- catch (FormatException)
- { }
- catch (Exception e)
- {
- errorDesc = "Unexpected exception: " + e;
- TestLibrary.TestFramework.LogError("010" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- return retVal;
- }
-
- //OverflowException
- public bool NegTest3()
- {
- bool retVal = true;
-
- const string c_TEST_ID = "N003";
- const string c_TEST_DESC = "NegTest3: String representation is greater than UInt16.MaxValue";
- string errorDesc;
-
- string strValue;
- int i;
-
- i = this.GetInt32(UInt16.MaxValue + 1, int.MaxValue);
- strValue = i.ToString();
-
- TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
- try
- {
- UInt16.Parse(strValue);
- errorDesc = "OverflowException is not thrown as expected.";
- errorDesc += "\nThe string representation is " + strValue;
- TestLibrary.TestFramework.LogError("011" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- catch (OverflowException)
- { }
- catch (Exception e)
- {
- errorDesc = "Unexpected exception: " + e;
- errorDesc += "\nThe string representation is " + strValue;
- TestLibrary.TestFramework.LogError("012" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- return retVal;
- }
-
- public bool NegTest4()
- {
- bool retVal = true;
-
- const string c_TEST_ID = "N004";
- const string c_TEST_DESC = "NegTest4: String representation is less than UInt16.MaxValue";
- string errorDesc;
-
- string strValue;
- int i;
-
- i = -1 * TestLibrary.Generator.GetInt32(-55) - 1;
- strValue = i.ToString();
-
- TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
- try
- {
- UInt16.Parse(strValue);
- errorDesc = "OverflowException is not thrown as expected.";
- errorDesc += "\nThe string representation is " + strValue;
- TestLibrary.TestFramework.LogError("013" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- catch (OverflowException)
- { }
- catch (Exception e)
- {
- errorDesc = "Unexpected exception: " + e;
- errorDesc += "\nThe string representation is " + strValue;
- TestLibrary.TestFramework.LogError("014" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- return retVal;
- }
- #endregion
-
- #region ForTestObject
- private Int32 GetInt32(Int32 minValue, Int32 maxValue)
- {
- try
- {
- if (minValue == maxValue)
- {
- return minValue;
- }
- if (minValue < maxValue)
- {
- return minValue + TestLibrary.Generator.GetInt32(-55) % (maxValue - minValue);
- }
- }
- catch
- {
- throw;
- }
-
- return minValue;
- }
-
- #endregion
-}
diff --git a/tests/src/CoreMangLib/cti/system/uint16/uint16parse2.cs b/tests/src/CoreMangLib/cti/system/uint16/uint16parse2.cs
deleted file mode 100644
index 938ac5654a..0000000000
--- a/tests/src/CoreMangLib/cti/system/uint16/uint16parse2.cs
+++ /dev/null
@@ -1,503 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Globalization;
-
-/// <summary>
-/// UInt16.Parse(String, NumberStyles)
-/// </summary>
-public class UInt16Parse
-{
- public static int Main()
- {
- UInt16Parse ui32ct2 = new UInt16Parse();
- TestLibrary.TestFramework.BeginTestCase("for method: UInt16.Parse(String, NumberStyles)");
-
- if (ui32ct2.RunTests())
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("PASS");
- return 100;
- }
- else
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("FAIL");
- return 0;
- }
- }
- public bool RunTests()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.LogInformation("[Positive]");
- retVal = PosTest1() && retVal;
- retVal = PosTest2() && retVal;
- retVal = PosTest3() && retVal;
- retVal = PosTest4() && retVal;
- retVal = PosTest5() && retVal;
-
- TestLibrary.TestFramework.LogInformation("[Negative]");
- retVal = NegTest1() && retVal;
- retVal = NegTest2() && retVal;
- retVal = NegTest3() && retVal;
- retVal = NegTest4() && retVal;
- retVal = NegTest5() && retVal;
- retVal = NegTest6() && retVal;
- retVal = NegTest7() && retVal;
-
- return retVal;
- }
- #region PositiveTest
- public bool PosTest1()
- {
- bool retVal = true;
- string errorDesc;
-
- UInt16 actualValue;
- NumberStyles numberStyle;
-
- TestLibrary.TestFramework.BeginScenario("PosTest1: UInt16.MaxValue, number style is NumberStyles.Integer.");
- try
- {
- numberStyle = NumberStyles.Integer;
- string strValue = UInt16.MaxValue.ToString();
- strValue = " " + strValue + " ";
- actualValue = UInt16.Parse(strValue, numberStyle);
- if (actualValue != UInt16.MaxValue)
- {
- errorDesc = "The parse value of " + strValue + " with number styles " +
- numberStyle + " is not the value " + UInt16.MaxValue +
- " as expected: actual(" + actualValue + ")";
- TestLibrary.TestFramework.LogError("001", errorDesc);
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("002", "Unexpect exception:" + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest2()
- {
- bool retVal = true;
- string errorDesc;
-
- UInt16 actualValue;
- NumberStyles numberStyle;
-
- TestLibrary.TestFramework.BeginScenario("PosTest2: UInt16.MinValue, number style is NumberStyles.None.");
- try
- {
- string strValue = UInt16.MinValue.ToString();
- numberStyle = NumberStyles.None;
-
- actualValue = UInt16.Parse(strValue, numberStyle);
- if (actualValue != UInt16.MinValue)
- {
- errorDesc = "The parse value of " + strValue + " with number styles " +
- numberStyle + " is not the value " + UInt16.MaxValue +
- " as expected: actual(" + actualValue + ")";
- TestLibrary.TestFramework.LogError("003", errorDesc);
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("004", "Unexpect exception:" + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest3()
- {
- bool retVal = true;
- string errorDesc;
-
- UInt16 expectedValue;
- UInt16 actualValue;
- NumberStyles numberStyle;
-
- TestLibrary.TestFramework.BeginScenario("PosTest3: random hexadecimal UInt16 value between 0 and UInt16.MaxValue");
- try
- {
- expectedValue = (UInt16)this.GetInt32(0, UInt16.MaxValue);
- string strValue = expectedValue.ToString("x");
- numberStyle = NumberStyles.HexNumber;
- actualValue = UInt16.Parse(strValue, numberStyle);
- if (actualValue != expectedValue)
- {
- errorDesc = "The parse value of " + strValue + " with number styles " +
- numberStyle + " is not the value " + UInt16.MaxValue +
- " as expected: actual(" + actualValue + ")";
- TestLibrary.TestFramework.LogError("005", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("006", "Unexpect exception:" + e);
- retVal = false;
- }
- return retVal;
- }
-
- public bool PosTest4()
- {
- bool retVal = true;
- string errorDesc;
-
- UInt16 expectedValue;
- UInt16 actualValue;
- NumberStyles numberStyle;
-
- TestLibrary.TestFramework.BeginScenario("PosTest4: random currency UInt16 value between 0 and UInt16.MaxValue");
- try
- {
- expectedValue = (UInt16)this.GetInt32(0, UInt16.MaxValue);
- string strValue = expectedValue.ToString("c");
- numberStyle = NumberStyles.Currency;
- actualValue = UInt16.Parse(strValue, numberStyle);
- if (actualValue != expectedValue)
- {
- errorDesc = "The parse value of " + strValue + " with number styles " +
- numberStyle + " is not the value " + UInt16.MaxValue +
- " as expected: actual(" + actualValue + ")";
- TestLibrary.TestFramework.LogError("007", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("008", "Unexpect exception:" + e);
- retVal = false;
- }
- return retVal;
- }
-
- public bool PosTest5()
- {
- bool retVal = true;
- string errorDesc;
-
- UInt16 expectedValue;
- UInt16 actualValue;
- NumberStyles numberStyle;
-
- TestLibrary.TestFramework.BeginScenario("PosTest5: random UInt16 value between 0 and UInt16.MaxValue, number styles is NumberStyels.Any");
- try
- {
- expectedValue = (UInt16)this.GetInt32(0, UInt16.MaxValue);
- string strValue = expectedValue.ToString("f");
- numberStyle = NumberStyles.Any;
- actualValue = UInt16.Parse(strValue, numberStyle);
- if (actualValue != expectedValue)
- {
- errorDesc = "The parse value of " + strValue + " with number styles " +
- numberStyle + " is not the value " + UInt16.MaxValue +
- " as expected: actual(" + actualValue + ")";
- TestLibrary.TestFramework.LogError("009", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("010", "Unexpect exception:" + e);
- retVal = false;
- }
- return retVal;
- }
- #endregion
-
- #region Negative tests
- //ArgumentNullException
- public bool NegTest1()
- {
- bool retVal = true;
-
- const string c_TEST_ID = "N001";
- const string c_TEST_DESC = "NegTest1: string representation is a null reference";
- string errorDesc;
-
- TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
- try
- {
- UInt16.Parse(null, NumberStyles.Integer);
- errorDesc = "ArgumentNullException is not thrown as expected.";
- TestLibrary.TestFramework.LogError("011" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
-
- }
- catch (ArgumentNullException)
- { }
- catch (Exception e)
- {
- errorDesc = "Unexpected exception: " + e;
- TestLibrary.TestFramework.LogError("012" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- return retVal;
- }
-
- //FormatException
- public bool NegTest2()
- {
- bool retVal = true;
-
- const string c_TEST_ID = "N002";
- const string c_TEST_DESC = "NegTest2: String representation is not in the correct format";
- string errorDesc;
-
- string strValue;
-
- TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
- try
- {
- strValue = "Incorrect";
- UInt16.Parse(strValue, NumberStyles.Integer);
- errorDesc = "FormatException is not thrown as expected.";
- TestLibrary.TestFramework.LogError("013" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- catch (FormatException)
- { }
- catch (Exception e)
- {
- errorDesc = "Unexpected exception: " + e;
- TestLibrary.TestFramework.LogError("014" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- return retVal;
- }
-
- public bool NegTest3()
- {
- bool retVal = true;
-
- const string c_TEST_ID = "N003";
- const string c_TEST_DESC = "NegTest3: String representation does not match the correct number style";
- string errorDesc;
-
- string strValue;
- strValue = this.GetInt32(0, UInt16.MaxValue).ToString("c");
- NumberStyles numberStyle = NumberStyles.None;
-
- TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
- try
- {
- UInt16.Parse(strValue, numberStyle);
-
- errorDesc = "FormatException is not thrown as expected.";
-
- errorDesc += string.Format("\nString representation is {0}, number styles is {1}",
- strValue,
- numberStyle);
-
- TestLibrary.TestFramework.LogError("013" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- catch (FormatException)
- { }
- catch (Exception e)
- {
- errorDesc = "Unexpected exception: " + e;
- errorDesc += string.Format("\nString representation is {0}, number styles is {1}",
- strValue,
- numberStyle);
- TestLibrary.TestFramework.LogError("014" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- return retVal;
- }
-
- //OverflowException
- public bool NegTest4()
- {
- bool retVal = true;
-
- const string c_TEST_ID = "N004";
- const string c_TEST_DESC = "NegTest4: String representation is greater than UInt16.MaxValue";
- string errorDesc;
-
- string strValue;
- int i;
-
- i = this.GetInt32(UInt16.MaxValue + 1, int.MaxValue);
- strValue = i.ToString();
-
- TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
- try
- {
- UInt16.Parse(strValue, NumberStyles.None);
- errorDesc = "OverflowException is not thrown as expected.";
- errorDesc += string.Format("\nString representation is {0}, number styles is {1}",
- strValue,
- NumberStyles.None);
- TestLibrary.TestFramework.LogError("015" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- catch (OverflowException)
- { }
- catch (Exception e)
- {
- errorDesc = "Unexpected exception: " + e;
- errorDesc += string.Format("\nString representation is {0}, number styles is {1}",
- strValue,
- NumberStyles.None);
- TestLibrary.TestFramework.LogError("016" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- return retVal;
- }
-
- public bool NegTest5()
- {
- bool retVal = true;
-
- const string c_TEST_ID = "N005";
- const string c_TEST_DESC = "NegTest5: String representation is less than UInt16.MaxValue";
- string errorDesc;
-
- string strValue;
- int i;
-
- i = -1 * TestLibrary.Generator.GetInt32(-55) - 1;
- strValue = i.ToString();
-
- TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
- try
- {
- UInt16.Parse(strValue, NumberStyles.Integer);
- errorDesc = "OverflowException is not thrown as expected.";
- errorDesc += string.Format("\nString representation is {0}, number styles is {1}",
- strValue,
- NumberStyles.Integer);
- TestLibrary.TestFramework.LogError("017" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- catch (OverflowException)
- { }
- catch (Exception e)
- {
- errorDesc = "Unexpected exception: " + e;
- errorDesc += string.Format("\nString representation is {0}, number styles is {1}",
- strValue,
- NumberStyles.Integer);
- TestLibrary.TestFramework.LogError("018" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- return retVal;
- }
-
- //ArgumentException
- public bool NegTest6()
- {
- bool retVal = true;
-
- const string c_TEST_ID = "N006";
- const string c_TEST_DESC = "NegTest6: style is not a NumberStyles value.";
- string errorDesc;
-
- string strValue;
- UInt16 i;
-
- i = (UInt16)(TestLibrary.Generator.GetInt32(-55) % (UInt16.MaxValue + 1));
- strValue = i.ToString();
- NumberStyles numberStyle = (NumberStyles)(0x204 + TestLibrary.Generator.GetInt16(-55));
-
- TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
- try
- {
- UInt16.Parse(strValue, numberStyle);
-
- errorDesc = "ArgumentException is not thrown as expected.";
- errorDesc += string.Format("\nString representation is {0}, number styles is {1}",
- strValue,
- numberStyle);
- TestLibrary.TestFramework.LogError("019" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- catch (ArgumentException)
- { }
- catch (Exception e)
- {
- errorDesc = "Unexpected exception: " + e;
- errorDesc += string.Format("\nString representation is {0}, number styles is {1}",
- strValue,
- numberStyle);
- TestLibrary.TestFramework.LogError("020" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- return retVal;
- }
-
- public bool NegTest7()
- {
- bool retVal = true;
-
- const string c_TEST_ID = "N007";
- const string c_TEST_DESC = "NegTest7: style is not a combination of AllowHexSpecifier and HexNumber values.";
- string errorDesc;
-
- string strValue;
- UInt16 i;
-
- i = (UInt16)(TestLibrary.Generator.GetInt32(-55) % (UInt16.MaxValue + 1));
- strValue = i.ToString();
- NumberStyles numberStyle = (NumberStyles)(NumberStyles.AllowHexSpecifier |
- NumberStyles.AllowCurrencySymbol);
-
- TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
- try
- {
- UInt16.Parse(strValue, numberStyle);
-
- errorDesc = "ArgumentException is not thrown as expected.";
- errorDesc += string.Format("\nString representation is {0}, number styles is {1}",
- strValue,
- numberStyle);
- TestLibrary.TestFramework.LogError("021" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- catch (ArgumentException)
- { }
- catch (Exception e)
- {
- errorDesc = "Unexpected exception: " + e;
- errorDesc += string.Format("\nString representation is {0}, number styles is {1}",
- strValue,
- numberStyle);
- TestLibrary.TestFramework.LogError("022" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- return retVal;
- }
- #endregion
-
- #region ForTestObject
- private Int32 GetInt32(Int32 minValue, Int32 maxValue)
- {
- try
- {
- if (minValue == maxValue)
- {
- return minValue;
- }
- if (minValue < maxValue)
- {
- return minValue + TestLibrary.Generator.GetInt32(-55) % (maxValue - minValue);
- }
- }
- catch
- {
- throw;
- }
-
- return minValue;
- }
-
- #endregion
-}
diff --git a/tests/src/CoreMangLib/cti/system/uint16/uint16parse3.cs b/tests/src/CoreMangLib/cti/system/uint16/uint16parse3.cs
deleted file mode 100644
index 27813a5835..0000000000
--- a/tests/src/CoreMangLib/cti/system/uint16/uint16parse3.cs
+++ /dev/null
@@ -1,548 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Globalization;
-
-/// <summary>
-/// UInt16.Parse(String, NumberStyles, IFormatProvider)
-/// </summary>
-public class UInt16Parse
-{
- public static int Main()
- {
- UInt16Parse ui32ct2 = new UInt16Parse();
- TestLibrary.TestFramework.BeginTestCase("for method: UInt16.Parse(String, NumberStyles, IFormatProvider)");
-
- if (ui32ct2.RunTests())
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("PASS");
- return 100;
- }
- else
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("FAIL");
- return 0;
- }
- }
- public bool RunTests()
- {
- bool retVal = true;
-
- TestLibrary.TestFramework.LogInformation("[Positive]");
- retVal = PosTest1() && retVal;
- retVal = PosTest2() && retVal;
- retVal = PosTest3() && retVal;
- retVal = PosTest4() && retVal;
- retVal = PosTest5() && retVal;
-
- TestLibrary.TestFramework.LogInformation("[Negative]");
- retVal = NegTest1() && retVal;
- retVal = NegTest2() && retVal;
- retVal = NegTest3() && retVal;
- retVal = NegTest4() && retVal;
- retVal = NegTest5() && retVal;
- retVal = NegTest6() && retVal;
- retVal = NegTest7() && retVal;
-
- return retVal;
- }
- #region PositiveTest
- public bool PosTest1()
- {
- bool retVal = true;
- string errorDesc;
-
- UInt16 actualValue;
- NumberStyles numberStyle;
- CultureInfo culture;
- IFormatProvider provider;
-
- numberStyle = NumberStyles.Integer;
- string strValue = UInt16.MaxValue.ToString();
- strValue = " " + strValue + " ";
- culture = CultureInfo.InvariantCulture;
- provider = culture.NumberFormat;
-
- TestLibrary.TestFramework.BeginScenario("PosTest1: UInt16.MaxValue, number style is NumberStyles.Integer.");
- try
- {
- actualValue = UInt16.Parse(strValue, numberStyle, provider);
- if (actualValue != UInt16.MaxValue)
- {
- errorDesc = "The parse value of " + strValue + " with number styles " +
- numberStyle + " and format " + culture.NumberFormat +
- " is not the value " + UInt16.MaxValue +
- " as expected: actual(" + actualValue + ")";
- TestLibrary.TestFramework.LogError("001", errorDesc);
- retVal = false;
- }
- }
- catch (Exception e)
- {
- errorDesc = "Unexpect exception:" + e;
- errorDesc = "\nThe string representation is " + strValue + " with number styles " +
- numberStyle + " and format " + culture.NumberFormat;
- TestLibrary.TestFramework.LogError("002", errorDesc);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest2()
- {
- bool retVal = true;
- string errorDesc;
-
- UInt16 actualValue;
- NumberStyles numberStyle;
- CultureInfo culture;
- IFormatProvider provider;
-
- string strValue = UInt16.MinValue.ToString();
- numberStyle = NumberStyles.None;
- culture = CultureInfo.InvariantCulture;
- provider = culture.NumberFormat;
-
- TestLibrary.TestFramework.BeginScenario("PosTest2: UInt16.MinValue, number style is NumberStyles.None.");
- try
- {
- actualValue = UInt16.Parse(strValue, numberStyle,provider);
- if (actualValue != UInt16.MinValue)
- {
- errorDesc = "The parse value of " + strValue + " with number styles " +
- numberStyle + " and format " + culture.NumberFormat +
- " is not the value " + UInt16.MaxValue +
- " as expected: actual(" + actualValue + ")";
- TestLibrary.TestFramework.LogError("003", errorDesc);
- retVal = false;
- }
- }
- catch (Exception e)
- {
- errorDesc = "Unexpect exception:" + e;
- errorDesc = "\nThe string representation is " + strValue + " with number styles " +
- numberStyle + " and format " + culture.NumberFormat;
- TestLibrary.TestFramework.LogError("004", errorDesc);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest3()
- {
- bool retVal = true;
- string errorDesc;
-
- UInt16 expectedValue;
- UInt16 actualValue;
- NumberStyles numberStyle;
- CultureInfo culture;
- IFormatProvider provider;
-
- expectedValue = (UInt16)this.GetInt32(0, UInt16.MaxValue);
- string strValue = expectedValue.ToString("x");
- numberStyle = NumberStyles.HexNumber;
- culture = CultureInfo.InvariantCulture;
- provider = culture.NumberFormat;
-
- TestLibrary.TestFramework.BeginScenario("PosTest3: random hexadecimal UInt16 value between 0 and UInt16.MaxValue");
- try
- {
- actualValue = UInt16.Parse(strValue, numberStyle,provider);
- if (actualValue != expectedValue)
- {
- errorDesc = "The parse value of " + strValue + " with number styles " +
- numberStyle + " and format " + culture.NumberFormat +
- " is not the value " + UInt16.MaxValue +
- " as expected: actual(" + actualValue + ")";
- TestLibrary.TestFramework.LogError("005", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- errorDesc = "Unexpect exception:" + e;
- errorDesc = "\nThe string representation is " + strValue + " with number styles " +
- numberStyle + " and format " + culture.NumberFormat;
- TestLibrary.TestFramework.LogError("006", errorDesc);
- retVal = false;
- }
- return retVal;
- }
-
- public bool PosTest4()
- {
- bool retVal = true;
- string errorDesc;
-
- UInt16 expectedValue;
- UInt16 actualValue;
- NumberStyles numberStyle;
- CultureInfo culture;
- IFormatProvider provider;
- string strValue;
-
- expectedValue = (UInt16)this.GetInt32(0, UInt16.MaxValue);
- strValue = expectedValue.ToString("c");
- numberStyle = NumberStyles.Currency;
- culture = CultureInfo.CurrentCulture;
- provider = culture.NumberFormat;
-
- TestLibrary.TestFramework.BeginScenario("PosTest4: random currency UInt16 value between 0 and UInt16.MaxValue");
- try
- {
- actualValue = UInt16.Parse(strValue, numberStyle,provider);
- if (actualValue != expectedValue)
- {
- errorDesc = "The parse value of " + strValue + " with number styles " +
- numberStyle + " and format " + culture.NumberFormat +
- " is not the value " + UInt16.MaxValue +
- " as expected: actual(" + actualValue + ")";
- TestLibrary.TestFramework.LogError("007", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- errorDesc = "Unexpect exception:" + e;
- errorDesc = "\nThe string representation is " + strValue + " with number styles " +
- numberStyle + " and format " + culture.NumberFormat;
- TestLibrary.TestFramework.LogError("008", errorDesc);
- retVal = false;
- }
- return retVal;
- }
-
- public bool PosTest5()
- {
- bool retVal = true;
- string errorDesc;
-
- UInt16 expectedValue;
- UInt16 actualValue;
- NumberStyles numberStyle;
- CultureInfo culture;
- IFormatProvider provider;
-
- expectedValue = (UInt16)this.GetInt32(0, UInt16.MaxValue);
- string strValue = expectedValue.ToString("f");
- numberStyle = NumberStyles.Any;
- culture = CultureInfo.InvariantCulture;
- provider = culture.NumberFormat;
-
- TestLibrary.TestFramework.BeginScenario("PosTest5: random UInt16 value between 0 and UInt16.MaxValue, number styles is NumberStyels.Any");
- try
- {
- actualValue = UInt16.Parse(strValue, numberStyle);
- if (actualValue != expectedValue)
- {
- errorDesc = "The parse value of " + strValue + " with number styles " +
- numberStyle + " and format " + culture.NumberFormat +
- " is not the value " + UInt16.MaxValue +
- " as expected: actual(" + actualValue + ")";
- TestLibrary.TestFramework.LogError("009", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- errorDesc = "Unexpect exception:" + e;
- errorDesc = "\nThe string representation is " + strValue + " with number styles " +
- numberStyle + " and format " + culture.NumberFormat;
- TestLibrary.TestFramework.LogError("010", errorDesc);
- retVal = false;
- }
- return retVal;
- }
- #endregion
-
- #region Negative tests
- //ArgumentNullException
- public bool NegTest1()
- {
- bool retVal = true;
-
- const string c_TEST_ID = "N001";
- const string c_TEST_DESC = "NegTest1: string representation is a null reference";
- string errorDesc;
-
- TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
- try
- {
- UInt16.Parse(null, NumberStyles.Integer, null);
- errorDesc = "ArgumentNullException is not thrown as expected.";
- TestLibrary.TestFramework.LogError("011" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
-
- }
- catch (ArgumentNullException)
- { }
- catch (Exception e)
- {
- errorDesc = "Unexpected exception: " + e;
- TestLibrary.TestFramework.LogError("012" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- return retVal;
- }
-
- //FormatException
- public bool NegTest2()
- {
- bool retVal = true;
-
- const string c_TEST_ID = "N002";
- const string c_TEST_DESC = "NegTest2: String representation is not in the correct format";
- string errorDesc;
-
- string strValue;
-
- TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
- try
- {
- strValue = "Incorrect";
- UInt16.Parse(strValue, NumberStyles.Integer, null);
- errorDesc = "FormatException is not thrown as expected.";
- TestLibrary.TestFramework.LogError("013" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- catch (FormatException)
- { }
- catch (Exception e)
- {
- errorDesc = "Unexpected exception: " + e;
- TestLibrary.TestFramework.LogError("014" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- return retVal;
- }
-
- public bool NegTest3()
- {
- bool retVal = true;
-
- const string c_TEST_ID = "N003";
- const string c_TEST_DESC = "NegTest3: String representation does not match the correct number style";
- string errorDesc;
-
- string strValue;
- strValue = this.GetInt32(0, UInt16.MaxValue).ToString("c");
- NumberStyles numberStyle = NumberStyles.None;
-
- TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
- try
- {
- UInt16.Parse(strValue, numberStyle, null);
-
- errorDesc = "FormatException is not thrown as expected.";
-
- errorDesc += string.Format("\nString representation is {0}, number styles is {1}",
- strValue,
- numberStyle);
-
- TestLibrary.TestFramework.LogError("013" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- catch (FormatException)
- { }
- catch (Exception e)
- {
- errorDesc = "Unexpected exception: " + e;
- errorDesc += string.Format("\nString representation is {0}, number styles is {1}",
- strValue,
- numberStyle);
- TestLibrary.TestFramework.LogError("014" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- return retVal;
- }
-
- //OverflowException
- public bool NegTest4()
- {
- bool retVal = true;
-
- const string c_TEST_ID = "N004";
- const string c_TEST_DESC = "NegTest4: String representation is greater than UInt16.MaxValue";
- string errorDesc;
-
- string strValue;
- int i;
-
- i = this.GetInt32(UInt16.MaxValue + 1, int.MaxValue);
- strValue = i.ToString();
-
- TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
- try
- {
- UInt16.Parse(strValue, NumberStyles.None, null);
- errorDesc = "OverflowException is not thrown as expected.";
- errorDesc += string.Format("\nString representation is {0}, number styles is {1}",
- strValue,
- NumberStyles.None);
- TestLibrary.TestFramework.LogError("015" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- catch (OverflowException)
- { }
- catch (Exception e)
- {
- errorDesc = "Unexpected exception: " + e;
- errorDesc += string.Format("\nString representation is {0}, number styles is {1}",
- strValue,
- NumberStyles.None);
- TestLibrary.TestFramework.LogError("016" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- return retVal;
- }
-
- public bool NegTest5()
- {
- bool retVal = true;
-
- const string c_TEST_ID = "N005";
- const string c_TEST_DESC = "NegTest5: String representation is less than UInt16.MaxValue";
- string errorDesc;
-
- string strValue;
- int i;
-
- i = -1 * TestLibrary.Generator.GetInt32(-55) - 1;
- strValue = i.ToString();
-
- TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
- try
- {
- UInt16.Parse(strValue, NumberStyles.Integer, null);
- errorDesc = "OverflowException is not thrown as expected.";
- errorDesc += string.Format("\nString representation is {0}, number styles is {1}",
- strValue,
- NumberStyles.Integer);
- TestLibrary.TestFramework.LogError("017" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- catch (OverflowException)
- { }
- catch (Exception e)
- {
- errorDesc = "Unexpected exception: " + e;
- errorDesc += string.Format("\nString representation is {0}, number styles is {1}",
- strValue,
- NumberStyles.Integer);
- TestLibrary.TestFramework.LogError("018" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- return retVal;
- }
-
- //ArgumentException
- public bool NegTest6()
- {
- bool retVal = true;
-
- const string c_TEST_ID = "N006";
- const string c_TEST_DESC = "NegTest6: style is not a NumberStyles value.";
- string errorDesc;
-
- string strValue;
- UInt16 i;
-
- i = (UInt16)(TestLibrary.Generator.GetInt32(-55) % (UInt16.MaxValue + 1));
- strValue = i.ToString();
- NumberStyles numberStyle = (NumberStyles)(0x204 + TestLibrary.Generator.GetInt16(-55));
-
- TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
- try
- {
- UInt16.Parse(strValue, numberStyle, null);
-
- errorDesc = "ArgumentException is not thrown as expected.";
- errorDesc += string.Format("\nString representation is {0}, number styles is {1}",
- strValue,
- numberStyle);
- TestLibrary.TestFramework.LogError("019" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- catch (ArgumentException)
- { }
- catch (Exception e)
- {
- errorDesc = "Unexpected exception: " + e;
- errorDesc += string.Format("\nString representation is {0}, number styles is {1}",
- strValue,
- numberStyle);
- TestLibrary.TestFramework.LogError("020" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- return retVal;
- }
-
- public bool NegTest7()
- {
- bool retVal = true;
-
- const string c_TEST_ID = "N007";
- const string c_TEST_DESC = "NegTest7: style is not a combination of AllowHexSpecifier and HexNumber values.";
- string errorDesc;
-
- string strValue;
- UInt16 i;
-
- i = (UInt16)(TestLibrary.Generator.GetInt32(-55) % (UInt16.MaxValue + 1));
- strValue = i.ToString();
- NumberStyles numberStyle = (NumberStyles)(NumberStyles.AllowHexSpecifier |
- NumberStyles.AllowCurrencySymbol);
-
- TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
- try
- {
- UInt16.Parse(strValue, numberStyle, null);
-
- errorDesc = "ArgumentException is not thrown as expected.";
- errorDesc += string.Format("\nString representation is {0}, number styles is {1}",
- strValue,
- numberStyle);
- TestLibrary.TestFramework.LogError("021" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- catch (ArgumentException)
- { }
- catch (Exception e)
- {
- errorDesc = "Unexpected exception: " + e;
- errorDesc += string.Format("\nString representation is {0}, number styles is {1}",
- strValue,
- numberStyle);
- TestLibrary.TestFramework.LogError("022" + " TestId-" + c_TEST_ID, errorDesc);
- retVal = false;
- }
- return retVal;
- }
- #endregion
-
- #region ForTestObject
- private Int32 GetInt32(Int32 minValue, Int32 maxValue)
- {
- try
- {
- if (minValue == maxValue)
- {
- return minValue;
- }
- if (minValue < maxValue)
- {
- return minValue + TestLibrary.Generator.GetInt32(-55) % (maxValue - minValue);
- }
- }
- catch
- {
- throw;
- }
-
- return minValue;
- }
-
- #endregion
-}
diff --git a/tests/src/CoreMangLib/cti/system/uint16/uint16tryparse.cs b/tests/src/CoreMangLib/cti/system/uint16/uint16tryparse.cs
deleted file mode 100644
index fa879fea2c..0000000000
--- a/tests/src/CoreMangLib/cti/system/uint16/uint16tryparse.cs
+++ /dev/null
@@ -1,554 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Globalization;
-
-// CoreCLR Port from Co7526TryParse_all.cs
-// Tests UInt16.TryParse(String), UInt16.TryParse(String, NumberStyles, IFormatProvider, ref UInt16)
-// 2003/04/01 KatyK
-// 2007/06/28 adapted by MarielY
-
-public class Co7526TryParse
-{
- static bool verbose = false;
-
- public static int Main()
- {
- bool passed = true;
-
- try
- {
- // Make the test culture independent
- TestLibrary.Utilities.CurrentCulture = CultureInfo.InvariantCulture;
-
- // Set up NFIs to use
- NumberFormatInfo goodNFI = new NumberFormatInfo();
-
- NumberFormatInfo corruptNFI = new NumberFormatInfo(); // DecimalSeparator == GroupSeparator
- corruptNFI.NumberDecimalSeparator = ".";
- corruptNFI.NumberGroupSeparator = ".";
- corruptNFI.CurrencyDecimalSeparator = ".";
- corruptNFI.CurrencyGroupSeparator = ".";
- corruptNFI.CurrencySymbol = "$";
-
- NumberFormatInfo swappedNFI = new NumberFormatInfo(); // DecimalSeparator & GroupSeparator swapped
- swappedNFI.NumberDecimalSeparator = ".";
- swappedNFI.NumberGroupSeparator = ",";
- swappedNFI.CurrencyDecimalSeparator = ",";
- swappedNFI.CurrencyGroupSeparator = ".";
- swappedNFI.CurrencySymbol = "$";
-
- NumberFormatInfo distinctNFI = new NumberFormatInfo(); // DecimalSeparator & GroupSeparator distinct
- distinctNFI.NumberDecimalSeparator = ".";
- distinctNFI.NumberGroupSeparator = ",";
- distinctNFI.CurrencyDecimalSeparator = ":";
- distinctNFI.CurrencyGroupSeparator = ";";
- distinctNFI.CurrencySymbol = "$";
-
- NumberFormatInfo customNFI = new NumberFormatInfo();
- customNFI.NegativeSign = "^";
-
- NumberFormatInfo ambigNFI = new NumberFormatInfo();
- ambigNFI.NegativeSign = "^";
- ambigNFI.CurrencySymbol = "^";
-
- CultureInfo germanCulture = new CultureInfo("de-DE");
- CultureInfo japaneseCulture;
-
- try
- {
- japaneseCulture = new CultureInfo("ja-JP");
- }
- catch (Exception)
- {
- TestLibrary.Logging.WriteLine("East Asian Languages are not installed. Skiping Japanese culture tests.");
- japaneseCulture = null;
- }
-
- // Parse tests included for comparison/regression
- passed &= VerifyUInt16Parse("5", 5);
- passed &= VerifyUInt16Parse("5 ", 5);
- passed &= VerifyUInt16Parse("5\0", 5);
- passed &= VerifyUInt16Parse("10000", 10000);
- passed &= VerifyUInt16Parse("50000", 50000);
- passed &= VerifyUInt16Parse("5", NumberStyles.Integer, CultureInfo.InvariantCulture, 5);
- passed &= VerifyUInt16Parse("5 \0", NumberStyles.Integer, CultureInfo.InvariantCulture, 5);
- passed &= VerifyUInt16Parse("5\0\0\0", NumberStyles.Integer, CultureInfo.InvariantCulture, 5);
- passed &= VerifyUInt16Parse("12", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0x12);
- passed &= VerifyUInt16Parse("fF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0xFF);
- passed &= VerifyUInt16Parse("fFFF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0xFFFF);
- passed &= VerifyUInt16Parse("5", NumberStyles.Integer, goodNFI, 5);
- passed &= VerifyUInt16Parse("5.0", NumberStyles.AllowDecimalPoint, goodNFI, 5);
- passed &= VerifyUInt16Parse("123", NumberStyles.Integer, germanCulture, 123);
- passed &= VerifyUInt16Parse("123", NumberStyles.Integer, japaneseCulture, 123);
- passed &= VerifyUInt16Parse("123,000", NumberStyles.AllowDecimalPoint, germanCulture, 123);
- passed &= VerifyUInt16Parse("123.000", NumberStyles.AllowDecimalPoint, japaneseCulture, 123);
- passed &= VerifyUInt16Parse("5,00 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Any, germanCulture, 5); // currency
- //
- passed &= VerifyUInt16Parse("5", NumberStyles.Integer, corruptNFI, 5);
- passed &= VerifyUInt16Parse("5", NumberStyles.Number, corruptNFI, 5);
- passed &= VerifyUInt16Parse("5.0", NumberStyles.Number, corruptNFI, 5);
- passed &= VerifyUInt16ParseException("5,0", NumberStyles.Number, corruptNFI, typeof(FormatException));
- passed &= VerifyUInt16ParseException("5.0.0", NumberStyles.Number, corruptNFI, typeof(FormatException));
- passed &= VerifyUInt16Parse("$5.0", NumberStyles.Currency, corruptNFI, 5);
- passed &= VerifyUInt16ParseException("$5,0", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyUInt16ParseException("$5.0.0", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyUInt16Parse("5.0", NumberStyles.Currency, corruptNFI, 5);
- passed &= VerifyUInt16ParseException("5,0", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyUInt16ParseException("5.0.0", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyUInt16Parse("5.0", NumberStyles.Any, corruptNFI, 5);
- passed &= VerifyUInt16ParseException("5,0", NumberStyles.Any, corruptNFI, typeof(FormatException));
- passed &= VerifyUInt16ParseException("5.0.0", NumberStyles.Any, corruptNFI, typeof(FormatException));
- //
- passed &= VerifyUInt16Parse("5", NumberStyles.Integer, swappedNFI, 5);
- passed &= VerifyUInt16ParseException("1,234", NumberStyles.Integer, swappedNFI, typeof(FormatException));
- passed &= VerifyUInt16Parse("5", NumberStyles.Number, swappedNFI, 5);
- passed &= VerifyUInt16Parse("5.0", NumberStyles.Number, swappedNFI, 5);
- passed &= VerifyUInt16Parse("1,234", NumberStyles.Number, swappedNFI, 1234);
- passed &= VerifyUInt16Parse("1,234.0", NumberStyles.Number, swappedNFI, 1234);
- passed &= VerifyUInt16ParseException("5.000.000", NumberStyles.Number, swappedNFI, typeof(FormatException));
- passed &= VerifyUInt16ParseException("5.000,00", NumberStyles.Number, swappedNFI, typeof(FormatException));
- passed &= VerifyUInt16Parse("5.000", NumberStyles.Currency, swappedNFI, 5); //???
- passed &= VerifyUInt16ParseException("5.000,00", NumberStyles.Currency, swappedNFI, typeof(FormatException)); //???
- passed &= VerifyUInt16Parse("$5.000", NumberStyles.Currency, swappedNFI, 5000);
- passed &= VerifyUInt16Parse("$5.000,00", NumberStyles.Currency, swappedNFI, 5000);
- passed &= VerifyUInt16Parse("5.000", NumberStyles.Any, swappedNFI, 5); //?
- passed &= VerifyUInt16ParseException("5.000,00", NumberStyles.Any, swappedNFI, typeof(FormatException)); //?
- passed &= VerifyUInt16Parse("$5.000", NumberStyles.Any, swappedNFI, 5000);
- passed &= VerifyUInt16Parse("$5.000,00", NumberStyles.Any, swappedNFI, 5000);
- passed &= VerifyUInt16Parse("5,0", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyUInt16Parse("$5,0", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyUInt16Parse("5,000", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyUInt16Parse("$5,000", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyUInt16ParseException("5,000.0", NumberStyles.Currency, swappedNFI, typeof(FormatException));
- passed &= VerifyUInt16ParseException("$5,000.0", NumberStyles.Currency, swappedNFI, typeof(FormatException));
- passed &= VerifyUInt16Parse("5,000", NumberStyles.Any, swappedNFI, 5);
- passed &= VerifyUInt16Parse("$5,000", NumberStyles.Any, swappedNFI, 5);
- passed &= VerifyUInt16ParseException("5,000.0", NumberStyles.Any, swappedNFI, typeof(FormatException));
- passed &= VerifyUInt16ParseException("$5,000.0", NumberStyles.Any, swappedNFI, typeof(FormatException));
- //
- passed &= VerifyUInt16Parse("5.0", NumberStyles.Number, distinctNFI, 5);
- passed &= VerifyUInt16Parse("1,234.0", NumberStyles.Number, distinctNFI, 1234);
- passed &= VerifyUInt16Parse("5.0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyUInt16Parse("1,234.0", NumberStyles.Currency, distinctNFI, 1234);
- passed &= VerifyUInt16Parse("5.0", NumberStyles.Any, distinctNFI, 5);
- passed &= VerifyUInt16Parse("1,234.0", NumberStyles.Any, distinctNFI, 1234);
- passed &= VerifyUInt16ParseException("$5.0", NumberStyles.Currency, distinctNFI, typeof(FormatException));
- passed &= VerifyUInt16ParseException("$5.0", NumberStyles.Any, distinctNFI, typeof(FormatException));
- passed &= VerifyUInt16ParseException("5:0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyUInt16ParseException("5;0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyUInt16ParseException("$5:0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyUInt16Parse("5:0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyUInt16Parse("5:000", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyUInt16Parse("5;000", NumberStyles.Currency, distinctNFI, 5000);
- passed &= VerifyUInt16Parse("$5:0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyUInt16Parse("$5;0", NumberStyles.Currency, distinctNFI, 50);
- passed &= VerifyUInt16Parse("5:0", NumberStyles.Any, distinctNFI, 5);
- passed &= VerifyUInt16Parse("5;0", NumberStyles.Any, distinctNFI, 50);
- passed &= VerifyUInt16Parse("$5:0", NumberStyles.Any, distinctNFI, 5);
- passed &= VerifyUInt16Parse("$5;0", NumberStyles.Any, distinctNFI, 50);
- passed &= VerifyUInt16ParseException("1,23;45.0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyUInt16Parse("1,23;45.0", NumberStyles.Currency, distinctNFI, 12345);
- passed &= VerifyUInt16Parse("1,23;45.0", NumberStyles.Any, distinctNFI, 12345);
- passed &= VerifyUInt16ParseException("$1,23;45.0", NumberStyles.Any, distinctNFI, typeof(FormatException));
- //
- passed &= VerifyUInt16ParseException("-5", typeof(OverflowException));
- passed &= VerifyUInt16ParseException("100000", typeof(OverflowException));
- passed &= VerifyUInt16ParseException("Garbage", typeof(FormatException));
- passed &= VerifyUInt16ParseException("5\0Garbage", typeof(FormatException));
- passed &= VerifyUInt16ParseException(null, typeof(ArgumentNullException));
- passed &= VerifyUInt16ParseException("1FFFF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, typeof(OverflowException));
- passed &= VerifyUInt16ParseException("FFFFFFFF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, typeof(OverflowException));
- passed &= VerifyUInt16ParseException("5", NumberStyles.AllowHexSpecifier | NumberStyles.AllowParentheses, null, typeof(ArgumentException));
- passed &= VerifyUInt16ParseException("4", (NumberStyles)(-1), typeof(ArgumentException));
- passed &= VerifyUInt16ParseException("4", (NumberStyles)0x10000, typeof(ArgumentException));
- passed &= VerifyUInt16ParseException("4", (NumberStyles)(-1), CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifyUInt16ParseException("4", (NumberStyles)0x10000, CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifyUInt16ParseException("123.000", NumberStyles.Any, germanCulture, typeof(OverflowException));
- passed &= VerifyUInt16ParseException("123,000", NumberStyles.Any, japaneseCulture, typeof(OverflowException));
- passed &= VerifyUInt16ParseException("123,000", NumberStyles.Integer, germanCulture, typeof(FormatException));
- passed &= VerifyUInt16ParseException("123.000", NumberStyles.Integer, japaneseCulture, typeof(FormatException));
- passed &= VerifyUInt16ParseException("5,00 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Integer, germanCulture, typeof(FormatException)); // currency
-
-
- /////////// TryParse(String)
- //// Pass cases
- passed &= VerifyUInt16TryParse("5", 5, true);
- passed &= VerifyUInt16TryParse(" 5 ", 5, true);
- passed &= VerifyUInt16TryParse("5\0", 5, true);
- passed &= VerifyUInt16TryParse("5 \0", 5, true);
- passed &= VerifyUInt16TryParse("5\0\0\0", 5, true);
- passed &= VerifyUInt16TryParse("10000", 10000, true);
- passed &= VerifyUInt16TryParse("50000", 50000, true);
- passed &= VerifyUInt16TryParse(UInt16.MaxValue.ToString(), UInt16.MaxValue, true);
- passed &= VerifyUInt16TryParse(UInt16.MinValue.ToString(), UInt16.MinValue, true);
-
- //// Fail cases
- passed &= VerifyUInt16TryParse(null, 0, false);
- passed &= VerifyUInt16TryParse("", 0, false);
- passed &= VerifyUInt16TryParse("Garbage", 0, false);
- passed &= VerifyUInt16TryParse("5\0Garbage", 0, false);
- passed &= VerifyUInt16TryParse("-5", 0, false);
- passed &= VerifyUInt16TryParse("100000", 0, false);
- passed &= VerifyUInt16TryParse("-100000", 0, false);
- passed &= VerifyUInt16TryParse("FF", 0, false);
- passed &= VerifyUInt16TryParse("27.3", 0, false);
- passed &= VerifyUInt16TryParse("23 5", 0, false);
-
-
- /////////// TryParse(TryParse(String, NumberStyles, IFormatProvider, ref UInt16)
- //// Pass cases
- passed &= VerifyUInt16TryParse("5", NumberStyles.Integer, CultureInfo.InvariantCulture, 5, true);
- // Variations on NumberStyles
- passed &= VerifyUInt16TryParse("12", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0x12, true);
- passed &= VerifyUInt16TryParse("FF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0xFF, true);
- passed &= VerifyUInt16TryParse("fF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0xFF, true);
- passed &= VerifyUInt16TryParse("fFFF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0xFFFF, true);
- passed &= VerifyUInt16TryParse(" 5", NumberStyles.AllowLeadingWhite, goodNFI, 5, true);
- passed &= VerifyUInt16TryParse("5", NumberStyles.Number, goodNFI, 5, true);
- passed &= VerifyUInt16TryParse("5.0", NumberStyles.AllowDecimalPoint, goodNFI, 5, true);
- // Variations on IFP
- passed &= VerifyUInt16TryParse("5", NumberStyles.Integer, goodNFI, 5, true);
- passed &= VerifyUInt16TryParse("5", NumberStyles.Integer, null, 5, true);
- passed &= VerifyUInt16TryParse("5", NumberStyles.Integer, new DateTimeFormatInfo(), 5, true);
- passed &= VerifyUInt16TryParse("123", NumberStyles.Integer, germanCulture, 123, true);
- passed &= VerifyUInt16TryParse("123", NumberStyles.Integer, japaneseCulture, 123, true);
- passed &= VerifyUInt16TryParse("123,000", NumberStyles.AllowDecimalPoint, germanCulture, 123, true);
- passed &= VerifyUInt16TryParse("123.000", NumberStyles.AllowDecimalPoint, japaneseCulture, 123, true);
- passed &= VerifyUInt16TryParse("5,00 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Any, germanCulture, 5, true); // currency
-
- //// Fail cases
- passed &= VerifyUInt16TryParse("-5", NumberStyles.Integer, CultureInfo.InvariantCulture, 0, false);
- passed &= VerifyUInt16TryParse("FF", NumberStyles.Integer, CultureInfo.InvariantCulture, 0, false);
- passed &= VerifyUInt16TryParse("1FFFF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0, false);
- passed &= VerifyUInt16TryParse("FFFFFFFF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0, false);
- passed &= VerifyUInt16TryParse("^42", NumberStyles.Any, customNFI, 0, false);
- passed &= VerifyUInt16TryParse("-42", NumberStyles.Any, customNFI, 0, false);
- passed &= VerifyUInt16TryParse("5.3", NumberStyles.AllowDecimalPoint, goodNFI, 0, false);
- passed &= VerifyUInt16TryParse("5 ", NumberStyles.AllowLeadingWhite, goodNFI, 0, false);
- passed &= VerifyUInt16TryParse("123.000", NumberStyles.Any, germanCulture, 0, false);
- passed &= VerifyUInt16TryParse("123,000", NumberStyles.Any, japaneseCulture, 0, false);
- passed &= VerifyUInt16TryParse("123,000", NumberStyles.Integer, germanCulture, 0, false);
- passed &= VerifyUInt16TryParse("123.000", NumberStyles.Integer, japaneseCulture, 0, false);
- passed &= VerifyUInt16TryParse("5,00 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Integer, germanCulture, 0, false); // currency
-
- //// Exception cases
- passed &= VerifyUInt16TryParseException("5", NumberStyles.AllowHexSpecifier | NumberStyles.AllowParentheses, null, typeof(ArgumentException));
- passed &= VerifyUInt16TryParseException("4", (NumberStyles)(-1), CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifyUInt16TryParseException("4", (NumberStyles)0x10000, CultureInfo.InvariantCulture, typeof(ArgumentException));
-
- // NumberStyles/NFI variations
- //
- passed &= VerifyUInt16TryParse("5", NumberStyles.Integer, corruptNFI, 5, true);
- passed &= VerifyUInt16TryParse("5", NumberStyles.Number, corruptNFI, 5, true);
- passed &= VerifyUInt16TryParse("5.0", NumberStyles.Number, corruptNFI, 5, true);
- passed &= VerifyUInt16TryParse("5,0", NumberStyles.Number, corruptNFI, 0, false);
- passed &= VerifyUInt16TryParse("5.0.0", NumberStyles.Number, corruptNFI, 0, false);
- passed &= VerifyUInt16TryParse("$5.0", NumberStyles.Currency, corruptNFI, 5, true);
- passed &= VerifyUInt16TryParse("$5,0", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyUInt16TryParse("$5.0.0", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyUInt16TryParse("5.0", NumberStyles.Currency, corruptNFI, 5, true);
- passed &= VerifyUInt16TryParse("5,0", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyUInt16TryParse("5.0.0", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyUInt16TryParse("5.0", NumberStyles.Any, corruptNFI, 5, true);
- passed &= VerifyUInt16TryParse("5,0", NumberStyles.Any, corruptNFI, 0, false);
- passed &= VerifyUInt16TryParse("5.0.0", NumberStyles.Any, corruptNFI, 0, false);
- //
- passed &= VerifyUInt16TryParse("5", NumberStyles.Integer, swappedNFI, 5, true);
- passed &= VerifyUInt16TryParse("1,234", NumberStyles.Integer, swappedNFI, 0, false);
- passed &= VerifyUInt16TryParse("5", NumberStyles.Number, swappedNFI, 5, true);
- passed &= VerifyUInt16TryParse("5.0", NumberStyles.Number, swappedNFI, 5, true);
- passed &= VerifyUInt16TryParse("1,234", NumberStyles.Number, swappedNFI, 1234, true);
- passed &= VerifyUInt16TryParse("1,234.0", NumberStyles.Number, swappedNFI, 1234, true);
- passed &= VerifyUInt16TryParse("5.000.000", NumberStyles.Number, swappedNFI, 0, false);
- passed &= VerifyUInt16TryParse("5.000,00", NumberStyles.Number, swappedNFI, 0, false);
- passed &= VerifyUInt16TryParse("5.000", NumberStyles.Currency, swappedNFI, 5, true); //???
- passed &= VerifyUInt16TryParse("5.000,00", NumberStyles.Currency, swappedNFI, 0, false); //???
- passed &= VerifyUInt16TryParse("$5.000", NumberStyles.Currency, swappedNFI, 5000, true);
- passed &= VerifyUInt16TryParse("$5.000,00", NumberStyles.Currency, swappedNFI, 5000, true);
- passed &= VerifyUInt16TryParse("5.000", NumberStyles.Any, swappedNFI, 5, true); //?
- passed &= VerifyUInt16TryParse("5.000,00", NumberStyles.Any, swappedNFI, 0, false); //?
- passed &= VerifyUInt16TryParse("$5.000", NumberStyles.Any, swappedNFI, 5000, true);
- passed &= VerifyUInt16TryParse("$5.000,00", NumberStyles.Any, swappedNFI, 5000, true);
- passed &= VerifyUInt16TryParse("5,0", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyUInt16TryParse("$5,0", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyUInt16TryParse("5,000", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyUInt16TryParse("$5,000", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyUInt16TryParse("5,000.0", NumberStyles.Currency, swappedNFI, 0, false);
- passed &= VerifyUInt16TryParse("$5,000.0", NumberStyles.Currency, swappedNFI, 0, false);
- passed &= VerifyUInt16TryParse("5,000", NumberStyles.Any, swappedNFI, 5, true);
- passed &= VerifyUInt16TryParse("$5,000", NumberStyles.Any, swappedNFI, 5, true);
- passed &= VerifyUInt16TryParse("5,000.0", NumberStyles.Any, swappedNFI, 0, false);
- passed &= VerifyUInt16TryParse("$5,000.0", NumberStyles.Any, swappedNFI, 0, false);
- //
- passed &= VerifyUInt16TryParse("5.0", NumberStyles.Number, distinctNFI, 5, true);
- passed &= VerifyUInt16TryParse("1,234.0", NumberStyles.Number, distinctNFI, 1234, true);
- passed &= VerifyUInt16TryParse("5.0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyUInt16TryParse("1,234.0", NumberStyles.Currency, distinctNFI, 1234, true);
- passed &= VerifyUInt16TryParse("5.0", NumberStyles.Any, distinctNFI, 5, true);
- passed &= VerifyUInt16TryParse("1,234.0", NumberStyles.Any, distinctNFI, 1234, true);
- passed &= VerifyUInt16TryParse("$5.0", NumberStyles.Currency, distinctNFI, 0, false);
- passed &= VerifyUInt16TryParse("$5.0", NumberStyles.Any, distinctNFI, 0, false);
- passed &= VerifyUInt16TryParse("5:0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyUInt16TryParse("5;0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyUInt16TryParse("$5:0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyUInt16TryParse("5:0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyUInt16TryParse("5:000", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyUInt16TryParse("5;000", NumberStyles.Currency, distinctNFI, 5000, true);
- passed &= VerifyUInt16TryParse("$5:0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyUInt16TryParse("$5;0", NumberStyles.Currency, distinctNFI, 50, true);
- passed &= VerifyUInt16TryParse("5:0", NumberStyles.Any, distinctNFI, 5, true);
- passed &= VerifyUInt16TryParse("5;0", NumberStyles.Any, distinctNFI, 50, true);
- passed &= VerifyUInt16TryParse("$5:0", NumberStyles.Any, distinctNFI, 5, true);
- passed &= VerifyUInt16TryParse("$5;0", NumberStyles.Any, distinctNFI, 50, true);
- passed &= VerifyUInt16TryParse("1,23;45.0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyUInt16TryParse("1,23;45.0", NumberStyles.Currency, distinctNFI, 12345, true);
- passed &= VerifyUInt16TryParse("1,23;45.0", NumberStyles.Any, distinctNFI, 12345, true);
- passed &= VerifyUInt16TryParse("$1,23;45.0", NumberStyles.Any, distinctNFI, 0, false);
-
-
- // Should these pass or fail? Current parse behavior is to pass, so they might be
- // parse bugs, but they're not tryparse bugs.
- passed &= VerifyUInt16Parse("5", NumberStyles.Float, goodNFI, 5);
- passed &= VerifyUInt16TryParse("5", NumberStyles.Float, goodNFI, 5, true);
- passed &= VerifyUInt16Parse("5", NumberStyles.AllowDecimalPoint, goodNFI, 5);
- passed &= VerifyUInt16TryParse("5", NumberStyles.AllowDecimalPoint, goodNFI, 5, true);
- // I expect ArgumentException with an ambiguous NFI
- passed &= VerifyUInt16ParseException("^42", NumberStyles.Any, ambigNFI, typeof(OverflowException));
- passed &= VerifyUInt16TryParse("^42", NumberStyles.Any, ambigNFI, 0, false);
-
- /// END TEST CASES
- }
- catch (Exception e)
- {
- TestLibrary.Logging.WriteLine("Unexpected exception!! " + e.ToString());
- passed = false;
- }
-
- if (passed)
- {
- TestLibrary.Logging.WriteLine("paSs");
- return 100;
- }
- else
- {
- TestLibrary.Logging.WriteLine("FAiL");
- return 1;
- }
- }
-
- public static bool VerifyUInt16TryParse(string value, UInt16 expectedResult, bool expectedReturn)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: UInt16.TryParse, Value = '{0}', Expected Result = {1}, Expected Return = {2}",
- value, expectedResult, expectedReturn);
- }
- UInt16 result = 0;
- try
- {
- bool returnValue = UInt16.TryParse(value, out result);
- if (returnValue != expectedReturn)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedReturn, returnValue);
- return false;
- }
- if (result != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, result);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyUInt16TryParse(string value, NumberStyles style, IFormatProvider provider, UInt16 expectedResult, bool expectedReturn)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: UInt16.TryParse, Value = '{0}', Style = {1}, Provider = {2}, Expected Result = {3}, Expected Return = {4}",
- value, style, provider, expectedResult, expectedReturn);
- }
- UInt16 result = 0;
- try
- {
- bool returnValue = UInt16.TryParse(value, style, provider, out result);
- if (returnValue != expectedReturn)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Style = {1}, Provider = {2}, Expected Return = {3}, Actual Return = {4}",
- value, style, provider, expectedReturn, returnValue);
- return false;
- }
- if (result != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, result);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyUInt16TryParseException(string value, NumberStyles style, IFormatProvider provider, Type exceptionType)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: UInt16.TryParse, Value = '{0}', Style = {1}, Provider = {2}, Expected Exception = {3}",
- value, style, provider, exceptionType);
- }
- try
- {
- UInt16 result = 0;
- Boolean returnValue = UInt16.TryParse(value, style, provider, out result);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifyUInt16Parse(string value, UInt16 expectedResult)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: UInt16.Parse, Value = '{0}', Expected Result, {1}",
- value, expectedResult);
- }
- try
- {
- UInt16 returnValue = UInt16.Parse(value);
- if (returnValue != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, returnValue);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyUInt16Parse(string value, NumberStyles style, IFormatProvider provider, UInt16 expectedResult)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: UInt16.Parse, Value = '{0}', Style = {1}, provider = {2}, Expected Result = {3}",
- value, style, provider, expectedResult);
- }
- try
- {
- UInt16 returnValue = UInt16.Parse(value, style, provider);
- if (returnValue != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, returnValue);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyUInt16ParseException(string value, Type exceptionType)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: UInt16.Parse, Value = '{0}', Expected Exception, {1}",
- value, exceptionType);
- }
- try
- {
- UInt16 returnValue = UInt16.Parse(value);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifyUInt16ParseException(string value, NumberStyles style, Type exceptionType)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: UInt16.Parse, Value = '{0}', Style = {1}, Expected Exception = {3}",
- value, style, exceptionType);
- }
- try
- {
- UInt16 returnValue = UInt16.Parse(value, style);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifyUInt16ParseException(string value, NumberStyles style, IFormatProvider provider, Type exceptionType)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: UInt16.Parse, Value = '{0}', Style = {1}, Provider = {2}, Expected Exception = {3}",
- value, style, provider, exceptionType);
- }
- try
- {
- UInt16 returnValue = UInt16.Parse(value, style, provider);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-}
diff --git a/tests/src/CoreMangLib/cti/system/uint32/UInt32Parse1.csproj b/tests/src/CoreMangLib/cti/system/uint32/UInt32Parse1.csproj
deleted file mode 100644
index a719d100a4..0000000000
--- a/tests/src/CoreMangLib/cti/system/uint32/UInt32Parse1.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="uint32parse1.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/uint32/UInt32Parse2.csproj b/tests/src/CoreMangLib/cti/system/uint32/UInt32Parse2.csproj
deleted file mode 100644
index 285890d49e..0000000000
--- a/tests/src/CoreMangLib/cti/system/uint32/UInt32Parse2.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="uint32parse2.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/uint32/UInt32Parse3.csproj b/tests/src/CoreMangLib/cti/system/uint32/UInt32Parse3.csproj
deleted file mode 100644
index 4bd885ba96..0000000000
--- a/tests/src/CoreMangLib/cti/system/uint32/UInt32Parse3.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="uint32parse3.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/uint32/UInt32TryParse.csproj b/tests/src/CoreMangLib/cti/system/uint32/UInt32TryParse.csproj
deleted file mode 100644
index 4fd243cd80..0000000000
--- a/tests/src/CoreMangLib/cti/system/uint32/UInt32TryParse.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="uint32tryparse.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/uint32/uint32parse1.cs b/tests/src/CoreMangLib/cti/system/uint32/uint32parse1.cs
deleted file mode 100644
index 82d5663433..0000000000
--- a/tests/src/CoreMangLib/cti/system/uint32/uint32parse1.cs
+++ /dev/null
@@ -1,357 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-// v-minch
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Globalization;
-
-/// <summary>
-/// UInt32.Parse(System.string)
-/// </summary>
-public class UInt32Parse1
-{
- public static int Main()
- {
- UInt32Parse1 ui32parse1 = new UInt32Parse1();
- TestLibrary.TestFramework.BeginTestCase("UInt32Parse1");
-
- if (ui32parse1.RunTests())
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("PASS");
- return 100;
- }
- else
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("FAIL");
- return 0;
- }
- }
- public bool RunTests()
- {
- bool retVal = true;
- TestLibrary.TestFramework.LogInformation("[Positive]");
- retVal = PosTest1() && retVal;
- retVal = PosTest2() && retVal;
- retVal = PosTest3() && retVal;
- retVal = PosTest4() && retVal;
- retVal = PosTest5() && retVal;
- retVal = PosTest6() && retVal;
- retVal = PosTest7() && retVal;
- TestLibrary.TestFramework.LogInformation("[Negative]");
- retVal = NegTest1() && retVal;
- retVal = NegTest2() && retVal;
- retVal = NegTest3() && retVal;
- retVal = NegTest4() && retVal;
- retVal = NegTest5() && retVal;
- return retVal;
- }
- #region PostiveTest
- public bool PosTest1()
- {
- bool retVal = true;
- UInt32 uintA;
-
- TestLibrary.TestFramework.BeginScenario("PosTest1: the string corresponding UInt32 is UInt32 MinValue ");
-
- try
- {
- string strA = UInt32.MinValue.ToString();
- uintA = UInt32.Parse(strA);
- if (uintA != 0)
- {
- TestLibrary.TestFramework.LogError("001", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest2()
- {
- bool retVal = true;
- UInt32 uintA;
-
- TestLibrary.TestFramework.BeginScenario("PosTest2: the string corresponding UInt32 is UInt32 MaxValue ");
-
- try
- {
- string strA = UInt32.MaxValue.ToString();
- uintA = UInt32.Parse(strA);
- if (uintA != UInt32.MaxValue)
- {
- TestLibrary.TestFramework.LogError("003", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest3()
- {
- bool retVal = true;
- UInt32 uintA;
-
- TestLibrary.TestFramework.BeginScenario("PosTest3: the string corresponding UInt32 is normal UInt32 ");
-
- try
- {
- UInt32 uintTest = (UInt32)this.GetInt32(0,Int32.MaxValue);
- string strA = uintTest.ToString();
- uintA = UInt32.Parse(strA);
- if (uintA != uintTest)
- {
- TestLibrary.TestFramework.LogError("005", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest4()
- {
- bool retVal = true;
- UInt32 uintA;
-
- TestLibrary.TestFramework.BeginScenario("PosTest4: the string format is [ws][sign]digits[ws] 1");
-
- try
- {
- UInt32 uintTest = (UInt32)this.GetInt32(0, Int32.MaxValue);
- string strA = "+" + uintTest.ToString();
- uintA = UInt32.Parse(strA);
- if (uintA != uintTest)
- {
- TestLibrary.TestFramework.LogError("007", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("008", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest5()
- {
- bool retVal = true;
- UInt32 uintA;
-
- TestLibrary.TestFramework.BeginScenario("PosTest5: the string format is [ws][sign]digits[ws] 2");
-
- try
- {
- UInt32 uintTest = (UInt32)this.GetInt32(0, Int32.MaxValue);
- string strA = "\u0009" + "+" + uintTest.ToString();
- uintA = UInt32.Parse(strA);
- if (uintA != uintTest)
- {
- TestLibrary.TestFramework.LogError("009", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("010", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest6()
- {
- bool retVal = true;
- UInt32 uintA;
-
- TestLibrary.TestFramework.BeginScenario("PosTest6: the string format is [ws][sign]digits[ws] 3");
-
- try
- {
- UInt32 uintTest = (UInt32)this.GetInt32(0, Int32.MaxValue);
- string strA = uintTest.ToString() + "\u0020";
- uintA = UInt32.Parse(strA);
- if (uintA != uintTest)
- {
- TestLibrary.TestFramework.LogError("011", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("012", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest7()
- {
- bool retVal = true;
- UInt32 uintA;
-
- TestLibrary.TestFramework.BeginScenario("PosTest7: the string format is [ws][sign]digits[ws] 4");
-
- try
- {
- UInt32 uintTest = (UInt32)this.GetInt32(0, Int32.MaxValue);
- string strA = "\u0009" + "+" + uintTest.ToString() + "\u0020";
- uintA = UInt32.Parse(strA);
- if (uintA != uintTest)
- {
- TestLibrary.TestFramework.LogError("013", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("014", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- #endregion
- #region NegativeTest
- public bool NegTest1()
- {
- bool retVal = true;
- UInt32 uintA;
- TestLibrary.TestFramework.BeginScenario("NegTest1: the parameter string is null");
-
- try
- {
- string strA = null;
- uintA = UInt32.Parse(strA);
- retVal = false;
- }
- catch (ArgumentNullException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N001", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest2()
- {
- bool retVal = true;
- UInt32 uintA;
- TestLibrary.TestFramework.BeginScenario("NegTest2: the parameter string is not of the correct format 1");
-
- try
- {
- string strA = "abcd";
- uintA = UInt32.Parse(strA);
- retVal = false;
- }
- catch (FormatException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N002", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest3()
- {
- bool retVal = true;
- UInt32 uintA;
- TestLibrary.TestFramework.BeginScenario("NegTest3: the parameter string is not of the correct format 2");
-
- try
- {
- string strA = "b12345d";
- uintA = UInt32.Parse(strA);
- retVal = false;
- }
- catch (FormatException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N003", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest4()
- {
- bool retVal = true;
- UInt32 uintA;
- TestLibrary.TestFramework.BeginScenario("NegTest4: the parameter string corresponding number is less than UInt32 minValue");
-
- try
- {
- Int32 Testint = (-1) * this.GetInt32(1, Int32.MaxValue);
- string strA = Testint.ToString();
- uintA = UInt32.Parse(strA);
- retVal = false;
- }
- catch (OverflowException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N004", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest5()
- {
- bool retVal = true;
- UInt32 uintA;
- TestLibrary.TestFramework.BeginScenario("NegTest5: the parameter string corresponding number is larger than UInt32 maxValue");
-
- try
- {
- UInt32 uinta = UInt32.MaxValue;
- UInt32 uintb = (UInt32)this.GetInt32(1, Int32.MaxValue);
- UInt64 TestUint = (UInt64)uinta + (UInt64)uintb;
- string strA = TestUint.ToString();
- uintA = UInt32.Parse(strA);
- retVal = false;
- }
- catch (OverflowException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N005", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- #endregion
- #region ForTestObject
- private Int32 GetInt32(Int32 minValue, Int32 maxValue)
- {
- try
- {
- if (minValue == maxValue)
- {
- return minValue;
- }
- if (minValue < maxValue)
- {
- return minValue + TestLibrary.Generator.GetInt32(-55) % (maxValue - minValue);
- }
- }
- catch
- {
- throw;
- }
-
- return minValue;
- }
- #endregion
-}
-
diff --git a/tests/src/CoreMangLib/cti/system/uint32/uint32parse2.cs b/tests/src/CoreMangLib/cti/system/uint32/uint32parse2.cs
deleted file mode 100644
index 5d99378ba2..0000000000
--- a/tests/src/CoreMangLib/cti/system/uint32/uint32parse2.cs
+++ /dev/null
@@ -1,392 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-
-/// <summary>
-/// UInt32.Parse(System.string,NumberStyle style)
-/// </summary>
-public class UInt32Parse2
-{
- public static int Main()
- {
- UInt32Parse2 ui32parse2 = new UInt32Parse2();
- TestLibrary.TestFramework.BeginTestCase("UInt32Parse2");
-
- if (ui32parse2.RunTests())
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("PASS");
- return 100;
- }
- else
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("FAIL");
- return 0;
- }
- }
- public bool RunTests()
- {
- bool retVal = true;
- TestLibrary.TestFramework.LogInformation("[Positive]");
- retVal = PosTest1() && retVal;
- retVal = PosTest2() && retVal;
- retVal = PosTest3() && retVal;
- retVal = PosTest4() && retVal;
- retVal = PosTest5() && retVal;
- retVal = PosTest6() && retVal;
- retVal = PosTest7() && retVal;
- TestLibrary.TestFramework.LogInformation("[Negative]");
- retVal = NegTest1() && retVal;
- retVal = NegTest2() && retVal;
- retVal = NegTest3() && retVal;
- retVal = NegTest4() && retVal;
- retVal = NegTest5() && retVal;
- retVal = NegTest6() && retVal;
- retVal = NegTest7() && retVal;
- return retVal;
- }
- #region PositiveTest
- public bool PosTest1()
- {
- bool retVal = true;
- UInt32 uintA;
- TestLibrary.TestFramework.BeginScenario("PosTest1: the string corresponding UInt32 is UInt32 MaxValue 1");
- try
- {
- string strA = UInt32.MaxValue.ToString();
- NumberStyles style = NumberStyles.Any;
- uintA = UInt32.Parse(strA,style);
- if (uintA != UInt32.MaxValue)
- {
- TestLibrary.TestFramework.LogError("001", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest2()
- {
- bool retVal = true;
- UInt32 uintA;
- TestLibrary.TestFramework.BeginScenario("PosTest2: the string corresponding UInt32 is UInt32 MaxValue 2");
- try
- {
- string strA = "ffffffff";
- NumberStyles style = NumberStyles.HexNumber;
- uintA = UInt32.Parse(strA, style);
- if (uintA != UInt32.MaxValue)
- {
- TestLibrary.TestFramework.LogError("003", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest3()
- {
- bool retVal = true;
- UInt32 uintA;
- TestLibrary.TestFramework.BeginScenario("PosTest3: The string parameter contains a number of the form:[ws][sign]digits[ws] 1");
- try
- {
- string strA = "01234";
- NumberStyles style = NumberStyles.HexNumber;
- uintA = UInt32.Parse(strA, style);
- UInt32 expUIntA = (UInt32)(Math.Pow(16, 3)) + (UInt32)(2 * Math.Pow(16, 2)) + 3 * 16 + 4;
- if (uintA != expUIntA)
- {
- TestLibrary.TestFramework.LogError("005", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest4()
- {
- bool retVal = true;
- UInt32 uintA;
- TestLibrary.TestFramework.BeginScenario("PosTest4: The string parameter contains a number of the form:[ws][sign]digits[ws] 2");
- try
- {
- string strA = "01234";
- NumberStyles style = NumberStyles.Any;
- uintA = UInt32.Parse(strA,style);
- if (uintA != 1234)
- {
- TestLibrary.TestFramework.LogError("007", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("008", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest5()
- {
- bool retVal = true;
- UInt32 uintA;
- TestLibrary.TestFramework.BeginScenario("PosTest5: The string parameter contains a number of the form:[ws][sign]digits[ws] 3");
- try
- {
- int intA = this.GetInt32(0, Int32.MaxValue);
- string strA = "\u0009" + "+" + intA.ToString() + "\u000a";
- NumberStyles style = NumberStyles.Any;
- uintA = UInt32.Parse(strA, style);
- if (uintA != (UInt32)intA)
- {
- TestLibrary.TestFramework.LogError("009", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("010", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest6()
- {
- bool retVal = true;
- UInt32 uintA;
- TestLibrary.TestFramework.BeginScenario("PosTest6: The string parameter contains a number of the form:[ws]hexdigits[ws] 1");
- try
- {
- string strA = "abcde";
- NumberStyles style = NumberStyles.HexNumber;
- uintA = UInt32.Parse(strA, style);
- UInt32 expUIntA = (UInt32)(10 * Math.Pow(16, 4)) + (UInt32)(11 * Math.Pow(16, 3)) + (UInt32)(12 * Math.Pow(16, 2)) + (UInt32)(13 * Math.Pow(16, 1)) + 14;
- if (uintA != expUIntA)
- {
- TestLibrary.TestFramework.LogError("011", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("012", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest7()
- {
- bool retVal = true;
- UInt32 uintA;
- TestLibrary.TestFramework.BeginScenario("PosTest7: The string parameter contains a number of the form:[ws]hexdigits[ws] 2");
- try
- {
- string strA = "\u0009" + "abcde" + "\u000A";
- NumberStyles style = NumberStyles.HexNumber;
- uintA = UInt32.Parse(strA, style);
- UInt32 expUIntA = (UInt32)(10 * Math.Pow(16, 4)) + (UInt32)(11 * Math.Pow(16, 3)) + (UInt32)(12 * Math.Pow(16, 2)) + (UInt32)(13 * Math.Pow(16, 1)) + 14;
- if (uintA != expUIntA)
- {
- TestLibrary.TestFramework.LogError("013", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("014", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- #endregion
- #region NegativeTest
- public bool NegTest1()
- {
- bool retVal = true;
- UInt32 uintA;
- TestLibrary.TestFramework.BeginScenario("NegTest1: the parameter string is null");
-
- try
- {
- string strA = null;
- uintA = UInt32.Parse(strA, NumberStyles.Integer);
- retVal = false;
- }
- catch (ArgumentNullException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N001", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest2()
- {
- bool retVal = true;
- UInt32 uintA;
- TestLibrary.TestFramework.BeginScenario("NegTest2: the style is not the NumberStyles value");
-
- try
- {
- string strA = "12345";
- NumberStyles numstyle = (NumberStyles)(-1);
- uintA = UInt32.Parse(strA, numstyle);
- retVal = false;
- }
- catch (ArgumentException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N002", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest3()
- {
- bool retVal = true;
- UInt32 uintA;
- TestLibrary.TestFramework.BeginScenario("NegTest3: the string is not in a format compliant with style 1");
-
- try
- {
- string strA = "abcd";
- NumberStyles style = NumberStyles.Integer;
- uintA = UInt32.Parse(strA, style);
- retVal = false;
- }
- catch (FormatException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N003", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest4()
- {
- bool retVal = true;
- UInt32 uintA;
- TestLibrary.TestFramework.BeginScenario("NegTest4: the string is not in a format compliant with style 2");
-
- try
- {
- string strA = "gabcd";
- NumberStyles style = NumberStyles.HexNumber;
- uintA = UInt32.Parse(strA, style);
- retVal = false;
- }
- catch (FormatException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N003", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest5()
- {
- bool retVal = true;
- UInt32 uintA;
- TestLibrary.TestFramework.BeginScenario("NegTest5: the parameter string corresponding number is less than UInt32 minValue");
-
- try
- {
- Int32 Testint = (-1) * this.GetInt32(1, Int32.MaxValue);
- string strA = Testint.ToString();
- NumberStyles style = NumberStyles.Integer;
- uintA = UInt32.Parse(strA,style);
- retVal = false;
- }
- catch (OverflowException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N005", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest6()
- {
- bool retVal = true;
- UInt32 uintA;
- TestLibrary.TestFramework.BeginScenario("NegTest6: the parameter string corresponding number is larger than UInt32 maxValue");
-
- try
- {
- UInt32 uinta = UInt32.MaxValue;
- UInt32 uintb = (UInt32)this.GetInt32(1, Int32.MaxValue);
- UInt64 TestUint = (UInt64)uinta + (UInt64)uintb;
- string strA = TestUint.ToString();
- NumberStyles style = NumberStyles.Integer;
- uintA = UInt32.Parse(strA,style);
- retVal = false;
- }
- catch (OverflowException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N006", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest7()
- {
- bool retVal = true;
- UInt32 uintA;
- TestLibrary.TestFramework.BeginScenario("NegTest7: The string parameter contains a number of the form:[ws][sign]hexdigits[ws]");
- try
- {
- string strA = "\u0009" + "+" + "abcde" + "\u0009";
- NumberStyles style = NumberStyles.HexNumber;
- uintA = UInt32.Parse(strA, style);
- retVal = false;
- }
- catch (FormatException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N007", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- #endregion
- #region ForTestObject
- private Int32 GetInt32(Int32 minValue, Int32 maxValue)
- {
- try
- {
- if (minValue == maxValue)
- {
- return minValue;
- }
- if (minValue < maxValue)
- {
- return minValue + TestLibrary.Generator.GetInt32(-55) % (maxValue - minValue);
- }
- }
- catch
- {
- throw;
- }
-
- return minValue;
- }
- #endregion
-}
diff --git a/tests/src/CoreMangLib/cti/system/uint32/uint32parse3.cs b/tests/src/CoreMangLib/cti/system/uint32/uint32parse3.cs
deleted file mode 100644
index af0f65514b..0000000000
--- a/tests/src/CoreMangLib/cti/system/uint32/uint32parse3.cs
+++ /dev/null
@@ -1,334 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Globalization;
-
-/// <summary>
-/// UInt32.Parse(System.string,NumberStyle style,IFormatProvider provider)
-/// </summary>
-public class UInt32Parse3
-{
- public static int Main()
- {
- UInt32Parse3 ui32parse3 = new UInt32Parse3();
- TestLibrary.TestFramework.BeginTestCase("UInt32Parse3");
-
- if (ui32parse3.RunTests())
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("PASS");
- return 100;
- }
- else
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("FAIL");
- return 0;
- }
- }
- public bool RunTests()
- {
- bool retVal = true;
- TestLibrary.TestFramework.LogInformation("[Positive]");
- retVal = PosTest1() && retVal;
- retVal = PosTest2() && retVal;
- retVal = PosTest3() && retVal;
- retVal = PosTest4() && retVal;
- TestLibrary.TestFramework.LogInformation("[Negative]");
- retVal = NegTest1() && retVal;
- retVal = NegTest2() && retVal;
- retVal = NegTest3() && retVal;
- retVal = NegTest4() && retVal;
- retVal = NegTest5() && retVal;
- retVal = NegTest6() && retVal;
- retVal = NegTest7() && retVal;
- return retVal;
- }
- #region PositiveTest
- public bool PosTest1()
- {
- bool retVal = true;
- UInt32 uintA;
- CultureInfo myculture = new CultureInfo("en-us");
- IFormatProvider provider = myculture.NumberFormat;
- TestLibrary.TestFramework.BeginScenario("PosTest1: the string corresponding UInt32 is UInt32 MaxValue 1");
- try
- {
- string strA = UInt32.MaxValue.ToString();
- NumberStyles style = NumberStyles.Any;
- uintA = UInt32.Parse(strA, style,provider);
- if (uintA != UInt32.MaxValue)
- {
- TestLibrary.TestFramework.LogError("001", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest2()
- {
- bool retVal = true;
- UInt32 uintA;
- CultureInfo myculture = new CultureInfo("en-us");
- IFormatProvider provider = myculture.NumberFormat;
- TestLibrary.TestFramework.BeginScenario("PosTest2: the string corresponding UInt32 is UInt32 MaxValue 2");
- try
- {
- string strA = "ffffffff";
- NumberStyles style = NumberStyles.HexNumber;
- uintA = UInt32.Parse(strA, style,provider);
- if (uintA != UInt32.MaxValue)
- {
- TestLibrary.TestFramework.LogError("003", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest3()
- {
- bool retVal = true;
- UInt32 uintA;
- CultureInfo myculture = new CultureInfo("el-GR");
- IFormatProvider provider = myculture.NumberFormat;
- TestLibrary.TestFramework.BeginScenario("PosTest3: The string parameter contains a number of the form:[ws][sign]digits[ws]");
- try
- {
- string strA = "\u0009" + "abcde" + "\u000A";
- NumberStyles style = NumberStyles.HexNumber;
- uintA = UInt32.Parse(strA, style, provider);
- UInt32 expUIntA = (UInt32)(10 * Math.Pow(16, 4)) + (UInt32)(11 * Math.Pow(16, 3)) + (UInt32)(12 * Math.Pow(16, 2)) + (UInt32)(13 * Math.Pow(16, 1)) + 14;
- if (uintA != expUIntA)
- {
- TestLibrary.TestFramework.LogError("005", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest4()
- {
- bool retVal = true;
- UInt32 uintA;
- CultureInfo myculture = new CultureInfo("el-GR");
- IFormatProvider provider = myculture.NumberFormat;
- TestLibrary.TestFramework.BeginScenario("PosTest4: The string parameter contains a number of the form:[ws]hexdigits[ws]");
- try
- {
- string strA = "fffff";
- NumberStyles style = NumberStyles.HexNumber;
- uintA = UInt32.Parse(strA, style, provider);
- UInt32 expUIntA = (UInt32)(15 * Math.Pow(16, 4)) + (UInt32)(15 * Math.Pow(16, 3)) + (UInt32)(15 * Math.Pow(16, 2)) + (UInt32)(15 * Math.Pow(16, 1)) + 15;
- if (uintA != expUIntA)
- {
- TestLibrary.TestFramework.LogError("007", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("008", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- #endregion
- #region NegativeTest
- public bool NegTest1()
- {
- bool retVal = true;
- UInt32 uintA;
- IFormatProvider provider = null;
- TestLibrary.TestFramework.BeginScenario("NegTest1: the parameter string is null");
-
- try
- {
- string strA = null;
- uintA = UInt32.Parse(strA, NumberStyles.Integer,provider);
- retVal = false;
- }
- catch (ArgumentNullException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N001", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest2()
- {
- bool retVal = true;
- UInt32 uintA;
- IFormatProvider provider = null;
- TestLibrary.TestFramework.BeginScenario("NegTest2: the style is not the NumberStyles value");
-
- try
- {
- string strA = "12345";
- NumberStyles numstyle = (NumberStyles)(-1);
- uintA = UInt32.Parse(strA, numstyle, provider);
- retVal = false;
- }
- catch (ArgumentException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N002", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest3()
- {
- bool retVal = true;
- UInt32 uintA;
- IFormatProvider provider = null;
- TestLibrary.TestFramework.BeginScenario("NegTest3: the string is not in a format compliant with style 1");
-
- try
- {
- string strA = "abcd";
- NumberStyles style = NumberStyles.Integer;
- uintA = UInt32.Parse(strA, style, provider);
- retVal = false;
- }
- catch (FormatException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N003", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest4()
- {
- bool retVal = true;
- UInt32 uintA;
- IFormatProvider provider = null;
- TestLibrary.TestFramework.BeginScenario("NegTest4: the string is not in a format compliant with style 2");
-
- try
- {
- string strA = "gabcd";
- NumberStyles style = NumberStyles.HexNumber;
- uintA = UInt32.Parse(strA, style, provider);
- retVal = false;
- }
- catch (FormatException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N003", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest5()
- {
- bool retVal = true;
- UInt32 uintA;
- IFormatProvider provider = null;
- TestLibrary.TestFramework.BeginScenario("NegTest5: the parameter string corresponding number is less than UInt32 minValue");
-
- try
- {
- Int32 Testint = (-1) * this.GetInt32(1, Int32.MaxValue);
- string strA = Testint.ToString();
- NumberStyles style = NumberStyles.Integer;
- uintA = UInt32.Parse(strA, style, provider);
- retVal = false;
- }
- catch (OverflowException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N005", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest6()
- {
- bool retVal = true;
- UInt32 uintA;
- IFormatProvider provider = null;
- TestLibrary.TestFramework.BeginScenario("NegTest6: the parameter string corresponding number is larger than UInt32 maxValue");
-
- try
- {
- UInt32 uinta = UInt32.MaxValue;
- UInt32 uintb = (UInt32)this.GetInt32(1, Int32.MaxValue);
- UInt64 TestUint = (UInt64)uinta + (UInt64)uintb;
- string strA = TestUint.ToString();
- NumberStyles style = NumberStyles.Integer;
- uintA = UInt32.Parse(strA, style, provider);
- retVal = false;
- }
- catch (OverflowException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N006", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest7()
- {
- bool retVal = true;
- UInt32 uintA;
- IFormatProvider provider = null;
- TestLibrary.TestFramework.BeginScenario("NegTest7: The string parameter contains a number of the form:[ws][sign]hexdigits[ws]");
- try
- {
- string strA = "\u0009" + "+" + "abcde" + "\u0009";
- NumberStyles style = NumberStyles.HexNumber;
- uintA = UInt32.Parse(strA, style, provider);
- retVal = false;
- }
- catch (FormatException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N007", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- #endregion
- #region ForTestObject
- private Int32 GetInt32(Int32 minValue, Int32 maxValue)
- {
- try
- {
- if (minValue == maxValue)
- {
- return minValue;
- }
- if (minValue < maxValue)
- {
- return minValue + TestLibrary.Generator.GetInt32(-55) % (maxValue - minValue);
- }
- }
- catch
- {
- throw;
- }
-
- return minValue;
- }
- #endregion
-}
diff --git a/tests/src/CoreMangLib/cti/system/uint32/uint32tryparse.cs b/tests/src/CoreMangLib/cti/system/uint32/uint32tryparse.cs
deleted file mode 100644
index 8e9bf6535c..0000000000
--- a/tests/src/CoreMangLib/cti/system/uint32/uint32tryparse.cs
+++ /dev/null
@@ -1,556 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Globalization;
-
-// CoreCLR Port from Co7528TryParse_all.cs
-// Tests UInt32.TryParse(String), UInt32.TryParse(String, NumberStyles, IFormatProvider, ref UInt32)
-// 2003/04/01 KatyK
-// 2007/06/28 adapted by MarielY
-
-public class Co7528TryParse
-{
- static bool verbose = false;
-
- public static int Main()
- {
- bool passed = true;
-
- try
- {
- // Make the test culture independent
- TestLibrary.Utilities.CurrentCulture = CultureInfo.InvariantCulture;
-
- // Set up NFIs to use
- NumberFormatInfo goodNFI = new NumberFormatInfo();
-
- NumberFormatInfo corruptNFI = new NumberFormatInfo(); // DecimalSeparator == GroupSeparator
- corruptNFI.NumberDecimalSeparator = ".";
- corruptNFI.NumberGroupSeparator = ".";
- corruptNFI.CurrencyDecimalSeparator = ".";
- corruptNFI.CurrencyGroupSeparator = ".";
- corruptNFI.CurrencySymbol = "$";
-
- NumberFormatInfo swappedNFI = new NumberFormatInfo(); // DecimalSeparator & GroupSeparator swapped
- swappedNFI.NumberDecimalSeparator = ".";
- swappedNFI.NumberGroupSeparator = ",";
- swappedNFI.CurrencyDecimalSeparator = ",";
- swappedNFI.CurrencyGroupSeparator = ".";
- swappedNFI.CurrencySymbol = "$";
-
- NumberFormatInfo distinctNFI = new NumberFormatInfo(); // DecimalSeparator & GroupSeparator distinct
- distinctNFI.NumberDecimalSeparator = ".";
- distinctNFI.NumberGroupSeparator = ",";
- distinctNFI.CurrencyDecimalSeparator = ":";
- distinctNFI.CurrencyGroupSeparator = ";";
- distinctNFI.CurrencySymbol = "$";
-
- NumberFormatInfo customNFI = new NumberFormatInfo();
- customNFI.NegativeSign = "^";
-
- NumberFormatInfo ambigNFI = new NumberFormatInfo();
- ambigNFI.NegativeSign = "^";
- ambigNFI.CurrencySymbol = "^";
-
- CultureInfo germanCulture = new CultureInfo("de-DE");
- CultureInfo japaneseCulture;
-
- try
- {
- japaneseCulture = new CultureInfo("ja-JP");
- }
- catch (Exception)
- {
- TestLibrary.Logging.WriteLine("East Asian Languages are not installed. Skiping Japanese culture tests.");
- japaneseCulture = null;
- }
-
- // Parse tests included for comparison/regression
- passed &= VerifyUInt32Parse("5", 5);
- passed &= VerifyUInt32Parse("5 ", 5);
- passed &= VerifyUInt32Parse("5\0", 5);
- passed &= VerifyUInt32Parse("893382737", 893382737);
- passed &= VerifyUInt32Parse("1234567891", 1234567891);
- passed &= VerifyUInt32Parse("3123456789", 3123456789u);
- passed &= VerifyUInt32Parse("5", NumberStyles.Integer, CultureInfo.InvariantCulture, 5);
- passed &= VerifyUInt32Parse("5 \0", NumberStyles.Integer, CultureInfo.InvariantCulture, 5);
- passed &= VerifyUInt32Parse("5\0\0\0", NumberStyles.Integer, CultureInfo.InvariantCulture, 5);
- passed &= VerifyUInt32Parse("12", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0x12);
- passed &= VerifyUInt32Parse("fF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0xFF);
- passed &= VerifyUInt32Parse("5", NumberStyles.Integer, goodNFI, 5);
- passed &= VerifyUInt32Parse("5.0", NumberStyles.AllowDecimalPoint, goodNFI, 5);
- passed &= VerifyUInt32Parse("123", NumberStyles.Integer, germanCulture, 123);
- passed &= VerifyUInt32Parse("123", NumberStyles.Integer, japaneseCulture, 123);
- passed &= VerifyUInt32Parse("123.000", NumberStyles.Any, germanCulture, 123000);
- passed &= VerifyUInt32Parse("123,000", NumberStyles.Any, japaneseCulture, 123000);
- passed &= VerifyUInt32Parse("123,000", NumberStyles.AllowDecimalPoint, germanCulture, 123);
- passed &= VerifyUInt32Parse("123.000", NumberStyles.AllowDecimalPoint, japaneseCulture, 123);
- passed &= VerifyUInt32Parse("5,00 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Any, germanCulture, 5); // currency
- //
- passed &= VerifyUInt32Parse("5", NumberStyles.Integer, corruptNFI, 5);
- passed &= VerifyUInt32Parse("5", NumberStyles.Number, corruptNFI, 5);
- passed &= VerifyUInt32Parse("5.0", NumberStyles.Number, corruptNFI, 5);
- passed &= VerifyUInt32ParseException("5,0", NumberStyles.Number, corruptNFI, typeof(FormatException));
- passed &= VerifyUInt32ParseException("5.0.0", NumberStyles.Number, corruptNFI, typeof(FormatException));
- passed &= VerifyUInt32Parse("$5.0", NumberStyles.Currency, corruptNFI, 5);
- passed &= VerifyUInt32ParseException("$5,0", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyUInt32ParseException("$5.0.0", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyUInt32Parse("5.0", NumberStyles.Currency, corruptNFI, 5);
- passed &= VerifyUInt32ParseException("5,0", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyUInt32ParseException("5.0.0", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyUInt32Parse("5.0", NumberStyles.Any, corruptNFI, 5);
- passed &= VerifyUInt32ParseException("5,0", NumberStyles.Any, corruptNFI, typeof(FormatException));
- passed &= VerifyUInt32ParseException("5.0.0", NumberStyles.Any, corruptNFI, typeof(FormatException));
- //
- passed &= VerifyUInt32Parse("5", NumberStyles.Integer, swappedNFI, 5);
- passed &= VerifyUInt32ParseException("1,234", NumberStyles.Integer, swappedNFI, typeof(FormatException));
- passed &= VerifyUInt32Parse("5", NumberStyles.Number, swappedNFI, 5);
- passed &= VerifyUInt32Parse("5.0", NumberStyles.Number, swappedNFI, 5);
- passed &= VerifyUInt32Parse("1,234", NumberStyles.Number, swappedNFI, 1234);
- passed &= VerifyUInt32Parse("1,234.0", NumberStyles.Number, swappedNFI, 1234);
- passed &= VerifyUInt32ParseException("5.000.000", NumberStyles.Number, swappedNFI, typeof(FormatException));
- passed &= VerifyUInt32ParseException("5.000,00", NumberStyles.Number, swappedNFI, typeof(FormatException));
- passed &= VerifyUInt32Parse("5.000", NumberStyles.Currency, swappedNFI, 5); //???
- passed &= VerifyUInt32ParseException("5.000,00", NumberStyles.Currency, swappedNFI, typeof(FormatException)); //???
- passed &= VerifyUInt32Parse("$5.000", NumberStyles.Currency, swappedNFI, 5000);
- passed &= VerifyUInt32Parse("$5.000,00", NumberStyles.Currency, swappedNFI, 5000);
- passed &= VerifyUInt32Parse("5.000", NumberStyles.Any, swappedNFI, 5); //?
- passed &= VerifyUInt32ParseException("5.000,00", NumberStyles.Any, swappedNFI, typeof(FormatException)); //?
- passed &= VerifyUInt32Parse("$5.000", NumberStyles.Any, swappedNFI, 5000);
- passed &= VerifyUInt32Parse("$5.000,00", NumberStyles.Any, swappedNFI, 5000);
- passed &= VerifyUInt32Parse("5,0", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyUInt32Parse("$5,0", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyUInt32Parse("5,000", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyUInt32Parse("$5,000", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyUInt32ParseException("5,000.0", NumberStyles.Currency, swappedNFI, typeof(FormatException));
- passed &= VerifyUInt32ParseException("$5,000.0", NumberStyles.Currency, swappedNFI, typeof(FormatException));
- passed &= VerifyUInt32Parse("5,000", NumberStyles.Any, swappedNFI, 5);
- passed &= VerifyUInt32Parse("$5,000", NumberStyles.Any, swappedNFI, 5);
- passed &= VerifyUInt32ParseException("5,000.0", NumberStyles.Any, swappedNFI, typeof(FormatException));
- passed &= VerifyUInt32ParseException("$5,000.0", NumberStyles.Any, swappedNFI, typeof(FormatException));
- //
- passed &= VerifyUInt32Parse("5.0", NumberStyles.Number, distinctNFI, 5);
- passed &= VerifyUInt32Parse("1,234.0", NumberStyles.Number, distinctNFI, 1234);
- passed &= VerifyUInt32Parse("5.0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyUInt32Parse("1,234.0", NumberStyles.Currency, distinctNFI, 1234);
- passed &= VerifyUInt32Parse("5.0", NumberStyles.Any, distinctNFI, 5);
- passed &= VerifyUInt32Parse("1,234.0", NumberStyles.Any, distinctNFI, 1234);
- passed &= VerifyUInt32ParseException("$5.0", NumberStyles.Currency, distinctNFI, typeof(FormatException));
- passed &= VerifyUInt32ParseException("$5.0", NumberStyles.Any, distinctNFI, typeof(FormatException));
- passed &= VerifyUInt32ParseException("5:0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyUInt32ParseException("5;0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyUInt32ParseException("$5:0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyUInt32Parse("5:0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyUInt32Parse("5:000", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyUInt32Parse("5;000", NumberStyles.Currency, distinctNFI, 5000);
- passed &= VerifyUInt32Parse("$5:0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyUInt32Parse("$5;0", NumberStyles.Currency, distinctNFI, 50);
- passed &= VerifyUInt32Parse("5:0", NumberStyles.Any, distinctNFI, 5);
- passed &= VerifyUInt32Parse("5;0", NumberStyles.Any, distinctNFI, 50);
- passed &= VerifyUInt32Parse("$5:0", NumberStyles.Any, distinctNFI, 5);
- passed &= VerifyUInt32Parse("$5;0", NumberStyles.Any, distinctNFI, 50);
- passed &= VerifyUInt32ParseException("123,456;789.0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyUInt32Parse("123,456;789.0", NumberStyles.Currency, distinctNFI, 123456789);
- passed &= VerifyUInt32Parse("123,456;789.0", NumberStyles.Any, distinctNFI, 123456789);
- passed &= VerifyUInt32ParseException("$123,456;789.0", NumberStyles.Any, distinctNFI, typeof(FormatException));
- //
- passed &= VerifyUInt32ParseException("12345678912", typeof(OverflowException));
- passed &= VerifyUInt32ParseException("5.3", NumberStyles.AllowDecimalPoint, goodNFI, typeof(OverflowException)); //weird that it's Overflow, but consistent with v1
- passed &= VerifyUInt32ParseException("Garbage", typeof(FormatException));
- passed &= VerifyUInt32ParseException("5\0Garbage", typeof(FormatException));
- passed &= VerifyUInt32ParseException(null, typeof(ArgumentNullException));
- passed &= VerifyUInt32ParseException("893382737", NumberStyles.HexNumber, CultureInfo.InvariantCulture, typeof(OverflowException));
- passed &= VerifyUInt32ParseException("5", NumberStyles.AllowHexSpecifier | NumberStyles.AllowParentheses, null, typeof(ArgumentException));
- passed &= VerifyUInt32ParseException("4", (NumberStyles)(-1), typeof(ArgumentException));
- passed &= VerifyUInt32ParseException("4", (NumberStyles)0x10000, typeof(ArgumentException));
- passed &= VerifyUInt32ParseException("4", (NumberStyles)(-1), CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifyUInt32ParseException("4", (NumberStyles)0x10000, CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifyUInt32ParseException("123.000.000.000", NumberStyles.Any, germanCulture, typeof(OverflowException));
- passed &= VerifyUInt32ParseException("123,000,000,000", NumberStyles.Any, japaneseCulture, typeof(OverflowException));
- passed &= VerifyUInt32ParseException("123,000,000,000", NumberStyles.Integer, germanCulture, typeof(FormatException));
- passed &= VerifyUInt32ParseException("123.000.000.000", NumberStyles.Integer, japaneseCulture, typeof(FormatException));
- passed &= VerifyUInt32ParseException("5,00 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Integer, germanCulture, typeof(FormatException)); // currency
-
- /////////// TryParse(String)
- //// Pass cases
- passed &= VerifyUInt32TryParse("5", 5, true);
- passed &= VerifyUInt32TryParse(" 5 ", 5, true);
- passed &= VerifyUInt32TryParse("5\0", 5, true);
- passed &= VerifyUInt32TryParse("5 \0", 5, true);
- passed &= VerifyUInt32TryParse("5\0\0\0", 5, true);
- passed &= VerifyUInt32TryParse("10000", 10000, true);
- passed &= VerifyUInt32TryParse("893382737", 893382737, true);
- passed &= VerifyUInt32TryParse("1234567891", 1234567891, true);
- passed &= VerifyUInt32TryParse("3123456789", 3123456789u, true);
- passed &= VerifyUInt32TryParse(UInt32.MaxValue.ToString(), UInt32.MaxValue, true);
- passed &= VerifyUInt32TryParse(UInt32.MinValue.ToString(), UInt32.MinValue, true);
-
- //// Fail cases
- passed &= VerifyUInt32TryParse(null, 0, false);
- passed &= VerifyUInt32TryParse("", 0, false);
- passed &= VerifyUInt32TryParse("Garbage", 0, false);
- passed &= VerifyUInt32TryParse("5\0Garbage", 0, false);
- passed &= VerifyUInt32TryParse("-5", 0, false);
- passed &= VerifyUInt32TryParse("12345678912", 0, false);
- passed &= VerifyUInt32TryParse("FF", 0, false);
- passed &= VerifyUInt32TryParse("27.3", 0, false);
- passed &= VerifyUInt32TryParse("23 5", 0, false);
-
-
- /////////// TryParse(TryParse(String, NumberStyles, IFormatProvider, ref UInt32)
- //// Pass cases
- passed &= VerifyUInt32TryParse("5", NumberStyles.Integer, CultureInfo.InvariantCulture, 5, true);
- // Variations on NumberStyles
- passed &= VerifyUInt32TryParse("12", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0x12, true);
- passed &= VerifyUInt32TryParse("FF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0xFF, true);
- passed &= VerifyUInt32TryParse("fF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0xFF, true);
- passed &= VerifyUInt32TryParse("fFFFFFFF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0xFFFFFFFF, true);
- passed &= VerifyUInt32TryParse(" 5", NumberStyles.AllowLeadingWhite, goodNFI, 5, true);
- passed &= VerifyUInt32TryParse("5", NumberStyles.Number, goodNFI, 5, true);
- passed &= VerifyUInt32TryParse("5.0", NumberStyles.AllowDecimalPoint, goodNFI, 5, true);
- // Variations on IFP
- passed &= VerifyUInt32TryParse("5", NumberStyles.Integer, goodNFI, 5, true);
- passed &= VerifyUInt32TryParse("5", NumberStyles.Integer, null, 5, true);
- passed &= VerifyUInt32TryParse("5", NumberStyles.Integer, new DateTimeFormatInfo(), 5, true);
- passed &= VerifyUInt32TryParse("123", NumberStyles.Integer, germanCulture, 123, true);
- passed &= VerifyUInt32TryParse("123", NumberStyles.Integer, japaneseCulture, 123, true);
- passed &= VerifyUInt32TryParse("123.000", NumberStyles.Any, germanCulture, 123000, true);
- passed &= VerifyUInt32TryParse("123,000", NumberStyles.Any, japaneseCulture, 123000, true);
- passed &= VerifyUInt32TryParse("123,000", NumberStyles.AllowDecimalPoint, germanCulture, 123, true);
- passed &= VerifyUInt32TryParse("123.000", NumberStyles.AllowDecimalPoint, japaneseCulture, 123, true);
- passed &= VerifyUInt32TryParse("5,00 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Any, germanCulture, 5, true); // currency
-
- //// Fail cases
- passed &= VerifyUInt32TryParse("-5", NumberStyles.Integer, CultureInfo.InvariantCulture, 0, false);
- passed &= VerifyUInt32TryParse("FF", NumberStyles.Integer, CultureInfo.InvariantCulture, 0, false);
- passed &= VerifyUInt32TryParse("893382737", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0, false);
- passed &= VerifyUInt32TryParse("^42", NumberStyles.Any, customNFI, 0, false);
- passed &= VerifyUInt32TryParse("-42", NumberStyles.Any, customNFI, 0, false);
- passed &= VerifyUInt32TryParse("5.3", NumberStyles.AllowDecimalPoint, goodNFI, 0, false);
- passed &= VerifyUInt32TryParse("5 ", NumberStyles.AllowLeadingWhite, goodNFI, 0, false);
- passed &= VerifyUInt32TryParse("123.000.000.000", NumberStyles.Any, germanCulture, 0, false);
- passed &= VerifyUInt32TryParse("123,000,000,000", NumberStyles.Any, japaneseCulture, 0, false);
- passed &= VerifyUInt32TryParse("123,000,000,000", NumberStyles.Integer, germanCulture, 0, false);
- passed &= VerifyUInt32TryParse("123.000.000.000", NumberStyles.Integer, japaneseCulture, 0, false);
- passed &= VerifyUInt32TryParse("5,00 \u20AC", NumberStyles.Integer, germanCulture, 0, false); // currency
-
- //// Exception cases
- passed &= VerifyUInt32TryParseException("5", NumberStyles.AllowHexSpecifier | NumberStyles.AllowParentheses, null, typeof(ArgumentException));
- passed &= VerifyUInt32TryParseException("4", (NumberStyles)(-1), CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifyUInt32TryParseException("4", (NumberStyles)0x10000, CultureInfo.InvariantCulture, typeof(ArgumentException));
-
- // NumberStyles/NFI variations
- //
- passed &= VerifyUInt32TryParse("5", NumberStyles.Integer, corruptNFI, 5, true);
- passed &= VerifyUInt32TryParse("5", NumberStyles.Number, corruptNFI, 5, true);
- passed &= VerifyUInt32TryParse("5.0", NumberStyles.Number, corruptNFI, 5, true);
- passed &= VerifyUInt32TryParse("5,0", NumberStyles.Number, corruptNFI, 0, false);
- passed &= VerifyUInt32TryParse("5.0.0", NumberStyles.Number, corruptNFI, 0, false);
- passed &= VerifyUInt32TryParse("$5.0", NumberStyles.Currency, corruptNFI, 5, true);
- passed &= VerifyUInt32TryParse("$5,0", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyUInt32TryParse("$5.0.0", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyUInt32TryParse("5.0", NumberStyles.Currency, corruptNFI, 5, true);
- passed &= VerifyUInt32TryParse("5,0", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyUInt32TryParse("5.0.0", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyUInt32TryParse("5.0", NumberStyles.Any, corruptNFI, 5, true);
- passed &= VerifyUInt32TryParse("5,0", NumberStyles.Any, corruptNFI, 0, false);
- passed &= VerifyUInt32TryParse("5.0.0", NumberStyles.Any, corruptNFI, 0, false);
- //
- passed &= VerifyUInt32TryParse("5", NumberStyles.Integer, swappedNFI, 5, true);
- passed &= VerifyUInt32TryParse("1,234", NumberStyles.Integer, swappedNFI, 0, false);
- passed &= VerifyUInt32TryParse("5", NumberStyles.Number, swappedNFI, 5, true);
- passed &= VerifyUInt32TryParse("5.0", NumberStyles.Number, swappedNFI, 5, true);
- passed &= VerifyUInt32TryParse("1,234", NumberStyles.Number, swappedNFI, 1234, true);
- passed &= VerifyUInt32TryParse("1,234.0", NumberStyles.Number, swappedNFI, 1234, true);
- passed &= VerifyUInt32TryParse("5.000.000", NumberStyles.Number, swappedNFI, 0, false);
- passed &= VerifyUInt32TryParse("5.000,00", NumberStyles.Number, swappedNFI, 0, false);
- passed &= VerifyUInt32TryParse("5.000", NumberStyles.Currency, swappedNFI, 5, true); //???
- passed &= VerifyUInt32TryParse("5.000,00", NumberStyles.Currency, swappedNFI, 0, false); //???
- passed &= VerifyUInt32TryParse("$5.000", NumberStyles.Currency, swappedNFI, 5000, true);
- passed &= VerifyUInt32TryParse("$5.000,00", NumberStyles.Currency, swappedNFI, 5000, true);
- passed &= VerifyUInt32TryParse("5.000", NumberStyles.Any, swappedNFI, 5, true); //?
- passed &= VerifyUInt32TryParse("5.000,00", NumberStyles.Any, swappedNFI, 0, false); //?
- passed &= VerifyUInt32TryParse("$5.000", NumberStyles.Any, swappedNFI, 5000, true);
- passed &= VerifyUInt32TryParse("$5.000,00", NumberStyles.Any, swappedNFI, 5000, true);
- passed &= VerifyUInt32TryParse("5,0", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyUInt32TryParse("$5,0", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyUInt32TryParse("5,000", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyUInt32TryParse("$5,000", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyUInt32TryParse("5,000.0", NumberStyles.Currency, swappedNFI, 0, false);
- passed &= VerifyUInt32TryParse("$5,000.0", NumberStyles.Currency, swappedNFI, 0, false);
- passed &= VerifyUInt32TryParse("5,000", NumberStyles.Any, swappedNFI, 5, true);
- passed &= VerifyUInt32TryParse("$5,000", NumberStyles.Any, swappedNFI, 5, true);
- passed &= VerifyUInt32TryParse("5,000.0", NumberStyles.Any, swappedNFI, 0, false);
- passed &= VerifyUInt32TryParse("$5,000.0", NumberStyles.Any, swappedNFI, 0, false);
- //
- passed &= VerifyUInt32TryParse("5.0", NumberStyles.Number, distinctNFI, 5, true);
- passed &= VerifyUInt32TryParse("1,234.0", NumberStyles.Number, distinctNFI, 1234, true);
- passed &= VerifyUInt32TryParse("5.0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyUInt32TryParse("1,234.0", NumberStyles.Currency, distinctNFI, 1234, true);
- passed &= VerifyUInt32TryParse("5.0", NumberStyles.Any, distinctNFI, 5, true);
- passed &= VerifyUInt32TryParse("1,234.0", NumberStyles.Any, distinctNFI, 1234, true);
- passed &= VerifyUInt32TryParse("$5.0", NumberStyles.Currency, distinctNFI, 0, false);
- passed &= VerifyUInt32TryParse("$5.0", NumberStyles.Any, distinctNFI, 0, false);
- passed &= VerifyUInt32TryParse("5:0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyUInt32TryParse("5;0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyUInt32TryParse("$5:0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyUInt32TryParse("5:0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyUInt32TryParse("5:000", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyUInt32TryParse("5;000", NumberStyles.Currency, distinctNFI, 5000, true);
- passed &= VerifyUInt32TryParse("$5:0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyUInt32TryParse("$5;0", NumberStyles.Currency, distinctNFI, 50, true);
- passed &= VerifyUInt32TryParse("5:0", NumberStyles.Any, distinctNFI, 5, true);
- passed &= VerifyUInt32TryParse("5;0", NumberStyles.Any, distinctNFI, 50, true);
- passed &= VerifyUInt32TryParse("$5:0", NumberStyles.Any, distinctNFI, 5, true);
- passed &= VerifyUInt32TryParse("$5;0", NumberStyles.Any, distinctNFI, 50, true);
- passed &= VerifyUInt32TryParse("123,456;789.0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyUInt32TryParse("123,456;789.0", NumberStyles.Currency, distinctNFI, 123456789, true);
- passed &= VerifyUInt32TryParse("123,456;789.0", NumberStyles.Any, distinctNFI, 123456789, true);
- passed &= VerifyUInt32TryParse("$123,456;789.0", NumberStyles.Any, distinctNFI, 0, false);
-
-
- // Should these pass or fail? Current parse behavior is to pass, so they might be
- // parse bugs, but they're not tryparse bugs.
- passed &= VerifyUInt32Parse("5", NumberStyles.Float, goodNFI, 5);
- passed &= VerifyUInt32TryParse("5", NumberStyles.Float, goodNFI, 5, true);
- passed &= VerifyUInt32Parse("5", NumberStyles.AllowDecimalPoint, goodNFI, 5);
- passed &= VerifyUInt32TryParse("5", NumberStyles.AllowDecimalPoint, goodNFI, 5, true);
- // I expect ArgumentException with an ambiguous NFI
- passed &= VerifyUInt32ParseException("^42", NumberStyles.Any, ambigNFI, typeof(OverflowException));
- passed &= VerifyUInt32TryParse("^42", NumberStyles.Any, ambigNFI, 0, false);
-
- /// END TEST CASES
- }
- catch (Exception e)
- {
- TestLibrary.Logging.WriteLine("Unexpected exception!! " + e.ToString());
- passed = false;
- }
-
- if (passed)
- {
- TestLibrary.Logging.WriteLine("paSs");
- return 100;
- }
- else
- {
- TestLibrary.Logging.WriteLine("FAiL");
- return 1;
- }
- }
-
- public static bool VerifyUInt32TryParse(string value, UInt32 expectedResult, bool expectedReturn)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: UInt32.TryParse, Value = '{0}', Expected Result = {1}, Expected Return = {2}",
- value, expectedResult, expectedReturn);
- }
- UInt32 result = 0;
- try
- {
- bool returnValue = UInt32.TryParse(value, out result);
- if (returnValue != expectedReturn)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedReturn, returnValue);
- return false;
- }
- if (result != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, result);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyUInt32TryParse(string value, NumberStyles style, IFormatProvider provider, UInt32 expectedResult, bool expectedReturn)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: UInt32.TryParse, Value = '{0}', Style = {1}, Provider = {2}, Expected Result = {3}, Expected Return = {4}",
- value, style, provider, expectedResult, expectedReturn);
- }
- UInt32 result = 0;
- try
- {
- bool returnValue = UInt32.TryParse(value, style, provider, out result);
- if (returnValue != expectedReturn)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Style = {1}, Provider = {2}, Expected Return = {3}, Actual Return = {4}",
- value, style, provider, expectedReturn, returnValue);
- return false;
- }
- if (result != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, result);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyUInt32TryParseException(string value, NumberStyles style, IFormatProvider provider, Type exceptionType)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: UInt32.TryParse, Value = '{0}', Style = {1}, Provider = {2}, Expected Exception = {3}",
- value, style, provider, exceptionType);
- }
- try
- {
- UInt32 result = 0;
- Boolean returnValue = UInt32.TryParse(value, style, provider, out result);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifyUInt32Parse(string value, UInt32 expectedResult)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: UInt32.Parse, Value = '{0}', Expected Result, {1}",
- value, expectedResult);
- }
- try
- {
- UInt32 returnValue = UInt32.Parse(value);
- if (returnValue != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, returnValue);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyUInt32Parse(string value, NumberStyles style, IFormatProvider provider, UInt32 expectedResult)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: UInt32.Parse, Value = '{0}', Style = {1}, provider = {2}, Expected Result = {3}",
- value, style, provider, expectedResult);
- }
- try
- {
- UInt32 returnValue = UInt32.Parse(value, style, provider);
- if (returnValue != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, returnValue);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyUInt32ParseException(string value, Type exceptionType)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: UInt32.Parse, Value = '{0}', Expected Exception, {1}",
- value, exceptionType);
- }
- try
- {
- UInt32 returnValue = UInt32.Parse(value);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifyUInt32ParseException(string value, NumberStyles style, Type exceptionType)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: UInt32.Parse, Value = '{0}', Style = {1}, Expected Exception = {3}",
- value, style, exceptionType);
- }
- try
- {
- UInt32 returnValue = UInt32.Parse(value, style);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifyUInt32ParseException(string value, NumberStyles style, IFormatProvider provider, Type exceptionType)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: UInt32.Parse, Value = '{0}', Style = {1}, Provider = {2}, Expected Exception = {3}",
- value, style, provider, exceptionType);
- }
- try
- {
- UInt32 returnValue = UInt32.Parse(value, style, provider);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-}
diff --git a/tests/src/CoreMangLib/cti/system/uint64/UInt64Parse1.csproj b/tests/src/CoreMangLib/cti/system/uint64/UInt64Parse1.csproj
deleted file mode 100644
index 1db2a88dba..0000000000
--- a/tests/src/CoreMangLib/cti/system/uint64/UInt64Parse1.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="uint64parse1.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/uint64/UInt64Parse2.csproj b/tests/src/CoreMangLib/cti/system/uint64/UInt64Parse2.csproj
deleted file mode 100644
index 09486583fe..0000000000
--- a/tests/src/CoreMangLib/cti/system/uint64/UInt64Parse2.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="uint64parse2.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/uint64/UInt64Parse3.csproj b/tests/src/CoreMangLib/cti/system/uint64/UInt64Parse3.csproj
deleted file mode 100644
index 9d6f0bf56d..0000000000
--- a/tests/src/CoreMangLib/cti/system/uint64/UInt64Parse3.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="uint64parse3.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/uint64/UInt64TryParse.csproj b/tests/src/CoreMangLib/cti/system/uint64/UInt64TryParse.csproj
deleted file mode 100644
index 6986a650d0..0000000000
--- a/tests/src/CoreMangLib/cti/system/uint64/UInt64TryParse.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="uint64tryparse.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/CoreMangLib/cti/system/uint64/uint64parse1.cs b/tests/src/CoreMangLib/cti/system/uint64/uint64parse1.cs
deleted file mode 100644
index ea0541c63d..0000000000
--- a/tests/src/CoreMangLib/cti/system/uint64/uint64parse1.cs
+++ /dev/null
@@ -1,354 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Globalization;
-
-/// <summary>
-/// UInt64.Parse(System.string)
-/// </summary>
-public class UInt64Parse1
-{
- public static int Main()
- {
- UInt64Parse1 ui64parse1 = new UInt64Parse1();
- TestLibrary.TestFramework.BeginTestCase("UInt64Parse1");
-
- if (ui64parse1.RunTests())
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("PASS");
- return 100;
- }
- else
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("FAIL");
- return 0;
- }
- }
- public bool RunTests()
- {
- bool retVal = true;
- TestLibrary.TestFramework.LogInformation("[Positive]");
- retVal = PosTest1() && retVal;
- retVal = PosTest2() && retVal;
- retVal = PosTest3() && retVal;
- retVal = PosTest4() && retVal;
- retVal = PosTest5() && retVal;
- retVal = PosTest6() && retVal;
- retVal = PosTest7() && retVal;
-
- TestLibrary.TestFramework.LogInformation("[Negative]");
- retVal = NegTest1() && retVal;
- retVal = NegTest2() && retVal;
- retVal = NegTest3() && retVal;
- retVal = NegTest4() && retVal;
- retVal = NegTest5() && retVal;
-
- return retVal;
- }
- #region PostiveTest
- public bool PosTest1()
- {
- bool retVal = true;
- UInt64 uintA;
-
- TestLibrary.TestFramework.BeginScenario("PosTest1: the string corresponding UInt64 is UInt64 MinValue ");
-
- try
- {
- string strA = UInt64.MinValue.ToString();
- uintA = UInt64.Parse(strA);
- if (uintA != 0)
- {
- TestLibrary.TestFramework.LogError("001", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest2()
- {
- bool retVal = true;
- UInt64 uintA;
-
- TestLibrary.TestFramework.BeginScenario("PosTest2: the string corresponding UInt64 is UInt64 MaxValue ");
-
- try
- {
- string strA = UInt64.MaxValue.ToString();
- uintA = UInt64.Parse(strA);
- if (uintA != UInt64.MaxValue)
- {
- TestLibrary.TestFramework.LogError("003", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest3()
- {
- bool retVal = true;
- UInt64 uintA;
-
- TestLibrary.TestFramework.BeginScenario("PosTest3: the string corresponding UInt64 is normal UInt64 ");
-
- try
- {
- UInt64 uintTest = (UInt64)this.GetInt64(0, UInt64.MaxValue);
- string strA = uintTest.ToString();
- uintA = UInt64.Parse(strA);
- if (uintA != uintTest)
- {
- TestLibrary.TestFramework.LogError("005", "the ActualResult is not the ExpectResult,The UInt64 is:" + uintTest);
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest4()
- {
- bool retVal = true;
- UInt64 uintA;
-
- TestLibrary.TestFramework.BeginScenario("PosTest4: the string format is [ws][sign]digits[ws] 1");
-
- try
- {
- UInt64 uintTest = (UInt64)this.GetInt64(0, UInt64.MaxValue);
- string strA = "+" + uintTest.ToString();
- uintA = UInt64.Parse(strA);
- if (uintA != uintTest)
- {
- TestLibrary.TestFramework.LogError("007", "the ActualResult is not the ExpectResult,UInt64 is:" + uintTest);
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("008", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest5()
- {
- bool retVal = true;
- UInt64 uintA;
-
- TestLibrary.TestFramework.BeginScenario("PosTest5: the string format is [ws][sign]digits[ws] 2");
-
- try
- {
- UInt64 uintTest = (UInt64)this.GetInt64(0, UInt64.MaxValue);
- string strA = "\u0020" + uintTest.ToString();
- uintA = UInt64.Parse(strA);
- if (uintA != uintTest)
- {
- TestLibrary.TestFramework.LogError("009", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("010", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest6()
- {
- bool retVal = true;
- UInt64 uintA;
-
- TestLibrary.TestFramework.BeginScenario("PosTest6: the string format is [ws][sign]digits[ws] 3");
-
- try
- {
- UInt64 uintTest = (UInt64)this.GetInt64(0, UInt64.MaxValue);
- string strA = uintTest.ToString() + "\u0020";
- uintA = UInt64.Parse(strA);
- if (uintA != uintTest)
- {
- TestLibrary.TestFramework.LogError("011", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("012", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest7()
- {
- bool retVal = true;
- UInt64 uintA;
-
- TestLibrary.TestFramework.BeginScenario("PosTest7: the string format is [ws][sign]digits[ws] 4");
-
- try
- {
- UInt64 uintTest = (UInt64)this.GetInt64(0, UInt64.MaxValue);
- string strA = "\u0009" + "+" + uintTest.ToString() + "\u0020";
- uintA = UInt64.Parse(strA);
- if (uintA != uintTest)
- {
- TestLibrary.TestFramework.LogError("013", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("014", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- #endregion
- #region NegativeTest
- public bool NegTest1()
- {
- bool retVal = true;
- UInt64 uintA;
- TestLibrary.TestFramework.BeginScenario("NegTest1: the parameter string is null");
-
- try
- {
- string strA = null;
- uintA = UInt64.Parse(strA);
- retVal = false;
- }
- catch (ArgumentNullException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N001", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest2()
- {
- bool retVal = true;
- UInt64 uintA;
- TestLibrary.TestFramework.BeginScenario("NegTest2: the parameter string is not of the correct format 1");
-
- try
- {
- string strA = "abcd";
- uintA = UInt64.Parse(strA);
- retVal = false;
- }
- catch (FormatException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N002", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest3()
- {
- bool retVal = true;
- UInt64 uintA;
- TestLibrary.TestFramework.BeginScenario("NegTest3: the parameter string is not of the correct format 2");
-
- try
- {
- string strA = "b12345d";
- uintA = UInt64.Parse(strA);
- retVal = false;
- }
- catch (FormatException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N003", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest4()
- {
- bool retVal = true;
- UInt64 uintA;
- TestLibrary.TestFramework.BeginScenario("NegTest4: the parameter string corresponding number is less than UInt64 minValue");
-
- try
- {
- Int64 Testint = (-1) * Convert.ToInt64(this.GetInt64(1, Int64.MaxValue));
- string strA = Testint.ToString();
- uintA = UInt64.Parse(strA);
- retVal = false;
- }
- catch (OverflowException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N004", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest5()
- {
- bool retVal = true;
- UInt64 uintA;
- TestLibrary.TestFramework.BeginScenario("NegTest5: the parameter string corresponding number is larger than UInt64 maxValue");
-
- try
- {
- string strA = "18446744073709551616";
- uintA = UInt64.Parse(strA);
- retVal = false;
- }
- catch (OverflowException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N005", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- #endregion
- #region ForTestObject
- private UInt64 GetInt64(UInt64 minValue, UInt64 maxValue)
- {
- try
- {
- if (minValue == maxValue)
- {
- return minValue;
- }
- if (minValue < maxValue)
- {
- return minValue + (UInt64)TestLibrary.Generator.GetInt64(-55) % (maxValue - minValue);
- }
- }
- catch
- {
- throw;
- }
-
- return minValue;
- }
- #endregion
-}
-
diff --git a/tests/src/CoreMangLib/cti/system/uint64/uint64parse2.cs b/tests/src/CoreMangLib/cti/system/uint64/uint64parse2.cs
deleted file mode 100644
index 8e242caf5c..0000000000
--- a/tests/src/CoreMangLib/cti/system/uint64/uint64parse2.cs
+++ /dev/null
@@ -1,391 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-
-/// <summary>
-/// UInt64.Parse(System.string,NumberStyle style)
-/// </summary>
-public class UInt64Parse2
-{
- public static int Main()
- {
- UInt64Parse2 ui64parse2 = new UInt64Parse2();
- TestLibrary.TestFramework.BeginTestCase("UInt64Parse2");
-
- if (ui64parse2.RunTests())
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("PASS");
- return 100;
- }
- else
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("FAIL");
- return 0;
- }
- }
- public bool RunTests()
- {
- bool retVal = true;
- TestLibrary.TestFramework.LogInformation("[Positive]");
- retVal = PosTest1() && retVal;
- retVal = PosTest2() && retVal;
- retVal = PosTest3() && retVal;
- retVal = PosTest4() && retVal;
- retVal = PosTest5() && retVal;
- retVal = PosTest6() && retVal;
- retVal = PosTest7() && retVal;
-
- TestLibrary.TestFramework.LogInformation("[Negative]");
- retVal = NegTest1() && retVal;
- retVal = NegTest2() && retVal;
- retVal = NegTest3() && retVal;
- retVal = NegTest4() && retVal;
- retVal = NegTest5() && retVal;
- retVal = NegTest6() && retVal;
- retVal = NegTest7() && retVal;
-
- return retVal;
- }
- #region PositiveTest
- public bool PosTest1()
- {
- bool retVal = true;
- UInt64 uintA;
- TestLibrary.TestFramework.BeginScenario("PosTest1: the string corresponding UInt64 is UInt64 MaxValue 1");
- try
- {
- string strA = UInt64.MaxValue.ToString();
- NumberStyles style = NumberStyles.Any;
- uintA = UInt64.Parse(strA, style);
- if (uintA != UInt64.MaxValue)
- {
- TestLibrary.TestFramework.LogError("001", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest2()
- {
- bool retVal = true;
- UInt64 uintA;
- TestLibrary.TestFramework.BeginScenario("PosTest2: the string corresponding UInt64 is UInt64 MaxValue 2");
- try
- {
- string strA = "FFFFFFFFFFFFFFFF";
- NumberStyles style = NumberStyles.HexNumber;
- uintA = UInt64.Parse(strA, style);
- if (uintA != UInt64.MaxValue)
- {
- TestLibrary.TestFramework.LogError("003", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest3()
- {
- bool retVal = true;
- UInt64 uintA;
- TestLibrary.TestFramework.BeginScenario("PosTest3: The string parameter contains a number of the form:[ws][sign]digits[ws] 1");
- try
- {
- string strA = "01234";
- NumberStyles style = NumberStyles.HexNumber;
- uintA = UInt64.Parse(strA, style);
- UInt64 expUIntA = (UInt64)(Math.Pow(16, 3)) + (UInt64)(2 * Math.Pow(16, 2)) + 3 * 16 + 4;
- if (uintA != expUIntA)
- {
- TestLibrary.TestFramework.LogError("005", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest4()
- {
- bool retVal = true;
- UInt64 uintA;
- TestLibrary.TestFramework.BeginScenario("PosTest4: The string parameter contains a number of the form:[ws][sign]digits[ws] 2");
- try
- {
- string strA = "01234";
- NumberStyles style = NumberStyles.Any;
- uintA = UInt64.Parse(strA, style);
- if (uintA != 1234)
- {
- TestLibrary.TestFramework.LogError("007", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("008", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest5()
- {
- bool retVal = true;
- UInt64 uintA;
- TestLibrary.TestFramework.BeginScenario("PosTest5: The string parameter contains a number of the form:[ws][sign]digits[ws] 3");
- try
- {
- UInt64 intA = this.GetInt64(0, UInt64.MaxValue);
- string strA = "\u0009" + "+" + intA.ToString() + "\u000a";
- NumberStyles style = NumberStyles.Any;
- uintA = UInt64.Parse(strA, style);
- if (uintA != (UInt64)intA)
- {
- TestLibrary.TestFramework.LogError("009", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("010", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest6()
- {
- bool retVal = true;
- UInt64 uintA;
- TestLibrary.TestFramework.BeginScenario("PosTest6: The string parameter contains a number of the form:[ws]hexdigits[ws] 1");
- try
- {
- string strA = "abcde";
- NumberStyles style = NumberStyles.HexNumber;
- uintA = UInt64.Parse(strA, style);
- UInt64 expUIntA = (UInt64)(10 * Math.Pow(16, 4)) + (UInt64)(11 * Math.Pow(16, 3)) + (UInt64)(12 * Math.Pow(16, 2)) + (UInt64)(13 * Math.Pow(16, 1)) + 14;
- if (uintA != expUIntA)
- {
- TestLibrary.TestFramework.LogError("011", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("012", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest7()
- {
- bool retVal = true;
- UInt64 uintA;
- TestLibrary.TestFramework.BeginScenario("PosTest7: The string parameter contains a number of the form:[ws]hexdigits[ws] 2");
- try
- {
- string strA = "\u0009" + "abcde" + "\u000A";
- NumberStyles style = NumberStyles.HexNumber;
- uintA = UInt64.Parse(strA, style);
- UInt64 expUIntA = (UInt64)(10 * Math.Pow(16, 4)) + (UInt64)(11 * Math.Pow(16, 3)) + (UInt64)(12 * Math.Pow(16, 2)) + (UInt64)(13 * Math.Pow(16, 1)) + 14;
- if (uintA != expUIntA)
- {
- TestLibrary.TestFramework.LogError("013", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("014", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- #endregion
- #region NegativeTest
- public bool NegTest1()
- {
- bool retVal = true;
- UInt64 uintA;
- TestLibrary.TestFramework.BeginScenario("NegTest1: the parameter string is null");
-
- try
- {
- string strA = null;
- uintA = UInt64.Parse(strA, NumberStyles.Integer);
- retVal = false;
- }
- catch (ArgumentNullException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N001", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest2()
- {
- bool retVal = true;
- UInt64 uintA;
- TestLibrary.TestFramework.BeginScenario("NegTest2: the style is not the NumberStyles value");
-
- try
- {
- string strA = "12345";
- NumberStyles numstyle = (NumberStyles)(-1);
- uintA = UInt64.Parse(strA, numstyle);
- retVal = false;
- }
- catch (ArgumentException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N002", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest3()
- {
- bool retVal = true;
- UInt64 uintA;
- TestLibrary.TestFramework.BeginScenario("NegTest3: the string is not in a format compliant with style 1");
-
- try
- {
- string strA = "abcd";
- NumberStyles style = NumberStyles.Integer;
- uintA = UInt64.Parse(strA, style);
- retVal = false;
- }
- catch (FormatException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N003", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest4()
- {
- bool retVal = true;
- UInt64 uintA;
- TestLibrary.TestFramework.BeginScenario("NegTest4: the string is not in a format compliant with style 2");
-
- try
- {
- string strA = "gabcd";
- NumberStyles style = NumberStyles.HexNumber;
- uintA = UInt64.Parse(strA, style);
- retVal = false;
- }
- catch (FormatException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N003", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest5()
- {
- bool retVal = true;
- UInt64 uintA;
- TestLibrary.TestFramework.BeginScenario("NegTest5: the parameter string corresponding number is less than UInt64 minValue");
-
- try
- {
- UInt64 Testint = this.GetInt64(1, UInt64.MaxValue);
- string strA = "-" + Testint.ToString();
- NumberStyles style = NumberStyles.Integer;
- uintA = UInt64.Parse(strA, style);
- retVal = false;
- }
- catch (OverflowException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N005", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest6()
- {
- bool retVal = true;
- UInt64 uintA;
- TestLibrary.TestFramework.BeginScenario("NegTest6: the parameter string corresponding number is larger than UInt64 maxValue");
-
- try
- {
- string strA = "18446744073709551616";
- NumberStyles style = NumberStyles.Integer;
- uintA = UInt64.Parse(strA, style);
- retVal = false;
- }
- catch (OverflowException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N006", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest7()
- {
- bool retVal = true;
- UInt64 uintA;
- TestLibrary.TestFramework.BeginScenario("NegTest7: The string parameter contains a number of the form:[ws][sign]hexdigits[ws]");
- try
- {
- string strA = "\u0009" + "+" + "abcde" + "\u0009";
- NumberStyles style = NumberStyles.HexNumber;
- uintA = UInt64.Parse(strA, style);
- retVal = false;
- }
- catch (FormatException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N007", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- #endregion
- #region ForTestObject
- private UInt64 GetInt64(UInt64 minValue, UInt64 maxValue)
- {
- try
- {
- if (minValue == maxValue)
- {
- return minValue;
- }
- if (minValue < maxValue)
- {
- return minValue + (UInt64)TestLibrary.Generator.GetInt64(-55) % (maxValue - minValue);
- }
- }
- catch
- {
- throw;
- }
-
- return minValue;
- }
- #endregion
-}
diff --git a/tests/src/CoreMangLib/cti/system/uint64/uint64parse3.cs b/tests/src/CoreMangLib/cti/system/uint64/uint64parse3.cs
deleted file mode 100644
index 284b9f4ee0..0000000000
--- a/tests/src/CoreMangLib/cti/system/uint64/uint64parse3.cs
+++ /dev/null
@@ -1,331 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Globalization;
-
-/// <summary>
-/// UInt64.Parse(System.string,NumberStyle style,IFormatProvider provider)
-/// </summary>
-public class UInt64Parse3
-{
- public static int Main()
- {
- UInt64Parse3 ui64parse3 = new UInt64Parse3();
- TestLibrary.TestFramework.BeginTestCase("UInt64Parse3");
-
- if (ui64parse3.RunTests())
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("PASS");
- return 100;
- }
- else
- {
- TestLibrary.TestFramework.EndTestCase();
- TestLibrary.TestFramework.LogInformation("FAIL");
- return 0;
- }
- }
- public bool RunTests()
- {
- bool retVal = true;
- TestLibrary.TestFramework.LogInformation("[Positive]");
- retVal = PosTest1() && retVal;
- retVal = PosTest2() && retVal;
- retVal = PosTest3() && retVal;
- retVal = PosTest4() && retVal;
- TestLibrary.TestFramework.LogInformation("[Negative]");
- retVal = NegTest1() && retVal;
- retVal = NegTest2() && retVal;
- retVal = NegTest3() && retVal;
- retVal = NegTest4() && retVal;
- retVal = NegTest5() && retVal;
- retVal = NegTest6() && retVal;
- retVal = NegTest7() && retVal;
- return retVal;
- }
- #region PositiveTest
- public bool PosTest1()
- {
- bool retVal = true;
- UInt64 uintA;
- CultureInfo myculture = new CultureInfo("en-us");
- IFormatProvider provider = myculture.NumberFormat;
- TestLibrary.TestFramework.BeginScenario("PosTest1: the string corresponding UInt64 is UInt64 MaxValue 1");
- try
- {
- string strA = UInt64.MaxValue.ToString();
- NumberStyles style = NumberStyles.Any;
- uintA = UInt64.Parse(strA, style, provider);
- if (uintA != UInt64.MaxValue)
- {
- TestLibrary.TestFramework.LogError("001", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest2()
- {
- bool retVal = true;
- UInt64 uintA;
- CultureInfo myculture = new CultureInfo("en-us");
- IFormatProvider provider = myculture.NumberFormat;
- TestLibrary.TestFramework.BeginScenario("PosTest2: the string corresponding UInt64 is UInt64 MaxValue 2");
- try
- {
- string strA = "FFFFFFFFFFFFFFFF";
- NumberStyles style = NumberStyles.HexNumber;
- uintA = UInt64.Parse(strA, style, provider);
- if (uintA != UInt64.MaxValue)
- {
- TestLibrary.TestFramework.LogError("003", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest3()
- {
- bool retVal = true;
- UInt64 uintA;
- CultureInfo myculture = new CultureInfo("el-GR");
- IFormatProvider provider = myculture.NumberFormat;
- TestLibrary.TestFramework.BeginScenario("PosTest3: The string parameter contains a number of the form:[ws][sign]digits[ws]");
- try
- {
- string strA = "\u0009" + "abcde" + "\u000A";
- NumberStyles style = NumberStyles.HexNumber;
- uintA = UInt64.Parse(strA, style, provider);
- UInt64 expUIntA = (UInt64)(10 * Math.Pow(16, 4)) + (UInt64)(11 * Math.Pow(16, 3)) + (UInt64)(12 * Math.Pow(16, 2)) + (UInt64)(13 * Math.Pow(16, 1)) + 14;
- if (uintA != expUIntA)
- {
- TestLibrary.TestFramework.LogError("005", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool PosTest4()
- {
- bool retVal = true;
- UInt64 uintA;
- CultureInfo myculture = new CultureInfo("el-GR");
- IFormatProvider provider = myculture.NumberFormat;
- TestLibrary.TestFramework.BeginScenario("PosTest4: The string parameter contains a number of the form:[ws]hexdigits[ws]");
- try
- {
- string strA = "fffff";
- NumberStyles style = NumberStyles.HexNumber;
- uintA = UInt64.Parse(strA, style, provider);
- UInt64 expUIntA = (UInt64)(15 * Math.Pow(16, 4)) + (UInt64)(15 * Math.Pow(16, 3)) + (UInt64)(15 * Math.Pow(16, 2)) + (UInt64)(15 * Math.Pow(16, 1)) + 15;
- if (uintA != expUIntA)
- {
- TestLibrary.TestFramework.LogError("007", "the ActualResult is not the ExpectResult");
- retVal = false;
- }
- }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("008", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- #endregion
- #region NegativeTest
- public bool NegTest1()
- {
- bool retVal = true;
- UInt64 uintA;
- IFormatProvider provider = null;
- TestLibrary.TestFramework.BeginScenario("NegTest1: the parameter string is null");
-
- try
- {
- string strA = null;
- uintA = UInt64.Parse(strA, NumberStyles.Integer, provider);
- retVal = false;
- }
- catch (ArgumentNullException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N001", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest2()
- {
- bool retVal = true;
- UInt64 uintA;
- IFormatProvider provider = null;
- TestLibrary.TestFramework.BeginScenario("NegTest2: the style is not the NumberStyles value");
-
- try
- {
- string strA = "12345";
- NumberStyles numstyle = (NumberStyles)(-1);
- uintA = UInt64.Parse(strA, numstyle, provider);
- retVal = false;
- }
- catch (ArgumentException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N002", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest3()
- {
- bool retVal = true;
- UInt64 uintA;
- IFormatProvider provider = null;
- TestLibrary.TestFramework.BeginScenario("NegTest3: the string is not in a format compliant with style 1");
-
- try
- {
- string strA = "abcd";
- NumberStyles style = NumberStyles.Integer;
- uintA = UInt64.Parse(strA, style, provider);
- retVal = false;
- }
- catch (FormatException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N003", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest4()
- {
- bool retVal = true;
- UInt64 uintA;
- IFormatProvider provider = null;
- TestLibrary.TestFramework.BeginScenario("NegTest4: the string is not in a format compliant with style 2");
-
- try
- {
- string strA = "gabcd";
- NumberStyles style = NumberStyles.HexNumber;
- uintA = UInt64.Parse(strA, style, provider);
- retVal = false;
- }
- catch (FormatException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N003", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest5()
- {
- bool retVal = true;
- UInt64 uintA;
- IFormatProvider provider = null;
- TestLibrary.TestFramework.BeginScenario("NegTest5: the parameter string corresponding number is less than UInt64 minValue");
-
- try
- {
- Int64 Testint = (-1) * Convert.ToInt64(this.GetInt64(1, Int64.MaxValue));
- string strA = Testint.ToString();
- NumberStyles style = NumberStyles.Integer;
- uintA = UInt64.Parse(strA, style, provider);
- retVal = false;
- }
- catch (OverflowException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N005", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest6()
- {
- bool retVal = true;
- UInt64 uintA;
- IFormatProvider provider = null;
- TestLibrary.TestFramework.BeginScenario("NegTest6: the parameter string corresponding number is larger than UInt64 maxValue");
-
- try
- {
- string strA = "18446744073709551616";
- NumberStyles style = NumberStyles.Integer;
- uintA = UInt64.Parse(strA, style, provider);
- retVal = false;
- }
- catch (OverflowException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N006", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- public bool NegTest7()
- {
- bool retVal = true;
- UInt64 uintA;
- IFormatProvider provider = null;
- TestLibrary.TestFramework.BeginScenario("NegTest7: The string parameter contains a number of the form:[ws][sign]hexdigits[ws]");
- try
- {
- string strA = "\u0009" + "+" + "abcde" + "\u0009";
- NumberStyles style = NumberStyles.HexNumber;
- uintA = UInt64.Parse(strA, style, provider);
- retVal = false;
- }
- catch (FormatException) { }
- catch (Exception e)
- {
- TestLibrary.TestFramework.LogError("N007", "Unexpected exception: " + e);
- retVal = false;
- }
- return retVal;
- }
- #endregion
- #region ForTestObject
- private UInt64 GetInt64(UInt64 minValue, UInt64 maxValue)
- {
- try
- {
- if (minValue == maxValue)
- {
- return minValue;
- }
- if (minValue < maxValue)
- {
- return minValue + (UInt64)TestLibrary.Generator.GetInt64(-55) % (maxValue - minValue);
- }
- }
- catch
- {
- throw;
- }
-
- return minValue;
- }
- #endregion
-}
diff --git a/tests/src/CoreMangLib/cti/system/uint64/uint64tryparse.cs b/tests/src/CoreMangLib/cti/system/uint64/uint64tryparse.cs
deleted file mode 100644
index d9432658eb..0000000000
--- a/tests/src/CoreMangLib/cti/system/uint64/uint64tryparse.cs
+++ /dev/null
@@ -1,561 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Globalization;
-
-// Co7530TryParse_all.cs
-// Tests UInt64.TryParse(String), UInt64.TryParse(String, NumberStyles, IFormatProvider, ref UInt64)
-// 2003/04/01 KatyK
-public class Co7530TryParse
-{
- static bool verbose = false;
-
- public static int Main()
- {
- bool passed = true;
-
- try
- {
- // Make the test culture independent
- TestLibrary.Utilities.CurrentCulture = CultureInfo.InvariantCulture;
-
- // Set up NFIs to use
- NumberFormatInfo goodNFI = new NumberFormatInfo();
-
- NumberFormatInfo corruptNFI = new NumberFormatInfo(); // DecimalSeparator == GroupSeparator
- corruptNFI.NumberDecimalSeparator = ".";
- corruptNFI.NumberGroupSeparator = ".";
- corruptNFI.CurrencyDecimalSeparator = ".";
- corruptNFI.CurrencyGroupSeparator = ".";
- corruptNFI.CurrencySymbol = "$";
-
- NumberFormatInfo swappedNFI = new NumberFormatInfo(); // DecimalSeparator & GroupSeparator swapped
- swappedNFI.NumberDecimalSeparator = ".";
- swappedNFI.NumberGroupSeparator = ",";
- swappedNFI.CurrencyDecimalSeparator = ",";
- swappedNFI.CurrencyGroupSeparator = ".";
- swappedNFI.CurrencySymbol = "$";
-
- NumberFormatInfo distinctNFI = new NumberFormatInfo(); // DecimalSeparator & GroupSeparator distinct
- distinctNFI.NumberDecimalSeparator = ".";
- distinctNFI.NumberGroupSeparator = ",";
- distinctNFI.CurrencyDecimalSeparator = ":";
- distinctNFI.CurrencyGroupSeparator = ";";
- distinctNFI.CurrencySymbol = "$";
-
- NumberFormatInfo customNFI = new NumberFormatInfo();
- customNFI.NegativeSign = "^";
-
- NumberFormatInfo ambigNFI = new NumberFormatInfo();
- ambigNFI.NegativeSign = "^";
- ambigNFI.CurrencySymbol = "^";
-
- CultureInfo germanCulture = new CultureInfo("de-DE");
- CultureInfo japaneseCulture;
-
- try
- {
- japaneseCulture = new CultureInfo("ja-JP");
- }
- catch (Exception)
- {
- TestLibrary.Logging.WriteLine("East Asian Languages are not installed. Skiping Japanese culture tests.");
- japaneseCulture = null;
- }
-
- // Parse tests included for comparison/regression
- passed &= VerifyUInt64Parse("5", 5);
- passed &= VerifyUInt64Parse("5 ", 5);
- passed &= VerifyUInt64Parse("5\0", 5);
- passed &= VerifyUInt64Parse("893382737", 893382737);
- passed &= VerifyUInt64Parse("1234567891", 1234567891);
- passed &= VerifyUInt64Parse("3123456789", 3123456789);
- passed &= VerifyUInt64Parse("123456789123456789", 123456789123456789);
- passed &= VerifyUInt64Parse("18446744073709551615", 0xFFFFFFFFFFFFFFFF);
- passed &= VerifyUInt64Parse("5", NumberStyles.Integer, CultureInfo.InvariantCulture, 5);
- passed &= VerifyUInt64Parse("5 \0", NumberStyles.Integer, CultureInfo.InvariantCulture, 5);
- passed &= VerifyUInt64Parse("5\0\0\0", NumberStyles.Integer, CultureInfo.InvariantCulture, 5);
- passed &= VerifyUInt64Parse("12", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0x12);
- passed &= VerifyUInt64Parse("fF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0xFF);
- passed &= VerifyUInt64Parse("FFFFFFFF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0xFFFFFFFF);
- passed &= VerifyUInt64Parse("FFFFFFFFFFFFFFFF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0xFFFFFFFFFFFFFFFF);
- passed &= VerifyUInt64Parse("5", NumberStyles.Integer, goodNFI, 5);
- passed &= VerifyUInt64Parse("5.0", NumberStyles.AllowDecimalPoint, goodNFI, 5);
- passed &= VerifyUInt64Parse("123", NumberStyles.Integer, germanCulture, 123);
- passed &= VerifyUInt64Parse("123", NumberStyles.Integer, japaneseCulture, 123);
- passed &= VerifyUInt64Parse("123.000", NumberStyles.Any, germanCulture, 123000);
- passed &= VerifyUInt64Parse("123,000", NumberStyles.Any, japaneseCulture, 123000);
- passed &= VerifyUInt64Parse("123,000", NumberStyles.AllowDecimalPoint, germanCulture, 123);
- passed &= VerifyUInt64Parse("123.000", NumberStyles.AllowDecimalPoint, japaneseCulture, 123);
- passed &= VerifyUInt64Parse("5,00 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Any, germanCulture, 5); // currency
- //
- passed &= VerifyUInt64Parse("5", NumberStyles.Integer, corruptNFI, 5);
- passed &= VerifyUInt64Parse("5", NumberStyles.Number, corruptNFI, 5);
- passed &= VerifyUInt64Parse("5.0", NumberStyles.Number, corruptNFI, 5);
- passed &= VerifyUInt64ParseException("5,0", NumberStyles.Number, corruptNFI, typeof(FormatException));
- passed &= VerifyUInt64ParseException("5.0.0", NumberStyles.Number, corruptNFI, typeof(FormatException));
- passed &= VerifyUInt64Parse("$5.0", NumberStyles.Currency, corruptNFI, 5);
- passed &= VerifyUInt64ParseException("$5,0", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyUInt64ParseException("$5.0.0", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyUInt64Parse("5.0", NumberStyles.Currency, corruptNFI, 5);
- passed &= VerifyUInt64ParseException("5,0", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyUInt64ParseException("5.0.0", NumberStyles.Currency, corruptNFI, typeof(FormatException));
- passed &= VerifyUInt64Parse("5.0", NumberStyles.Any, corruptNFI, 5);
- passed &= VerifyUInt64ParseException("5,0", NumberStyles.Any, corruptNFI, typeof(FormatException));
- passed &= VerifyUInt64ParseException("5.0.0", NumberStyles.Any, corruptNFI, typeof(FormatException));
- //
- passed &= VerifyUInt64Parse("5", NumberStyles.Integer, swappedNFI, 5);
- passed &= VerifyUInt64ParseException("1,234", NumberStyles.Integer, swappedNFI, typeof(FormatException));
- passed &= VerifyUInt64Parse("5", NumberStyles.Number, swappedNFI, 5);
- passed &= VerifyUInt64Parse("5.0", NumberStyles.Number, swappedNFI, 5);
- passed &= VerifyUInt64Parse("1,234", NumberStyles.Number, swappedNFI, 1234);
- passed &= VerifyUInt64Parse("1,234.0", NumberStyles.Number, swappedNFI, 1234);
- passed &= VerifyUInt64ParseException("5.000.000", NumberStyles.Number, swappedNFI, typeof(FormatException));
- passed &= VerifyUInt64ParseException("5.000,00", NumberStyles.Number, swappedNFI, typeof(FormatException));
- passed &= VerifyUInt64Parse("5.000", NumberStyles.Currency, swappedNFI, 5); //???
- passed &= VerifyUInt64ParseException("5.000,00", NumberStyles.Currency, swappedNFI, typeof(FormatException)); //???
- passed &= VerifyUInt64Parse("$5.000", NumberStyles.Currency, swappedNFI, 5000);
- passed &= VerifyUInt64Parse("$5.000,00", NumberStyles.Currency, swappedNFI, 5000);
- passed &= VerifyUInt64Parse("5.000", NumberStyles.Any, swappedNFI, 5); //?
- passed &= VerifyUInt64ParseException("5.000,00", NumberStyles.Any, swappedNFI, typeof(FormatException)); //?
- passed &= VerifyUInt64Parse("$5.000", NumberStyles.Any, swappedNFI, 5000);
- passed &= VerifyUInt64Parse("$5.000,00", NumberStyles.Any, swappedNFI, 5000);
- passed &= VerifyUInt64Parse("5,0", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyUInt64Parse("$5,0", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyUInt64Parse("5,000", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyUInt64Parse("$5,000", NumberStyles.Currency, swappedNFI, 5);
- passed &= VerifyUInt64ParseException("5,000.0", NumberStyles.Currency, swappedNFI, typeof(FormatException));
- passed &= VerifyUInt64ParseException("$5,000.0", NumberStyles.Currency, swappedNFI, typeof(FormatException));
- passed &= VerifyUInt64Parse("5,000", NumberStyles.Any, swappedNFI, 5);
- passed &= VerifyUInt64Parse("$5,000", NumberStyles.Any, swappedNFI, 5);
- passed &= VerifyUInt64ParseException("5,000.0", NumberStyles.Any, swappedNFI, typeof(FormatException));
- passed &= VerifyUInt64ParseException("$5,000.0", NumberStyles.Any, swappedNFI, typeof(FormatException));
- //
- passed &= VerifyUInt64Parse("5.0", NumberStyles.Number, distinctNFI, 5);
- passed &= VerifyUInt64Parse("1,234.0", NumberStyles.Number, distinctNFI, 1234);
- passed &= VerifyUInt64Parse("5.0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyUInt64Parse("1,234.0", NumberStyles.Currency, distinctNFI, 1234);
- passed &= VerifyUInt64Parse("5.0", NumberStyles.Any, distinctNFI, 5);
- passed &= VerifyUInt64Parse("1,234.0", NumberStyles.Any, distinctNFI, 1234);
- passed &= VerifyUInt64ParseException("$5.0", NumberStyles.Currency, distinctNFI, typeof(FormatException));
- passed &= VerifyUInt64ParseException("$5.0", NumberStyles.Any, distinctNFI, typeof(FormatException));
- passed &= VerifyUInt64ParseException("5:0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyUInt64ParseException("5;0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyUInt64ParseException("$5:0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyUInt64Parse("5:0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyUInt64Parse("5:000", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyUInt64Parse("5;000", NumberStyles.Currency, distinctNFI, 5000);
- passed &= VerifyUInt64Parse("$5:0", NumberStyles.Currency, distinctNFI, 5);
- passed &= VerifyUInt64Parse("$5;0", NumberStyles.Currency, distinctNFI, 50);
- passed &= VerifyUInt64Parse("5:0", NumberStyles.Any, distinctNFI, 5);
- passed &= VerifyUInt64Parse("5;0", NumberStyles.Any, distinctNFI, 50);
- passed &= VerifyUInt64Parse("$5:0", NumberStyles.Any, distinctNFI, 5);
- passed &= VerifyUInt64Parse("$5;0", NumberStyles.Any, distinctNFI, 50);
- passed &= VerifyUInt64ParseException("123,456;789.0", NumberStyles.Number, distinctNFI, typeof(FormatException));
- passed &= VerifyUInt64Parse("123,456;789.0", NumberStyles.Currency, distinctNFI, 123456789);
- passed &= VerifyUInt64Parse("123,456;789.0", NumberStyles.Any, distinctNFI, 123456789);
- passed &= VerifyUInt64ParseException("$123,456;789.0", NumberStyles.Any, distinctNFI, typeof(FormatException));
- //
- passed &= VerifyUInt64ParseException("-5", typeof(OverflowException));
- passed &= VerifyUInt64ParseException("123456789123456789123", typeof(OverflowException));
- passed &= VerifyUInt64ParseException("Garbage", typeof(FormatException));
- passed &= VerifyUInt64ParseException("5\0Garbage", typeof(FormatException));
- passed &= VerifyUInt64ParseException(null, typeof(ArgumentNullException));
- passed &= VerifyUInt64ParseException("123456789123456789", NumberStyles.HexNumber, CultureInfo.InvariantCulture, typeof(OverflowException));
- passed &= VerifyUInt64ParseException("5.3", NumberStyles.AllowDecimalPoint, goodNFI, typeof(OverflowException)); //weird that it's Overflow, but consistent with v1
- passed &= VerifyUInt64ParseException("5", NumberStyles.AllowHexSpecifier | NumberStyles.AllowParentheses, null, typeof(ArgumentException));
- passed &= VerifyUInt64ParseException("4", (NumberStyles)(-1), typeof(ArgumentException));
- passed &= VerifyUInt64ParseException("4", (NumberStyles)0x10000, typeof(ArgumentException));
- passed &= VerifyUInt64ParseException("4", (NumberStyles)(-1), CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifyUInt64ParseException("4", (NumberStyles)0x10000, CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifyUInt64ParseException("123.000.000.000.000.000.000", NumberStyles.Any, germanCulture, typeof(OverflowException));
- passed &= VerifyUInt64ParseException("123,000,000,000,000,000,000", NumberStyles.Any, japaneseCulture, typeof(OverflowException));
- passed &= VerifyUInt64ParseException("123,000,000,000,000,000,000", NumberStyles.Integer, germanCulture, typeof(FormatException));
- passed &= VerifyUInt64ParseException("123.000.000.000.000.000.000", NumberStyles.Integer, japaneseCulture, typeof(FormatException));
- passed &= VerifyUInt64ParseException("5,00 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Integer, germanCulture, typeof(FormatException)); // currency
-
- /////////// TryParse(String)
- //// Pass cases
- passed &= VerifyUInt64TryParse("5", 5, true);
- passed &= VerifyUInt64TryParse(" 5 ", 5, true);
- passed &= VerifyUInt64TryParse("5\0", 5, true);
- passed &= VerifyUInt64TryParse("5 \0", 5, true);
- passed &= VerifyUInt64TryParse("5\0\0\0", 5, true);
- passed &= VerifyUInt64TryParse("10000", 10000, true);
- passed &= VerifyUInt64TryParse("893382737", 893382737, true);
- passed &= VerifyUInt64TryParse("1234567891", 1234567891, true);
- passed &= VerifyUInt64TryParse("3123456789", 3123456789u, true);
- passed &= VerifyUInt64TryParse("123456789123456789", 123456789123456789, true);
- passed &= VerifyUInt64TryParse("18446744073709551615", 0xFFFFFFFFFFFFFFFF, true);
- passed &= VerifyUInt64TryParse(UInt64.MaxValue.ToString(), UInt64.MaxValue, true);
- passed &= VerifyUInt64TryParse(UInt64.MinValue.ToString(), UInt64.MinValue, true);
-
- //// Fail cases
- passed &= VerifyUInt64TryParse(null, 0, false);
- passed &= VerifyUInt64TryParse("", 0, false);
- passed &= VerifyUInt64TryParse("Garbage", 0, false);
- passed &= VerifyUInt64TryParse("5\0Garbage", 0, false);
- passed &= VerifyUInt64TryParse("-5", 0, false);
- passed &= VerifyUInt64TryParse("123456789123456789123", 0, false);
- passed &= VerifyUInt64TryParse("FF", 0, false);
- passed &= VerifyUInt64TryParse("27.3", 0, false);
- passed &= VerifyUInt64TryParse("23 5", 0, false);
-
-
- /////////// TryParse(TryParse(String, NumberStyles, IFormatProvider, ref UInt64)
- //// Pass cases
- passed &= VerifyUInt64TryParse("5", NumberStyles.Integer, CultureInfo.InvariantCulture, 5, true);
- // Variations on NumberStyles
- passed &= VerifyUInt64TryParse("12", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0x12, true);
- passed &= VerifyUInt64TryParse("FF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0xFF, true);
- passed &= VerifyUInt64TryParse("fF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0xFF, true);
- passed &= VerifyUInt64TryParse("fFFFFFFF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0xFFFFFFFF, true);
- passed &= VerifyUInt64TryParse("FFFFFFFFFFFFFFFF", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0xFFFFFFFFFFFFFFFF, true);
- passed &= VerifyUInt64TryParse(" 5", NumberStyles.AllowLeadingWhite, goodNFI, 5, true);
- passed &= VerifyUInt64TryParse("5", NumberStyles.Number, goodNFI, 5, true);
- passed &= VerifyUInt64TryParse("5.0", NumberStyles.AllowDecimalPoint, goodNFI, 5, true);
- // Variations on IFP
- passed &= VerifyUInt64TryParse("5", NumberStyles.Integer, goodNFI, 5, true);
- passed &= VerifyUInt64TryParse("5", NumberStyles.Integer, null, 5, true);
- passed &= VerifyUInt64TryParse("5", NumberStyles.Integer, new DateTimeFormatInfo(), 5, true);
- passed &= VerifyUInt64TryParse("123", NumberStyles.Integer, germanCulture, 123, true);
- passed &= VerifyUInt64TryParse("123", NumberStyles.Integer, japaneseCulture, 123, true);
- passed &= VerifyUInt64TryParse("123.000", NumberStyles.Any, germanCulture, 123000, true);
- passed &= VerifyUInt64TryParse("123,000", NumberStyles.Any, japaneseCulture, 123000, true);
- passed &= VerifyUInt64TryParse("123,000", NumberStyles.AllowDecimalPoint, germanCulture, 123, true);
- passed &= VerifyUInt64TryParse("123.000", NumberStyles.AllowDecimalPoint, japaneseCulture, 123, true);
- passed &= VerifyUInt64TryParse("5,00 " + germanCulture.NumberFormat.CurrencySymbol, NumberStyles.Any, germanCulture, 5, true); // currency
-
- //// Fail cases
- passed &= VerifyUInt64TryParse("-5", NumberStyles.Integer, CultureInfo.InvariantCulture, 0, false);
- passed &= VerifyUInt64TryParse("FF", NumberStyles.Integer, CultureInfo.InvariantCulture, 0, false);
- passed &= VerifyUInt64TryParse("123456789123456789", NumberStyles.HexNumber, CultureInfo.InvariantCulture, 0, false);
- passed &= VerifyUInt64TryParse("^42", NumberStyles.Any, customNFI, 0, false);
- passed &= VerifyUInt64TryParse("-42", NumberStyles.Any, customNFI, 0, false);
- passed &= VerifyUInt64TryParse("5.3", NumberStyles.AllowDecimalPoint, goodNFI, 0, false);
- passed &= VerifyUInt64TryParse("5 ", NumberStyles.AllowLeadingWhite, goodNFI, 0, false);
- passed &= VerifyUInt64TryParse("123.000.000.000.000.000.000", NumberStyles.Any, germanCulture, 0, false);
- passed &= VerifyUInt64TryParse("123,000,000,000,000,000,000", NumberStyles.Any, japaneseCulture, 0, false);
- passed &= VerifyUInt64TryParse("123,000,000,000,000,000,000", NumberStyles.Integer, germanCulture, 0, false);
- passed &= VerifyUInt64TryParse("123.000.000.000.000.000.000", NumberStyles.Integer, japaneseCulture, 0, false);
-
- //// Exception cases
- passed &= VerifyUInt64TryParseException("5", NumberStyles.AllowHexSpecifier | NumberStyles.AllowParentheses, null, typeof(ArgumentException));
- passed &= VerifyUInt64TryParseException("4", (NumberStyles)(-1), CultureInfo.InvariantCulture, typeof(ArgumentException));
- passed &= VerifyUInt64TryParseException("4", (NumberStyles)0x10000, CultureInfo.InvariantCulture, typeof(ArgumentException));
-
- // NumberStyles/NFI variations
- //
- passed &= VerifyUInt64TryParse("5", NumberStyles.Integer, corruptNFI, 5, true);
- passed &= VerifyUInt64TryParse("5", NumberStyles.Number, corruptNFI, 5, true);
- passed &= VerifyUInt64TryParse("5.0", NumberStyles.Number, corruptNFI, 5, true);
- passed &= VerifyUInt64TryParse("5,0", NumberStyles.Number, corruptNFI, 0, false);
- passed &= VerifyUInt64TryParse("5.0.0", NumberStyles.Number, corruptNFI, 0, false);
- passed &= VerifyUInt64TryParse("$5.0", NumberStyles.Currency, corruptNFI, 5, true);
- passed &= VerifyUInt64TryParse("$5,0", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyUInt64TryParse("$5.0.0", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyUInt64TryParse("5.0", NumberStyles.Currency, corruptNFI, 5, true);
- passed &= VerifyUInt64TryParse("5,0", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyUInt64TryParse("5.0.0", NumberStyles.Currency, corruptNFI, 0, false);
- passed &= VerifyUInt64TryParse("5.0", NumberStyles.Any, corruptNFI, 5, true);
- passed &= VerifyUInt64TryParse("5,0", NumberStyles.Any, corruptNFI, 0, false);
- passed &= VerifyUInt64TryParse("5.0.0", NumberStyles.Any, corruptNFI, 0, false);
- //
- passed &= VerifyUInt64TryParse("5", NumberStyles.Integer, swappedNFI, 5, true);
- passed &= VerifyUInt64TryParse("1,234", NumberStyles.Integer, swappedNFI, 0, false);
- passed &= VerifyUInt64TryParse("5", NumberStyles.Number, swappedNFI, 5, true);
- passed &= VerifyUInt64TryParse("5.0", NumberStyles.Number, swappedNFI, 5, true);
- passed &= VerifyUInt64TryParse("1,234", NumberStyles.Number, swappedNFI, 1234, true);
- passed &= VerifyUInt64TryParse("1,234.0", NumberStyles.Number, swappedNFI, 1234, true);
- passed &= VerifyUInt64TryParse("5.000.000", NumberStyles.Number, swappedNFI, 0, false);
- passed &= VerifyUInt64TryParse("5.000,00", NumberStyles.Number, swappedNFI, 0, false);
- passed &= VerifyUInt64TryParse("5.000", NumberStyles.Currency, swappedNFI, 5, true); //???
- passed &= VerifyUInt64TryParse("5.000,00", NumberStyles.Currency, swappedNFI, 0, false); //???
- passed &= VerifyUInt64TryParse("$5.000", NumberStyles.Currency, swappedNFI, 5000, true);
- passed &= VerifyUInt64TryParse("$5.000,00", NumberStyles.Currency, swappedNFI, 5000, true);
- passed &= VerifyUInt64TryParse("5.000", NumberStyles.Any, swappedNFI, 5, true); //?
- passed &= VerifyUInt64TryParse("5.000,00", NumberStyles.Any, swappedNFI, 0, false); //?
- passed &= VerifyUInt64TryParse("$5.000", NumberStyles.Any, swappedNFI, 5000, true);
- passed &= VerifyUInt64TryParse("$5.000,00", NumberStyles.Any, swappedNFI, 5000, true);
- passed &= VerifyUInt64TryParse("5,0", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyUInt64TryParse("$5,0", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyUInt64TryParse("5,000", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyUInt64TryParse("$5,000", NumberStyles.Currency, swappedNFI, 5, true);
- passed &= VerifyUInt64TryParse("5,000.0", NumberStyles.Currency, swappedNFI, 0, false);
- passed &= VerifyUInt64TryParse("$5,000.0", NumberStyles.Currency, swappedNFI, 0, false);
- passed &= VerifyUInt64TryParse("5,000", NumberStyles.Any, swappedNFI, 5, true);
- passed &= VerifyUInt64TryParse("$5,000", NumberStyles.Any, swappedNFI, 5, true);
- passed &= VerifyUInt64TryParse("5,000.0", NumberStyles.Any, swappedNFI, 0, false);
- passed &= VerifyUInt64TryParse("$5,000.0", NumberStyles.Any, swappedNFI, 0, false);
- //
- passed &= VerifyUInt64TryParse("5.0", NumberStyles.Number, distinctNFI, 5, true);
- passed &= VerifyUInt64TryParse("1,234.0", NumberStyles.Number, distinctNFI, 1234, true);
- passed &= VerifyUInt64TryParse("5.0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyUInt64TryParse("1,234.0", NumberStyles.Currency, distinctNFI, 1234, true);
- passed &= VerifyUInt64TryParse("5.0", NumberStyles.Any, distinctNFI, 5, true);
- passed &= VerifyUInt64TryParse("1,234.0", NumberStyles.Any, distinctNFI, 1234, true);
- passed &= VerifyUInt64TryParse("$5.0", NumberStyles.Currency, distinctNFI, 0, false);
- passed &= VerifyUInt64TryParse("$5.0", NumberStyles.Any, distinctNFI, 0, false);
- passed &= VerifyUInt64TryParse("5:0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyUInt64TryParse("5;0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyUInt64TryParse("$5:0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyUInt64TryParse("5:0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyUInt64TryParse("5:000", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyUInt64TryParse("5;000", NumberStyles.Currency, distinctNFI, 5000, true);
- passed &= VerifyUInt64TryParse("$5:0", NumberStyles.Currency, distinctNFI, 5, true);
- passed &= VerifyUInt64TryParse("$5;0", NumberStyles.Currency, distinctNFI, 50, true);
- passed &= VerifyUInt64TryParse("5:0", NumberStyles.Any, distinctNFI, 5, true);
- passed &= VerifyUInt64TryParse("5;0", NumberStyles.Any, distinctNFI, 50, true);
- passed &= VerifyUInt64TryParse("$5:0", NumberStyles.Any, distinctNFI, 5, true);
- passed &= VerifyUInt64TryParse("$5;0", NumberStyles.Any, distinctNFI, 50, true);
- passed &= VerifyUInt64TryParse("123,456;789.0", NumberStyles.Number, distinctNFI, 0, false);
- passed &= VerifyUInt64TryParse("123,456;789.0", NumberStyles.Currency, distinctNFI, 123456789, true);
- passed &= VerifyUInt64TryParse("123,456;789.0", NumberStyles.Any, distinctNFI, 123456789, true);
- passed &= VerifyUInt64TryParse("$123,456;789.0", NumberStyles.Any, distinctNFI, 0, false);
-
-
- // Should these pass or fail? Current parse behavior is to pass, so they might be
- // parse bugs, but they're not tryparse bugs.
- passed &= VerifyUInt64Parse("5", NumberStyles.Float, goodNFI, 5);
- passed &= VerifyUInt64TryParse("5", NumberStyles.Float, goodNFI, 5, true);
- passed &= VerifyUInt64Parse("5", NumberStyles.AllowDecimalPoint, goodNFI, 5);
- passed &= VerifyUInt64TryParse("5", NumberStyles.AllowDecimalPoint, goodNFI, 5, true);
- // I expect ArgumentException with an ambiguous NFI
- passed &= VerifyUInt64ParseException("^42", NumberStyles.Any, ambigNFI, typeof(OverflowException));
- passed &= VerifyUInt64TryParse("^42", NumberStyles.Any, ambigNFI, 0, false);
-
- /// END TEST CASES
- }
- catch (Exception e)
- {
- TestLibrary.Logging.WriteLine("Unexpected exception!! " + e.ToString());
- passed = false;
- }
-
- if (passed)
- {
- TestLibrary.Logging.WriteLine("paSs");
- return 100;
- }
- else
- {
- TestLibrary.Logging.WriteLine("FAiL");
- return 1;
- }
- }
-
- public static bool VerifyUInt64TryParse(string value, UInt64 expectedResult, bool expectedReturn)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: UInt64.TryParse, Value = '{0}', Expected Result = {1}, Expected Return = {2}",
- value, expectedResult, expectedReturn);
- }
- UInt64 result = 0;
- try
- {
- bool returnValue = UInt64.TryParse(value, out result);
- if (returnValue != expectedReturn)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedReturn, returnValue);
- return false;
- }
- if (result != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, result);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyUInt64TryParse(string value, NumberStyles style, IFormatProvider provider, UInt64 expectedResult, bool expectedReturn)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: UInt64.TryParse, Value = '{0}', Style = {1}, Provider = {2}, Expected Result = {3}, Expected Return = {4}",
- value, style, provider, expectedResult, expectedReturn);
- }
- UInt64 result = 0;
- try
- {
- bool returnValue = UInt64.TryParse(value, style, provider, out result);
- if (returnValue != expectedReturn)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Style = {1}, Provider = {2}, Expected Return = {3}, Actual Return = {4}",
- value, style, provider, expectedReturn, returnValue);
- return false;
- }
- if (result != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, result);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyUInt64TryParseException(string value, NumberStyles style, IFormatProvider provider, Type exceptionType)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: UInt64.TryParse, Value = '{0}', Style = {1}, Provider = {2}, Expected Exception = {3}",
- value, style, provider, exceptionType);
- }
- try
- {
- UInt64 result = 0;
- Boolean returnValue = UInt64.TryParse(value, style, provider, out result);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifyUInt64Parse(string value, UInt64 expectedResult)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: UInt64.Parse, Value = '{0}', Expected Result, {1}",
- value, expectedResult);
- }
- try
- {
- UInt64 returnValue = UInt64.Parse(value);
- if (returnValue != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, returnValue);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyUInt64Parse(string value, NumberStyles style, IFormatProvider provider, UInt64 expectedResult)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: UInt64.Parse, Value = '{0}', Style = {1}, provider = {2}, Expected Result = {3}",
- value, style, provider, expectedResult);
- }
- try
- {
- UInt64 returnValue = UInt64.Parse(value, style, provider);
- if (returnValue != expectedResult)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Return: {1}, Actual Return: {2}", value, expectedResult, returnValue);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- TestLibrary.Logging.WriteLine("FAILURE: Unexpected Exception, Value = '{0}', Exception: {1}", value, ex);
- return false;
- }
- }
-
- public static bool VerifyUInt64ParseException(string value, Type exceptionType)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: UInt64.Parse, Value = '{0}', Expected Exception, {1}",
- value, exceptionType);
- }
- try
- {
- UInt64 returnValue = UInt64.Parse(value);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifyUInt64ParseException(string value, NumberStyles style, Type exceptionType)
- {
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: UInt64.Parse, Value = '{0}', Style = {1}, Expected Exception = {3}",
- value, style, exceptionType);
- }
- try
- {
- UInt64 returnValue = UInt64.Parse(value, style);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-
- public static bool VerifyUInt64ParseException(string value, NumberStyles style, IFormatProvider provider, Type exceptionType)
- {
- if (provider == null) return true;
-
- if (verbose)
- {
- TestLibrary.Logging.WriteLine("Test: UInt64.Parse, Value = '{0}', Style = {1}, Provider = {2}, Expected Exception = {3}",
- value, style, provider, exceptionType);
- }
- try
- {
- UInt64 returnValue = UInt64.Parse(value, style, provider);
- TestLibrary.Logging.WriteLine("FAILURE: Value = '{0}', Expected Exception: {1}", value, exceptionType);
- return false;
- }
- catch (Exception ex)
- {
- if (!ex.GetType().IsAssignableFrom(exceptionType))
- {
- TestLibrary.Logging.WriteLine("FAILURE: Wrong Exception Type, Value = '{0}', Exception Type: {1} Expected Type: {2}", value, ex.GetType(), exceptionType);
- return false;
- }
- return true;
- }
- }
-}