aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs
diff options
context:
space:
mode:
authorJie Luo <jieluo@google.com>2017-12-19 11:54:11 -0800
committerJie Luo <jieluo@google.com>2017-12-19 15:38:02 -0800
commitb308580bb1c3f87a062ac1448a3e0bdaab9d40cf (patch)
treeea211f27b3deb05a9ba5461079288020a11b5c8d /csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs
parent3a06fe1fc9590b534f403114a0668befba926947 (diff)
downloadprotobuf-b308580bb1c3f87a062ac1448a3e0bdaab9d40cf.tar.gz
protobuf-b308580bb1c3f87a062ac1448a3e0bdaab9d40cf.tar.bz2
protobuf-b308580bb1c3f87a062ac1448a3e0bdaab9d40cf.zip
Cherrypick for csharp, including:
Add preserve UnknownFields Compare floating point values bitwise Add auto-generated header to C# generated files
Diffstat (limited to 'csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs')
-rw-r--r--csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs43
1 files changed, 43 insertions, 0 deletions
diff --git a/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs b/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs
index 68b4de45..8791dffc 100644
--- a/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs
+++ b/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs
@@ -540,6 +540,49 @@ namespace Google.Protobuf.Collections
Assert.Throws<ArgumentException>(() => map.ToString());
}
+ [Test]
+ public void NaNValuesComparedBitwise()
+ {
+ var map1 = new MapField<string, double>
+ {
+ { "x", SampleNaNs.Regular },
+ { "y", SampleNaNs.SignallingFlipped }
+ };
+
+ var map2 = new MapField<string, double>
+ {
+ { "x", SampleNaNs.Regular },
+ { "y", SampleNaNs.PayloadFlipped }
+ };
+
+ var map3 = new MapField<string, double>
+ {
+ { "x", SampleNaNs.Regular },
+ { "y", SampleNaNs.SignallingFlipped }
+ };
+
+ EqualityTester.AssertInequality(map1, map2);
+ EqualityTester.AssertEquality(map1, map3);
+ Assert.True(map1.Values.Contains(SampleNaNs.SignallingFlipped));
+ Assert.False(map2.Values.Contains(SampleNaNs.SignallingFlipped));
+ }
+
+ // This wouldn't usually happen, as protos can't use doubles as map keys,
+ // but let's be consistent.
+ [Test]
+ public void NaNKeysComparedBitwise()
+ {
+ var map = new MapField<double, string>
+ {
+ { SampleNaNs.Regular, "x" },
+ { SampleNaNs.SignallingFlipped, "y" }
+ };
+ Assert.AreEqual("x", map[SampleNaNs.Regular]);
+ Assert.AreEqual("y", map[SampleNaNs.SignallingFlipped]);
+ string ignored;
+ Assert.False(map.TryGetValue(SampleNaNs.PayloadFlipped, out ignored));
+ }
+
#if !NET35
[Test]
public void IDictionaryKeys_Equals_IReadOnlyDictionaryKeys()