aboutsummaryrefslogtreecommitdiffhomepage
path: root/csharp/src/Google.Protobuf.Test
diff options
context:
space:
mode:
authorGravatar Jon Skeet <jonskeet@google.com>2016-12-16 10:42:13 +0000
committerGravatar Jon Skeet <skeet@pobox.com>2016-12-16 12:04:40 +0000
commitb18bc9b9448d8c97b289f03a3cbad57191f30fad (patch)
treeb4c469aec79178964fd6a51c91f17d57122b75f3 /csharp/src/Google.Protobuf.Test
parenta95e38ce8dec20d327692f4f5c2b0d37d6776696 (diff)
Give C# ByteString a sensible GetHashCode implementation.
Fixes #2511.
Diffstat (limited to 'csharp/src/Google.Protobuf.Test')
-rw-r--r--csharp/src/Google.Protobuf.Test/ByteStringTest.cs13
1 files changed, 13 insertions, 0 deletions
diff --git a/csharp/src/Google.Protobuf.Test/ByteStringTest.cs b/csharp/src/Google.Protobuf.Test/ByteStringTest.cs
index 685e130a..ff2444a3 100644
--- a/csharp/src/Google.Protobuf.Test/ByteStringTest.cs
+++ b/csharp/src/Google.Protobuf.Test/ByteStringTest.cs
@@ -167,5 +167,18 @@ namespace Google.Protobuf
// Optimization which also fixes issue 61.
Assert.AreSame(ByteString.Empty, ByteString.FromBase64(""));
}
+
+ [Test]
+ public void GetHashCode_Regression()
+ {
+ // We used to have an awful hash algorithm where only the last four
+ // bytes were relevant. This is a regression test for
+ // https://github.com/google/protobuf/issues/2511
+
+ ByteString b1 = ByteString.CopyFrom(100, 1, 2, 3, 4);
+ ByteString b2 = ByteString.CopyFrom(200, 1, 2, 3, 4);
+ Assert.AreNotEqual(b1.GetHashCode(), b2.GetHashCode());
+ }
+
}
} \ No newline at end of file