Skip to content

Commit

Permalink
Add tests for ValueType.GetHashCode
Browse files Browse the repository at this point in the history
  • Loading branch information
jkotas committed Feb 24, 2018
1 parent 933ad99 commit 22b971c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/System.Runtime/tests/System/ValueTypeTests.cs
Expand Up @@ -28,6 +28,7 @@ public static void StructWithDoubleFieldNotTightlyPackedZeroCompareTest()
obj2.value2 = -0.0;

Assert.True(obj1.Equals(obj2));
Assert.Equal(obj1.GetHashCode(), obj2.GetHashCode());
}

[Fact]
Expand All @@ -43,6 +44,7 @@ public static void StructWithDoubleFieldTightlyPackedZeroCompareTest()
obj2.value2 = -0.0;

Assert.True(obj1.Equals(obj2));
Assert.Equal(obj1.GetHashCode(), obj2.GetHashCode());
}

[Fact]
Expand All @@ -57,6 +59,7 @@ public static void StructWithDoubleFieldNotTightlyPackedNaNCompareTest()
obj2.value2 = -double.NaN;

Assert.True(obj1.Equals(obj2));
// Assert.Equal(obj1.GetHashCode(), obj2.GetHashCode()); // https://github.com/dotnet/coreclr/issues/6237
}

[Fact]
Expand All @@ -72,6 +75,7 @@ public static void StructWithDoubleFieldTightlyPackedNaNCompareTest()
obj2.value2 = -double.NaN;

Assert.True(obj1.Equals(obj2));
// Assert.Equal(obj1.GetHashCode(), obj2.GetHashCode()); // https://github.com/dotnet/coreclr/issues/6237
}

[Fact]
Expand All @@ -86,6 +90,7 @@ public static void StructWithNestedDoubleFieldNotTightlyPackedZeroCompareTest()
obj2.value2.value2 = -0.0;

Assert.True(obj1.Equals(obj2));
Assert.Equal(obj1.GetHashCode(), obj2.GetHashCode());
}

[Fact]
Expand All @@ -101,6 +106,7 @@ public static void StructWithNestedDoubleFieldTightlyPackedZeroCompareTest()
obj2.value2.value2 = -0.0;

Assert.True(obj1.Equals(obj2));
Assert.Equal(obj1.GetHashCode(), obj2.GetHashCode());
}

[Fact]
Expand All @@ -115,6 +121,7 @@ public static void StructWithNestedDoubleFieldNotTightlyPackedNaNCompareTest()
obj2.value2.value2 = -double.NaN;

Assert.True(obj1.Equals(obj2));
// Assert.Equal(obj1.GetHashCode(), obj2.GetHashCode()); // https://github.com/dotnet/coreclr/issues/6237
}

[Fact]
Expand All @@ -130,6 +137,7 @@ public static void StructWithNestedDoubleFieldTightlyPackedNaNCompareTest()
obj2.value2.value2 = -double.NaN;

Assert.True(obj1.Equals(obj2));
// Assert.Equal(obj1.GetHashCode(), obj2.GetHashCode()); // https://github.com/dotnet/coreclr/issues/6237
}

[Fact]
Expand All @@ -144,6 +152,7 @@ public static void StructWithFloatFieldNotTightlyPackedZeroCompareTest()
obj2.value2 = 1;

Assert.True(obj1.Equals(obj2));
Assert.Equal(obj1.GetHashCode(), obj2.GetHashCode());
}

[Fact]
Expand All @@ -159,6 +168,7 @@ public static void StructWithFloatFieldTightlyPackedZeroCompareTest()
obj2.value2 = 1;

Assert.True(obj1.Equals(obj2));
Assert.Equal(obj1.GetHashCode(), obj2.GetHashCode());
}

[Fact]
Expand All @@ -173,6 +183,7 @@ public static void StructWithFloatFieldNotTightlyPackedNaNCompareTest()
obj2.value2 = 1;

Assert.True(obj1.Equals(obj2));
// Assert.Equal(obj1.GetHashCode(), obj2.GetHashCode()); // https://github.com/dotnet/coreclr/issues/6237
}

[Fact]
Expand All @@ -188,6 +199,7 @@ public static void StructWithFloatFieldTightlyPackedNaNCompareTest()
obj2.value2 = 1;

Assert.True(obj1.Equals(obj2));
// Assert.Equal(obj1.GetHashCode(), obj2.GetHashCode()); // https://github.com/dotnet/coreclr/issues/6237
}

[Fact]
Expand All @@ -202,6 +214,7 @@ public static void StructWithNestedFloatFieldNotTightlyPackedZeroCompareTest()
obj2.value2.value2 = 1;

Assert.True(obj1.Equals(obj2));
// Assert.Equal(obj1.GetHashCode(), obj2.GetHashCode()); // https://github.com/dotnet/coreclr/issues/6237
}

[Fact]
Expand All @@ -217,6 +230,7 @@ public static void StructWithNestedFloatFieldTightlyPackedZeroCompareTest()
obj2.value2.value2 = 1;

Assert.True(obj1.Equals(obj2));
Assert.Equal(obj1.GetHashCode(), obj2.GetHashCode());
}

[Fact]
Expand All @@ -231,6 +245,7 @@ public static void StructWithNestedFloatFieldNotTightlyPackedNaNCompareTest()
obj2.value2.value2 = 1;

Assert.True(obj1.Equals(obj2));
// Assert.Equal(obj1.GetHashCode(), obj2.GetHashCode()); // https://github.com/dotnet/coreclr/issues/6237
}

[Fact]
Expand All @@ -246,6 +261,7 @@ public static void StructWithNestedFloatFieldTightlyPackedNaNCompareTest()
obj2.value2.value2 = 1;

Assert.True(obj1.Equals(obj2));
// Assert.Equal(obj1.GetHashCode(), obj2.GetHashCode()); // https://github.com/dotnet/coreclr/issues/6237
}

[Fact]
Expand All @@ -260,6 +276,7 @@ public static void StructWithoutNestedOverriddenEqualsCompareTest()
obj2.value2.value = 2;

Assert.True(obj1.Equals(obj2));
Assert.Equal(obj1.GetHashCode(), obj2.GetHashCode());
}

[Fact]
Expand All @@ -275,6 +292,7 @@ public static void StructWithNestedOverriddenEqualsCompareTest()
obj2.value2.value = 2;

Assert.False(obj1.Equals(obj2));
Assert.Equal(obj1.GetHashCode(), obj2.GetHashCode());
}

[Fact]
Expand All @@ -289,6 +307,7 @@ public static void StructContainsPointerCompareTest()
obj2.value2 = -0.0;

Assert.True(obj1.Equals(obj2));
Assert.Equal(obj1.GetHashCode(), obj2.GetHashCode());
}

public struct S
Expand Down

0 comments on commit 22b971c

Please sign in to comment.