From c431646aad2b712b24ab95b956c9147afe896af1 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Mon, 26 Feb 2018 09:29:23 -0800 Subject: [PATCH] Delete Single/Double.GetHashCode tests (#16567) The test is failing because of change in the -NaN hashcode. CoreFX has redundant and better test coverage for these. Fixes #16566 --- .../cti/system/double/DoubleGetHashCode.csproj | 40 ------ .../cti/system/double/doublegethashcode.cs | 73 ---------- .../cti/system/single/SingleGetHashCode.csproj | 40 ------ .../cti/system/single/singlegethashcode.cs | 152 --------------------- 4 files changed, 305 deletions(-) delete mode 100644 tests/src/CoreMangLib/cti/system/double/DoubleGetHashCode.csproj delete mode 100644 tests/src/CoreMangLib/cti/system/double/doublegethashcode.cs delete mode 100644 tests/src/CoreMangLib/cti/system/single/SingleGetHashCode.csproj delete mode 100644 tests/src/CoreMangLib/cti/system/single/singlegethashcode.cs diff --git a/tests/src/CoreMangLib/cti/system/double/DoubleGetHashCode.csproj b/tests/src/CoreMangLib/cti/system/double/DoubleGetHashCode.csproj deleted file mode 100644 index fbf6b4d..0000000 --- a/tests/src/CoreMangLib/cti/system/double/DoubleGetHashCode.csproj +++ /dev/null @@ -1,40 +0,0 @@ - - - - - Debug - AnyCPU - 2.0 - {95DFC527-4DC1-495E-97D7-E94EE1F7140D} - Exe - {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - ..\..\ - true - BuildAndRun - 1 - - - - - - - - - False - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/tests/src/CoreMangLib/cti/system/double/doublegethashcode.cs b/tests/src/CoreMangLib/cti/system/double/doublegethashcode.cs deleted file mode 100644 index d06e2d1..0000000 --- a/tests/src/CoreMangLib/cti/system/double/doublegethashcode.cs +++ /dev/null @@ -1,73 +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; - -/// -/// GetHashCode -/// - -public class DoubleGetHashCode -{ - #region Public Methods - public bool RunTests() - { - bool retVal = true; - - TestLibrary.TestFramework.LogInformation("[Positive]"); - retVal = PosTest1() && retVal; - - return retVal; - } - - #region Positive Test Cases - public bool PosTest1() - { - bool retVal = true; - - TestLibrary.TestFramework.BeginScenario("PosTest1: check that if the return value is equal."); - - try - { - Double i = TestLibrary.Generator.GetDouble(-55); - Double i1 = i; - Double i2 = i; - - if (i1.GetHashCode() != i2.GetHashCode()) - { - TestLibrary.TestFramework.LogError("001.1", "gethashcode is not equal : " + i1); - retVal = false; - } - } - catch (Exception e) - { - TestLibrary.TestFramework.LogError("001.2", "Unexpected exception: " + e); - retVal = false; - } - - return retVal; - } - #endregion - - #endregion - - public static int Main() - { - DoubleGetHashCode test = new DoubleGetHashCode(); - - TestLibrary.TestFramework.BeginTestCase("DoubleGetHashCode"); - - 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/single/SingleGetHashCode.csproj b/tests/src/CoreMangLib/cti/system/single/SingleGetHashCode.csproj deleted file mode 100644 index 3c2e1ca..0000000 --- a/tests/src/CoreMangLib/cti/system/single/SingleGetHashCode.csproj +++ /dev/null @@ -1,40 +0,0 @@ - - - - - Debug - AnyCPU - 2.0 - {95DFC527-4DC1-495E-97D7-E94EE1F7140D} - Exe - {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - ..\..\ - true - BuildAndRun - 1 - - - - - - - - - False - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/tests/src/CoreMangLib/cti/system/single/singlegethashcode.cs b/tests/src/CoreMangLib/cti/system/single/singlegethashcode.cs deleted file mode 100644 index af93605..0000000 --- a/tests/src/CoreMangLib/cti/system/single/singlegethashcode.cs +++ /dev/null @@ -1,152 +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; -/// -/// GetHashCode -/// -public class SingleGetHashCode -{ - #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: check a random Single has a correct hashcode."); - - try - { - Single i1 = TestLibrary.Generator.GetSingle(-55); - int expectValue=GetExpectValue(i1); - int actualValue = i1.GetHashCode(); - if (actualValue != expectValue) - { - TestLibrary.TestFramework.LogError("001.1", "GetHashCode return an error value. "); - retVal = false; - } - } - catch (Exception e) - { - TestLibrary.TestFramework.LogError("001.2", "Unexpected exception: " + e); - retVal = false; - } - - return retVal; - } - public bool PosTest2() - { - bool retVal = true; - - TestLibrary.TestFramework.BeginScenario("PosTest2: check 0 and -0 has a correct hashcode."); - - try - { - Single i1 = (Single)0; - int expectValue = GetExpectValue(i1); - int actualValue = i1.GetHashCode(); - if (actualValue != expectValue) - { - TestLibrary.TestFramework.LogError("002.1", "GetHashCode return an error value. "); - retVal = false; - } - i1 = (Single)(-0); - expectValue = GetExpectValue(i1); - actualValue = i1.GetHashCode(); - if (actualValue != expectValue) - { - TestLibrary.TestFramework.LogError("002.2", "GetHashCode return an error value. "); - retVal = false; - } - } - catch (Exception e) - { - TestLibrary.TestFramework.LogError("002.3", "Unexpected exception: " + e); - retVal = false; - } - - return retVal; - } - public bool PosTest3() - { - bool retVal = true; - - TestLibrary.TestFramework.BeginScenario("PosTest3: check value which is not a number has a correct hashcode."); - - try - { - Single i1 = Single.NaN; - int expectValue = GetExpectValue(i1); - int actualValue = i1.GetHashCode(); - if (actualValue != expectValue) - { - TestLibrary.TestFramework.LogError("003.1", "GetHashCode return an error value. "); - retVal = false; - } - i1 = Single.NegativeInfinity; - expectValue = GetExpectValue(i1); - actualValue = i1.GetHashCode(); - if (actualValue != expectValue) - { - TestLibrary.TestFramework.LogError("003.2", "GetHashCode return an error value. "); - retVal = false; - } - i1 = Single.PositiveInfinity; - expectValue = GetExpectValue(i1); - actualValue = i1.GetHashCode(); - if (actualValue != expectValue) - { - TestLibrary.TestFramework.LogError("003.3", "GetHashCode return an error value. "); - retVal = false; - } - } - catch (Exception e) - { - TestLibrary.TestFramework.LogError("003.4", "Unexpected exception: " + e); - retVal = false; - } - - return retVal; - } - #endregion - - #endregion - - public static int Main() - { - SingleGetHashCode test = new SingleGetHashCode(); - - TestLibrary.TestFramework.BeginTestCase("SingleGetHashCode"); - - 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 unsafe int GetExpectValue(float myValue ) - { - int v = BitConverter.ToInt32(BitConverter.GetBytes(myValue), 0); - return v; - } - #endregion -} -- 2.7.4