From 187d411d70dbe142a45639edf5a4760537b028d2 Mon Sep 17 00:00:00 2001 From: Kevin Jones Date: Mon, 7 Mar 2016 18:16:03 -0500 Subject: [PATCH] Fix failing test in IntPtrGetHashCode. Test was not updated to reflect changes in GetHashCode. Fix dotnet/coreclr#3566 Commit migrated from https://github.com/dotnet/coreclr/commit/a1b04ccba4daed1378a157cace16a50ecf998a0b --- .../cti/system/intptr/intptrgethashcode.cs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/coreclr/tests/src/CoreMangLib/cti/system/intptr/intptrgethashcode.cs b/src/coreclr/tests/src/CoreMangLib/cti/system/intptr/intptrgethashcode.cs index 5f85489..ffc46c7 100644 --- a/src/coreclr/tests/src/CoreMangLib/cti/system/intptr/intptrgethashcode.cs +++ b/src/coreclr/tests/src/CoreMangLib/cti/system/intptr/intptrgethashcode.cs @@ -67,9 +67,25 @@ public class IntPtrGetHashCode { byte* mem = stackalloc byte[1024]; System.IntPtr ip = new IntPtr((void*)mem); - if (ip.GetHashCode() != (int)mem) + if (System.IntPtr.Size == 4) + { + if (ip.GetHashCode() != (int)mem) + { + TestLibrary.TestFramework.LogError("002", "expect IntPtr.GetHashCode() equals the address"); + retVal = false; + } + } + else if (System.IntPtr.Size == 8) + { + if (ip.GetHashCode() != ((int)mem ^ (int)((long)mem >> 32))) + { + TestLibrary.TestFramework.LogError("002", "expect IntPtr.GetHashCode() equals the address xor halves"); + retVal = false; + } + } + else { - TestLibrary.TestFramework.LogError("002", "expect IntPtr.GetHashCode() equals the address"); + TestLibrary.TestFramework.LogError("002", "Unexpected IntPtr.Size: " + System.IntPtr.Size); retVal = false; } } -- 2.7.4