summaryrefslogtreecommitdiff
path: root/tests/src/CoreMangLib/cti/system/uint64
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/CoreMangLib/cti/system/uint64')
-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
8 files changed, 0 insertions, 1797 deletions
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;
- }
- }
-}