From 958ee47afec243f91ee3e239e0437b48483ed944 Mon Sep 17 00:00:00 2001 From: Peter Occil Date: Tue, 18 Jan 2022 18:32:41 -0500 Subject: [PATCH] Version 4.5.2 --- CBOR.nuspec | 2 +- CBORTest/CBORGenerator.cs | 16 +- CBORTest/CBORObjectTest.cs | 2306 ++++++++++++++++++------------------ 3 files changed, 1162 insertions(+), 1162 deletions(-) diff --git a/CBOR.nuspec b/CBOR.nuspec index de952a69..3090c0f1 100644 --- a/CBOR.nuspec +++ b/CBOR.nuspec @@ -16,4 +16,4 @@ Version 4.5: - Add support for deserializing CBOR objects to IReadOnlyList, IReadOnlyCollection, and ReadOnlyDictionary Note that after version 4.5x, the CBOR library's repository will stop including special projects for .NET 2.0 and .NET 4.0, leaving the .NET-Standard project for building the library.CC0-1.0https://github.com/peteroupc/CBORPeter OccilA C# implementation of Concise Binary Object Representation (CBOR), a general-purpose binary data format defined in RFC 8949.Peter OccilCBOR (Concise Binary Object Representation)cbor data serialization binary json +> \ No newline at end of file diff --git a/CBORTest/CBORGenerator.cs b/CBORTest/CBORGenerator.cs index b6916eb0..b69ee8fb 100644 --- a/CBORTest/CBORGenerator.cs +++ b/CBORTest/CBORGenerator.cs @@ -142,19 +142,19 @@ private void GenerateSmall(IRandomGenExtended r, int depth, ByteWriter bs) { GenerateArgument(r, 0, r.GetInt32(100), bs); } else if (v < 35) { bs.Write(0x41); - bs.Write(0x20); + bs.Write(0x20); } else if (v < 45) { bs.Write(0x41); - bs.Write(0x20); + bs.Write(0x20); } else if (v < 50) { bs.Write(0x81); - this.GenerateSmall(r, depth + 1, bs); + this.GenerateSmall(r, depth + 1, bs); } else if (v < 53) { bs.Write(0xa2); - bs.Write(0xf7); - bs.Write(0xf6); - this.GenerateSmall(r, depth + 1, bs); - bs.Write(0xf5); + bs.Write(0xf7); + bs.Write(0xf6); + this.GenerateSmall(r, depth + 1, bs); + bs.Write(0xf5); } else if (v < 80) { bs.Write(r.GetInt32(0x40)); } else if (v < 100) { @@ -291,4 +291,4 @@ public byte[] Generate(IRandomGenExtended random) { return ret; } } -} +} \ No newline at end of file diff --git a/CBORTest/CBORObjectTest.cs b/CBORTest/CBORObjectTest.cs index 83734a45..3849e3d9 100644 --- a/CBORTest/CBORObjectTest.cs +++ b/CBORTest/CBORObjectTest.cs @@ -2183,16 +2183,16 @@ public void TestEncodeFloat64() { } public static readonly int[] EtbRanges = { - -24, 23, 1, - -256, -25, 2, - 24, 255, 2, - 256, 266, 3, - -266, -257, 3, - 65525, 65535, 3, - -65536, -65525, 3, - 65536, 65546, 5, - -65547, -65537, 5, - }; + 0 - 24, 23, 1, + -256, -25, 2, + 24, 255, 2, + 256, 266, 3, + -266, -257, 3, + 65525, 65535, 3, + -65536, -65525, 3, + 65536, 65546, 5, + -65547, -65537, 5, + }; [Test] public void TestEncodeToBytes() { @@ -4183,9 +4183,9 @@ public void TestReadJSON() { } } using (var ms = new MemoryStream(new byte[] { - 0xef, 0xbb, 0xbf, - 0x7b, 0x7d, - })) { + 0xef, 0xbb, 0xbf, + 0x7b, 0x7d, + })) { try { CBORObject.ReadJSON(ms); } catch (Exception ex) { @@ -4195,9 +4195,9 @@ public void TestReadJSON() { } // whitespace followed by BOM using (var ms2 = new MemoryStream(new byte[] { - 0x20, 0xef, 0xbb, - 0xbf, 0x7b, 0x7d, - })) { + 0x20, 0xef, 0xbb, + 0xbf, 0x7b, 0x7d, + })) { try { CBORObject.ReadJSON(ms2); Assert.Fail("Should have failed"); @@ -4232,9 +4232,9 @@ public void TestReadJSON() { } // two BOMs using (var ms3 = new MemoryStream(new byte[] { - 0xef, 0xbb, 0xbf, - 0xef, 0xbb, 0xbf, 0x7b, 0x7d, - })) { + 0xef, 0xbb, 0xbf, + 0xef, 0xbb, 0xbf, 0x7b, 0x7d, + })) { try { CBORObject.ReadJSON(ms3); Assert.Fail("Should have failed"); @@ -4246,82 +4246,82 @@ public void TestReadJSON() { } } using (var msjson = new MemoryStream(new byte[] { - 0, 0, 0xfe, 0xff, 0, - 0, - 0, - 0x74, 0, 0, 0, 0x72, 0, 0, 0, 0x75, 0, 0, 0, - 0x65, - })) { + 0, 0, 0xfe, 0xff, 0, + 0, + 0, + 0x74, 0, 0, 0, 0x72, 0, 0, 0, 0x75, 0, 0, 0, + 0x65, + })) { Assert.AreEqual(CBORObject.True, CBORObject.ReadJSON(msjson)); } using (var msjson = new MemoryStream(new byte[] { - 0, 0, 0, 0x74, 0, 0, - 0, 0x72, 0, - 0, 0, 0x75, 0, 0, 0, 0x65, - })) { + 0, 0, 0, 0x74, 0, 0, + 0, 0x72, 0, + 0, 0, 0x75, 0, 0, 0, 0x65, + })) { Assert.AreEqual(CBORObject.True, CBORObject.ReadJSON(msjson)); } using (var msjson = new MemoryStream(new byte[] { - 0xff, 0xfe, 0, 0, - 0x74, 0, 0, 0, - 0x72, 0, 0, 0, 0x75, 0, 0, 0, 0x65, 0, 0, 0, - })) { + 0xff, 0xfe, 0, 0, + 0x74, 0, 0, 0, + 0x72, 0, 0, 0, 0x75, 0, 0, 0, 0x65, 0, 0, 0, + })) { Assert.AreEqual(CBORObject.True, CBORObject.ReadJSON(msjson)); } using (var msjson = new MemoryStream(new byte[] { - 0x74, 0, 0, 0, 0x72, - 0, - 0, - 0, - 0x75, 0, 0, 0, 0x65, 0, 0, 0, - })) { + 0x74, 0, 0, 0, 0x72, + 0, + 0, + 0, + 0x75, 0, 0, 0, 0x65, 0, 0, 0, + })) { Assert.AreEqual(CBORObject.True, CBORObject.ReadJSON(msjson)); } using (var msjson = new MemoryStream(new byte[] { - 0xfe, 0xff, 0, 0x74, - 0, 0x72, 0, - 0x75, 0, 0x65, - })) { + 0xfe, 0xff, 0, 0x74, + 0, 0x72, 0, + 0x75, 0, 0x65, + })) { Assert.AreEqual(CBORObject.True, CBORObject.ReadJSON(msjson)); } using (var msjson = new MemoryStream(new byte[] { - 0, 0x74, 0, 0x72, 0, - 0x75, 0, 0x65, - })) { + 0, 0x74, 0, 0x72, 0, + 0x75, 0, 0x65, + })) { Assert.AreEqual(CBORObject.True, CBORObject.ReadJSON(msjson)); } using (var msjson = new MemoryStream(new byte[] { - 0xff, 0xfe, 0x74, 0, - 0x72, - 0, - 0x75, - 0, 0x65, 0, - })) { + 0xff, 0xfe, 0x74, 0, + 0x72, + 0, + 0x75, + 0, 0x65, 0, + })) { Assert.AreEqual(CBORObject.True, CBORObject.ReadJSON(msjson)); } using (var msjson = new MemoryStream(new byte[] { - 0x74, 0, 0x72, 0, - 0x75, 0, 0x65, 0, - })) { + 0x74, 0, 0x72, 0, + 0x75, 0, 0x65, 0, + })) { Assert.AreEqual(CBORObject.True, CBORObject.ReadJSON(msjson)); } using (var msjson = new MemoryStream(new byte[] { - 0xef, 0xbb, 0xbf, - 0x74, 0x72, 0x75, 0x65, - })) { + 0xef, 0xbb, 0xbf, + 0x74, 0x72, 0x75, 0x65, + })) { Assert.AreEqual(CBORObject.True, CBORObject.ReadJSON(msjson)); } using (var msjson = new MemoryStream(new byte[] { - 0x74, 0x72, 0x75, - 0x65, - })) { + 0x74, 0x72, 0x75, + 0x65, + })) { Assert.AreEqual(CBORObject.True, CBORObject.ReadJSON(msjson)); } using (var msjson = new MemoryStream(new byte[] { - 0, 0, 0xfe, 0xff, 0, - 0, 0, 0x22, - 0, 1, 0, 0, 0, 0, 0, 0x22, - })) { + 0, 0, 0xfe, 0xff, 0, + 0, 0, 0x22, + 0, 1, 0, 0, 0, 0, 0, 0x22, + })) { { string stringTemp = CBORObject.ReadJSON(msjson).AsString(); Assert.AreEqual( @@ -4330,10 +4330,10 @@ public void TestReadJSON() { } } using (var msjson = new MemoryStream(new byte[] { - 0, 0, 0, 0x22, 0, 1, - 0, 0, 0, 0, - 0, 0x22, - })) { + 0, 0, 0, 0x22, 0, 1, + 0, 0, 0, 0, + 0, 0x22, + })) { { string stringTemp = CBORObject.ReadJSON(msjson).AsString(); Assert.AreEqual( @@ -4342,10 +4342,10 @@ public void TestReadJSON() { } } using (var msjson = new MemoryStream(new byte[] { - 0xff, 0xfe, 0, 0, - 0x22, 0, 0, 0, - 0, 0, 1, 0, 0x22, 0, 0, 0, - })) { + 0xff, 0xfe, 0, 0, + 0x22, 0, 0, 0, + 0, 0, 1, 0, 0x22, 0, 0, 0, + })) { { string stringTemp = CBORObject.ReadJSON(msjson).AsString(); Assert.AreEqual( @@ -4354,11 +4354,11 @@ public void TestReadJSON() { } } using (var msjson = new MemoryStream(new byte[] { - 0x22, 0, 0, 0, 0, 0, - 1, 0, 0x22, - 0, - 0, 0, - })) { + 0x22, 0, 0, 0, 0, 0, + 1, 0, 0x22, + 0, + 0, 0, + })) { { string stringTemp = CBORObject.ReadJSON(msjson).AsString(); Assert.AreEqual( @@ -4367,11 +4367,11 @@ public void TestReadJSON() { } } using (var msjson = new MemoryStream(new byte[] { - 0xfe, 0xff, 0, - 0x22, 0xd8, - 0, - 0xdc, 0, 0, 0x22, - })) { + 0xfe, 0xff, 0, + 0x22, 0xd8, + 0, + 0xdc, 0, 0, 0x22, + })) { { string stringTemp = CBORObject.ReadJSON(msjson).AsString(); Assert.AreEqual( @@ -4380,9 +4380,9 @@ public void TestReadJSON() { } } using (var msjson = new MemoryStream(new byte[] { - 0, 0x22, 0xd8, 0, - 0xdc, 0, 0, 0x22, - })) { + 0, 0x22, 0xd8, 0, + 0xdc, 0, 0, 0x22, + })) { { string stringTemp = CBORObject.ReadJSON(msjson).AsString(); Assert.AreEqual( @@ -4391,10 +4391,10 @@ public void TestReadJSON() { } } using (var msjson = new MemoryStream(new byte[] { - 0xff, 0xfe, 0x22, 0, - 0, 0xd8, 0, - 0xdc, 0x22, 0, - })) { + 0xff, 0xfe, 0x22, 0, + 0, 0xd8, 0, + 0xdc, 0x22, 0, + })) { { string stringTemp = CBORObject.ReadJSON(msjson).AsString(); Assert.AreEqual( @@ -4403,9 +4403,9 @@ public void TestReadJSON() { } } using (var msjson = new MemoryStream(new byte[] { - 0x22, 0, 0, 0xd8, 0, - 0xdc, 0x22, 0, - })) { + 0x22, 0, 0, 0xd8, 0, + 0xdc, 0x22, 0, + })) { { string stringTemp = CBORObject.ReadJSON(msjson).AsString(); Assert.AreEqual( @@ -4414,10 +4414,10 @@ public void TestReadJSON() { } } using (var msjson = new MemoryStream(new byte[] { - 0, 0, 0xfe, 0xff, 0, - 0, 0, 0x22, - 0, 0, 0xd8, 0, 0, 0, 0, 0x22, - })) { + 0, 0, 0xfe, 0xff, 0, + 0, 0, 0x22, + 0, 0, 0xd8, 0, 0, 0, 0, 0x22, + })) { try { CBORObject.ReadJSON(msjson); Assert.Fail("Should have failed"); @@ -4429,11 +4429,11 @@ public void TestReadJSON() { } } using (var msjson = new MemoryStream(new byte[] { - 0, 0, 0, 0x22, 0, 0, - 0xd8, 0, 0, - 0, - 0, 0x22, - })) { + 0, 0, 0, 0x22, 0, 0, + 0xd8, 0, 0, + 0, + 0, 0x22, + })) { try { CBORObject.ReadJSON(msjson); Assert.Fail("Should have failed"); @@ -4445,10 +4445,10 @@ public void TestReadJSON() { } } using (var msjson = new MemoryStream(new byte[] { - 0xff, 0xfe, 0, 0, - 0x22, 0, 0, 0, - 0, 0xd8, 0, 0, 0x22, 0, 0, 0, - })) { + 0xff, 0xfe, 0, 0, + 0x22, 0, 0, 0, + 0, 0xd8, 0, 0, 0x22, 0, 0, 0, + })) { try { CBORObject.ReadJSON(msjson); Assert.Fail("Should have failed"); @@ -4460,12 +4460,12 @@ public void TestReadJSON() { } } using (var msjson = new MemoryStream(new byte[] { - 0x22, 0, 0, 0, 0, - 0xd8, - 0, - 0, - 0x22, 0, 0, 0, - })) { + 0x22, 0, 0, 0, 0, + 0xd8, + 0, + 0, + 0x22, 0, 0, 0, + })) { try { CBORObject.ReadJSON(msjson); Assert.Fail("Should have failed"); @@ -4477,10 +4477,10 @@ public void TestReadJSON() { } } using (var msjson = new MemoryStream(new byte[] { - 0xfe, 0xff, 0, 0x22, - 0, 0xdc, 0, - 0xdc, 0, 0, 0x22, - })) { + 0xfe, 0xff, 0, 0x22, + 0, 0xdc, 0, + 0xdc, 0, 0, 0x22, + })) { try { CBORObject.ReadJSON(msjson); Assert.Fail("Should have failed"); @@ -4492,10 +4492,10 @@ public void TestReadJSON() { } } using (var msjson = new MemoryStream(new byte[] { - 0, 0x22, 0, 0xdc, 0, - 0xdc, 0, 0, - 0x22, - })) { + 0, 0x22, 0, 0xdc, 0, + 0xdc, 0, 0, + 0x22, + })) { try { CBORObject.ReadJSON(msjson); Assert.Fail("Should have failed"); @@ -4507,10 +4507,10 @@ public void TestReadJSON() { } } using (var msjson = new MemoryStream(new byte[] { - 0xff, 0xfe, 0x22, 0, - 0, 0xdc, 0, - 0xdc, 0x22, 0, - })) { + 0xff, 0xfe, 0x22, 0, + 0, 0xdc, 0, + 0xdc, 0x22, 0, + })) { try { CBORObject.ReadJSON(msjson); Assert.Fail("Should have failed"); @@ -4522,9 +4522,9 @@ public void TestReadJSON() { } } using (var msjson = new MemoryStream(new byte[] { - 0x22, 0, 0, 0xdc, 0, - 0xdc, 0x22, 0, - })) { + 0x22, 0, 0, 0xdc, 0, + 0xdc, 0x22, 0, + })) { try { CBORObject.ReadJSON(msjson); Assert.Fail("Should have failed"); @@ -4559,9 +4559,9 @@ public void TestReadJSON() { } // Illegal UTF-16 using (var msjson = new MemoryStream(new byte[] { - 0xfe, 0xff, 0x20, - 0x20, 0x20, - })) { + 0xfe, 0xff, 0x20, + 0x20, 0x20, + })) { try { CBORObject.ReadJSON(msjson); Assert.Fail("Should have failed"); @@ -4573,9 +4573,9 @@ public void TestReadJSON() { } } using (var msjson = new MemoryStream(new byte[] { - 0xff, 0xfe, 0x20, - 0x20, 0x20, - })) { + 0xff, 0xfe, 0x20, + 0x20, 0x20, + })) { try { CBORObject.ReadJSON(msjson); Assert.Fail("Should have failed"); @@ -4587,9 +4587,9 @@ public void TestReadJSON() { } } using (var msjson = new MemoryStream(new byte[] { - 0xfe, 0xff, 0xd8, - 0x00, - })) { + 0xfe, 0xff, 0xd8, + 0x00, + })) { try { CBORObject.ReadJSON(msjson); Assert.Fail("Should have failed"); @@ -4601,9 +4601,9 @@ public void TestReadJSON() { } } using (var msjson = new MemoryStream(new byte[] { - 0xfe, 0xff, 0xdc, - 0x00, - })) { + 0xfe, 0xff, 0xdc, + 0x00, + })) { try { CBORObject.ReadJSON(msjson); Assert.Fail("Should have failed"); @@ -4615,9 +4615,9 @@ public void TestReadJSON() { } } using (var msjson = new MemoryStream(new byte[] { - 0xfe, 0xff, 0xd8, - 0x00, 0x20, 0x00, - })) { + 0xfe, 0xff, 0xd8, + 0x00, 0x20, 0x00, + })) { try { CBORObject.ReadJSON(msjson); Assert.Fail("Should have failed"); @@ -4629,9 +4629,9 @@ public void TestReadJSON() { } } using (var msjson = new MemoryStream(new byte[] { - 0xfe, 0xff, 0xdc, - 0x00, 0x20, 0x00, - })) { + 0xfe, 0xff, 0xdc, + 0x00, 0x20, 0x00, + })) { try { CBORObject.ReadJSON(msjson); Assert.Fail("Should have failed"); @@ -4643,9 +4643,9 @@ public void TestReadJSON() { } } using (var msjson = new MemoryStream(new byte[] { - 0xfe, 0xff, 0xd8, - 0x00, 0xd8, 0x00, - })) { + 0xfe, 0xff, 0xd8, + 0x00, 0xd8, 0x00, + })) { try { CBORObject.ReadJSON(msjson); Assert.Fail("Should have failed"); @@ -4657,9 +4657,9 @@ public void TestReadJSON() { } } using (var msjson = new MemoryStream(new byte[] { - 0xfe, 0xff, 0xdc, - 0x00, 0xd8, 0x00, - })) { + 0xfe, 0xff, 0xdc, + 0x00, 0xd8, 0x00, + })) { try { CBORObject.ReadJSON(msjson); Assert.Fail("Should have failed"); @@ -4671,9 +4671,9 @@ public void TestReadJSON() { } } using (var msjson = new MemoryStream(new byte[] { - 0xfe, 0xff, 0xdc, - 0x00, 0xd8, 0x00, 0xdc, 0x00, - })) { + 0xfe, 0xff, 0xdc, + 0x00, 0xd8, 0x00, 0xdc, 0x00, + })) { try { CBORObject.ReadJSON(msjson); Assert.Fail("Should have failed"); @@ -4685,9 +4685,9 @@ public void TestReadJSON() { } } using (var msjson = new MemoryStream(new byte[] { - 0xfe, 0xff, 0xdc, - 0x00, 0xdc, 0x00, - })) { + 0xfe, 0xff, 0xdc, + 0x00, 0xdc, 0x00, + })) { try { CBORObject.ReadJSON(msjson); Assert.Fail("Should have failed"); @@ -4700,9 +4700,9 @@ public void TestReadJSON() { } using (var msjson = new MemoryStream(new byte[] { - 0xff, 0xfe, 0x00, - 0xd8, - })) { + 0xff, 0xfe, 0x00, + 0xd8, + })) { try { CBORObject.ReadJSON(msjson); Assert.Fail("Should have failed"); @@ -4714,9 +4714,9 @@ public void TestReadJSON() { } } using (var msjson = new MemoryStream(new byte[] { - 0xff, 0xfe, 0x00, - 0xdc, - })) { + 0xff, 0xfe, 0x00, + 0xdc, + })) { try { CBORObject.ReadJSON(msjson); Assert.Fail("Should have failed"); @@ -4728,9 +4728,9 @@ public void TestReadJSON() { } } using (var msjson = new MemoryStream(new byte[] { - 0xff, 0xfe, 0x00, - 0xd8, 0x00, 0x20, - })) { + 0xff, 0xfe, 0x00, + 0xd8, 0x00, 0x20, + })) { try { CBORObject.ReadJSON(msjson); Assert.Fail("Should have failed"); @@ -4742,9 +4742,9 @@ public void TestReadJSON() { } } using (var msjson = new MemoryStream(new byte[] { - 0xff, 0xfe, 0x00, - 0xdc, 0x00, 0x20, - })) { + 0xff, 0xfe, 0x00, + 0xdc, 0x00, 0x20, + })) { try { CBORObject.ReadJSON(msjson); Assert.Fail("Should have failed"); @@ -4756,9 +4756,9 @@ public void TestReadJSON() { } } using (var msjson = new MemoryStream(new byte[] { - 0xff, 0xfe, 0x00, - 0xd8, 0x00, 0xd8, - })) { + 0xff, 0xfe, 0x00, + 0xd8, 0x00, 0xd8, + })) { try { CBORObject.ReadJSON(msjson); Assert.Fail("Should have failed"); @@ -4770,9 +4770,9 @@ public void TestReadJSON() { } } using (var msjson = new MemoryStream(new byte[] { - 0xff, 0xfe, 0x00, - 0xdc, 0x00, 0xd8, - })) { + 0xff, 0xfe, 0x00, + 0xdc, 0x00, 0xd8, + })) { try { CBORObject.ReadJSON(msjson); Assert.Fail("Should have failed"); @@ -4784,9 +4784,9 @@ public void TestReadJSON() { } } using (var msjson = new MemoryStream(new byte[] { - 0xff, 0xfe, 0x00, - 0xdc, 0x00, 0xd8, 0x00, 0xdc, - })) { + 0xff, 0xfe, 0x00, + 0xdc, 0x00, 0xd8, 0x00, 0xdc, + })) { try { CBORObject.ReadJSON(msjson); Assert.Fail("Should have failed"); @@ -4798,9 +4798,9 @@ public void TestReadJSON() { } } using (var msjson = new MemoryStream(new byte[] { - 0xff, 0xfe, 0x00, - 0xdc, 0x00, 0xdc, - })) { + 0xff, 0xfe, 0x00, + 0xdc, 0x00, 0xdc, + })) { try { CBORObject.ReadJSON(msjson); Assert.Fail("Should have failed"); @@ -4814,8 +4814,8 @@ public void TestReadJSON() { // Illegal UTF-32 using (var msjson = new MemoryStream(new byte[] { - 0, 0, 0, 0x20, 0, - })) { + 0, 0, 0, 0x20, 0, + })) { try { CBORObject.ReadJSON(msjson); Assert.Fail("Should have failed"); @@ -9343,8 +9343,8 @@ public void TestFromJsonStringEDecimalSpec() { } double dbl = ed.ToDouble(); if (Double.IsPositiveInfinity(dbl) || - Double.IsNegativeInfinity(dbl) || - Double.IsNaN(dbl)) { + Double.IsNegativeInfinity(dbl) || + Double.IsNaN(dbl)) { continue; } AssertJSONDouble( @@ -9721,313 +9721,313 @@ public void TestFromJsonStringLongKindIntOrFloat2() { Assert.IsTrue(cbor.AsDoubleValue() == Double.NegativeInfinity); } -[Test] -public void TestRoundTripRegressions() { -{ -var options = new CBOREncodeOptions("allowduplicatekeys=1;keepkeyorder=1"); -var bytes = new byte[] { - (byte)0xba, 0x00, 0x00, 0x00, 0x03, - (byte)0xf9, - (byte)0x83, 0x1d, - (byte)0xda, - (byte)0xb6, - (byte)0xda, 0x50, 0x56, 0x1a, 0x50, - (byte)0xe3, 0x2c, 0x7a, 0x16, - (byte)0xfa, 0x50, 0x32, 0x73, 0x07, - (byte)0xfa, (byte)0xb9, 0x2d, 0x73, (byte)0xce, 0x38, (byte)0xd0, -}; -CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(bytes, options)); -} -{ -var options = new CBOREncodeOptions("allowduplicatekeys=1;keepkeyorder=1"); -var bytes = new byte[] { - (byte)0xbf, - (byte)0x9f, - (byte)0xbf, 0x39, 0x20, - (byte)0x8f, 0x4a, 0x1f, 0x46, 0x26, 0x0b, 0x3e, 0x72, 0x2c, 0x7f, 0x11, - 0x2e, 0x39, - (byte)0x9d, - (byte)0xba, 0x1a, 0x11, - (byte)0x8d, - (byte)0xc0, - (byte)0xb4, 0x38, - (byte)0xb6, - (byte)0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - (byte)0xd8, 0x3b, - (byte)0x99, 0x00, 0x02, 0x3b, 0x05, - (byte)0xbb, - (byte)0xea, - (byte)0x8e, 0x4b, - (byte)0xd3, 0x5e, 0x22, - (byte)0x9f, 0x59, 0x00, 0x00, - (byte)0xbb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x41, 0x20, - (byte)0xbf, 0x1a, 0x00, 0x00, 0x00, 0x61, - (byte)0xb9, 0x00, 0x01, 0x1a, 0x00, 0x00, 0x00, 0x0e, - (byte)0xba, 0x00, 0x00, 0x00, 0x00, - (byte)0xff, - (byte)0xff, - (byte)0xff, - (byte)0xd8, 0x22, - (byte)0xf8, - (byte)0x93, - (byte)0xd9, - (byte)0xaf, 0x33, 0x19, - (byte)0xf0, - (byte)0xf0, - (byte)0xf9, - (byte)0x85, - (byte)0x93, - (byte)0x99, 0x00, 0x01, 0x3a, - (byte)0xb5, - (byte)0xfb, 0x4d, 0x43, - (byte)0x98, 0x00, - (byte)0xff, (byte)0xfa, (byte)0xb0, (byte)0xb4, (byte)0xdc, 0x6d, - (byte)0xff, -}; -CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(bytes, options)); -} -{ -var options = new CBOREncodeOptions("allowduplicatekeys=1;keepkeyorder=1"); -var bytes = new byte[] { - (byte)0xdb, 0x0d, - (byte)0xcb, 0x5d, 0x78, - (byte)0x92, - (byte)0xc2, - (byte)0xc7, 0x2b, - (byte)0xb9, 0x00, 0x02, 0x39, - (byte)0xee, - (byte)0xa0, (byte)0xa0, 0x1a, 0x0e, (byte)0xd9, (byte)0xec, (byte)0xca, - (byte)0xf2, -}; -CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(bytes, options)); -} -{ -var options = new CBOREncodeOptions("allowduplicatekeys=1;keepkeyorder=1"); -var bytes = new byte[] { - (byte)0xbf, - (byte)0xfb, - (byte)0xb1, 0x21, - (byte)0x93, - (byte)0x8c, - (byte)0xc6, - (byte)0xf3, - (byte)0xcf, - (byte)0xb7, (byte)0xf8, 0x76, 0x18, (byte)0xda, 0x39, 0x60, (byte)0xf4, - (byte)0xff, -}; -CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(bytes, options)); -} -{ -var options = new CBOREncodeOptions("allowduplicatekeys=1;keepkeyorder=1"); -var bytes = new byte[] { - (byte)0xbb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x02, (byte)0xf0, 0x0d, 0x2a, 0x21, -}; -CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(bytes, options)); -} -{ -var options = new CBOREncodeOptions("allowduplicatekeys=1;keepkeyorder=1"); -var bytes = new byte[] { - (byte)0xba, 0x00, 0x00, 0x00, 0x02, - (byte)0xf9, 0x48, 0x37, - (byte)0xda, - (byte)0xb5, 0x72, - (byte)0xcf, - (byte)0xf8, 0x31, 0x3b, 0x06, 0x78, - (byte)0xdb, 0x44, 0x7d, (byte)0xba, (byte)0xbd, 0x7d, 0x39, (byte)0x98, - (byte)0xb9, -}; -CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(bytes, options)); -} -{ -var options = new CBOREncodeOptions("allowduplicatekeys=1"); -var bytes = new byte[] { - (byte)0xbf, 0x0d, - (byte)0xdb, 0x7f, 0x53, - (byte)0xd5, 0x1e, - (byte)0xab, 0x1f, - (byte)0xb2, - (byte)0xc2, - (byte)0xb8, 0x02, 0x7f, 0x7a, 0x00, 0x00, 0x00, 0x09, - (byte)0xf0, - (byte)0xb8, - (byte)0xbf, - (byte)0xbf, 0x00, - (byte)0xf0, - (byte)0x9d, - (byte)0x84, - (byte)0xa1, - (byte)0xff, 0x1a, 0x00, 0x46, 0x31, - (byte)0xdf, 0x7f, 0x69, 0x05, 0x47, 0x76, 0x4f, 0x01, - (byte)0xf4, - (byte)0x80, - (byte)0x80, - (byte)0x80, (byte)0xff, 0x3a, 0x0a, (byte)0xaa, (byte)0xf2, 0x00, - (byte)0xff, -}; -CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(bytes, options)); -} -{ -var options = new CBOREncodeOptions("allowduplicatekeys=1"); -var bytes = new byte[] { - (byte)0xbf, 0x0d, - (byte)0xdb, 0x7f, 0x53, - (byte)0xd5, 0x1e, - (byte)0xab, 0x1f, 0x23, - (byte)0xc2, - (byte)0xb8, 0x02, 0x7f, 0x69, - (byte)0xc2, - (byte)0xa8, 0x7f, 0x39, 0x7f, - (byte)0xe4, - (byte)0xa1, - (byte)0xae, 0x1c, - (byte)0xff, 0x17, 0x7f, 0x69, 0x05, 0x47, 0x76, 0x4f, 0x01, - (byte)0xec, - (byte)0x90, - (byte)0xb2, 0x0a, (byte)0xff, (byte)0xfa, 0x12, 0x49, 0x20, 0x61, - (byte)0xff, -}; -CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(bytes, options)); -} -{ -var options = new CBOREncodeOptions("allowduplicatekeys=1"); -var bytes = new byte[] { - (byte)0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x01, - (byte)0xd8, 0x52, - (byte)0xbf, 0x0c, - (byte)0xf9, 0x68, 0x67, 0x3b, - (byte)0xdb, - (byte)0x85, 0x5b, 0x59, - (byte)0xfd, 0x03, 0x6c, - (byte)0x80, - (byte)0xf8, - (byte)0xc4, 0x7f, 0x67, 0x73, 0x2b, 0x51, 0x31, 0x5d, 0x26, 0x67, - (byte)0xff, 0x5f, 0x5b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, - (byte)0xc7, - (byte)0xb9, 0x6b, - (byte)0xb0, - (byte)0xb6, - (byte)0xbe, 0x6d, - (byte)0x9e, 0x41, 0x34, 0x5a, 0x00, 0x00, 0x00, 0x02, - (byte)0xc4, 0x4a, - (byte)0xff, 0x67, - (byte)0xe1, - (byte)0x99, - (byte)0x92, - (byte)0xf0, - (byte)0xb5, (byte)0xa4, (byte)0xa2, 0x3a, 0x77, 0x11, 0x4c, 0x6f, - (byte)0xff, -}; -CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(bytes, options)); -} -{ -var options = new CBOREncodeOptions("allowduplicatekeys=1;keepkeyorder=1"); -var bytes = new byte[] { - (byte)0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x01, - (byte)0x9f, - (byte)0xf9, 0x03, - (byte)0xf1, 0x3b, 0x1a, 0x6f, - (byte)0xc2, 0x1b, - (byte)0xce, 0x23, - (byte)0xcb, 0x2e, - (byte)0xbf, - (byte)0xf8, 0x25, - (byte)0xfb, 0x01, 0x54, 0x4a, 0x78, 0x13, - (byte)0xff, 0x12, - (byte)0x91, - (byte)0xff, - (byte)0xbf, 0x78, 0x04, 0x7a, 0x43, 0x30, 0x04, 0x41, 0x55, 0x7f, 0x7a, - 0x00, 0x00, 0x00, 0x03, - (byte)0xda, - (byte)0xb3, 0x64, 0x7b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x58, - (byte)0xff, 0x39, (byte)0xa2, 0x48, (byte)0xff, (byte)0xff, -}; -CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(bytes, options)); -} -{ -var options = new CBOREncodeOptions("allowduplicatekeys=1"); -var bytes = new byte[] { - (byte)0x81, - (byte)0xda, - (byte)0x8a, 0x18, 0x00, 0x00, - (byte)0xda, - (byte)0xd5, - (byte)0xf5, - (byte)0x96, 0x10, - (byte)0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - (byte)0xbf, 0x6f, 0x22, 0x65, 0x65, - (byte)0xf1, - (byte)0x86, - (byte)0x9d, - (byte)0xad, 0x22, 0x42, - (byte)0xc5, - (byte)0xb1, 0x62, 0x58, 0x01, 0x5e, - (byte)0xda, 0x47, 0x47, - (byte)0x87, - (byte)0x94, - (byte)0xed, 0x7f, 0x6c, - (byte)0xf0, - (byte)0x9c, - (byte)0xbc, - (byte)0x96, 0x2f, 0x47, 0x7c, 0x00, 0x50, 0x67, 0x67, 0x10, 0x78, 0x03, - (byte)0xc3, - (byte)0x90, 0x17, - (byte)0xff, 0x19, - (byte)0xd2, - (byte)0xe7, - (byte)0x99, 0x00, 0x01, 0x1b, 0x2a, 0x6e, 0x6f, 0x67, 0x4b, 0x18, 0x60, - 0x51, 0x1b, 0x46, - (byte)0x9f, (byte)0xd3, (byte)0xb7, (byte)0xf4, 0x74, (byte)0xad, 0x6c, - (byte)0xff, -}; -CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(bytes, options)); -} -{ -var options = new CBOREncodeOptions("allowduplicatekeys=1;keepkeyorder=1"); -var bytes = new byte[] { - (byte)0xda, - (byte)0xcf, - (byte)0xf0, - (byte)0xbe, 0x18, - (byte)0x99, 0x00, 0x01, - (byte)0xb9, 0x00, 0x01, - (byte)0xbf, 0x7f, 0x61, 0x5d, 0x7a, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, - 0x20, 0x5a, 0x66, 0x1c, 0x7a, 0x00, 0x00, 0x00, 0x02, 0x7d, 0x7f, 0x60, - 0x78, 0x01, 0x43, - (byte)0xff, 0x1a, - (byte)0xca, 0x5c, - (byte)0x83, 0x47, 0x7f, 0x79, 0x00, 0x0a, - (byte)0xcc, - (byte)0x88, 0x00, 0x73, 0x5f, 0x00, 0x26, 0x08, 0x72, 0x60, - (byte)0xff, 0x00, - (byte)0xff, 0x1b, - (byte)0xbb, 0x19, (byte)0xbf, (byte)0x9f, 0x55, (byte)0xee, 0x56, 0x09, -}; -CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(bytes, options)); -} -} -[Test] -public void TestMapCompareRegressions() { - CBORObject m1, m2; - m1 = CBORObject.NewMap().Add(3, 4).Add(1, 2); - m2 = CBORObject.NewOrderedMap().Add(3, 4).Add(1, 2); - Assert.AreEqual(0, m1.CompareTo(m2)); - TestCommon.CompareTestEqualAndConsistent(m1, m2); - m1 = CBORObject.NewMap().Add(3, 2).Add(1, 2); - m2 = CBORObject.NewOrderedMap().Add(3, 4).Add(1, 2); - TestCommon.CompareTestLess(m1, m2); - m1 = CBORObject.NewMap().Add(3, 7).Add(1, 2); - m2 = CBORObject.NewOrderedMap().Add(3, 4).Add(1, 2); - TestCommon.CompareTestGreater(m1, m2); - m1 = CBORObject.NewMap().Add(3, 4).Add(1, 0); - m2 = CBORObject.NewOrderedMap().Add(3, 4).Add(1, 2); - TestCommon.CompareTestLess(m1, m2); - m1 = CBORObject.NewMap().Add(3, 4).Add(1, 7); - m2 = CBORObject.NewOrderedMap().Add(3, 4).Add(1, 2); - TestCommon.CompareTestGreater(m1, m2); -} + [Test] + public void TestRoundTripRegressions() { + { + var options = new CBOREncodeOptions("allowduplicatekeys=1;keepkeyorder=1"); + var bytes = new byte[] { + (byte)0xba, 0x00, 0x00, 0x00, 0x03, + (byte)0xf9, + (byte)0x83, 0x1d, + (byte)0xda, + (byte)0xb6, + (byte)0xda, 0x50, 0x56, 0x1a, 0x50, + (byte)0xe3, 0x2c, 0x7a, 0x16, + (byte)0xfa, 0x50, 0x32, 0x73, 0x07, + (byte)0xfa, (byte)0xb9, 0x2d, 0x73, (byte)0xce, 0x38, (byte)0xd0, + }; + CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(bytes, options)); + } + { + var options = new CBOREncodeOptions("allowduplicatekeys=1;keepkeyorder=1"); + var bytes = new byte[] { + (byte)0xbf, + (byte)0x9f, + (byte)0xbf, 0x39, 0x20, + (byte)0x8f, 0x4a, 0x1f, 0x46, 0x26, 0x0b, 0x3e, 0x72, 0x2c, 0x7f, 0x11, + 0x2e, 0x39, + (byte)0x9d, + (byte)0xba, 0x1a, 0x11, + (byte)0x8d, + (byte)0xc0, + (byte)0xb4, 0x38, + (byte)0xb6, + (byte)0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + (byte)0xd8, 0x3b, + (byte)0x99, 0x00, 0x02, 0x3b, 0x05, + (byte)0xbb, + (byte)0xea, + (byte)0x8e, 0x4b, + (byte)0xd3, 0x5e, 0x22, + (byte)0x9f, 0x59, 0x00, 0x00, + (byte)0xbb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x41, 0x20, + (byte)0xbf, 0x1a, 0x00, 0x00, 0x00, 0x61, + (byte)0xb9, 0x00, 0x01, 0x1a, 0x00, 0x00, 0x00, 0x0e, + (byte)0xba, 0x00, 0x00, 0x00, 0x00, + (byte)0xff, + (byte)0xff, + (byte)0xff, + (byte)0xd8, 0x22, + (byte)0xf8, + (byte)0x93, + (byte)0xd9, + (byte)0xaf, 0x33, 0x19, + (byte)0xf0, + (byte)0xf0, + (byte)0xf9, + (byte)0x85, + (byte)0x93, + (byte)0x99, 0x00, 0x01, 0x3a, + (byte)0xb5, + (byte)0xfb, 0x4d, 0x43, + (byte)0x98, 0x00, + (byte)0xff, (byte)0xfa, (byte)0xb0, (byte)0xb4, (byte)0xdc, 0x6d, + (byte)0xff, + }; + CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(bytes, options)); + } + { + var options = new CBOREncodeOptions("allowduplicatekeys=1;keepkeyorder=1"); + var bytes = new byte[] { + (byte)0xdb, 0x0d, + (byte)0xcb, 0x5d, 0x78, + (byte)0x92, + (byte)0xc2, + (byte)0xc7, 0x2b, + (byte)0xb9, 0x00, 0x02, 0x39, + (byte)0xee, + (byte)0xa0, (byte)0xa0, 0x1a, 0x0e, (byte)0xd9, (byte)0xec, (byte)0xca, + (byte)0xf2, + }; + CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(bytes, options)); + } + { + var options = new CBOREncodeOptions("allowduplicatekeys=1;keepkeyorder=1"); + var bytes = new byte[] { + (byte)0xbf, + (byte)0xfb, + (byte)0xb1, 0x21, + (byte)0x93, + (byte)0x8c, + (byte)0xc6, + (byte)0xf3, + (byte)0xcf, + (byte)0xb7, (byte)0xf8, 0x76, 0x18, (byte)0xda, 0x39, 0x60, (byte)0xf4, + (byte)0xff, + }; + CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(bytes, options)); + } + { + var options = new CBOREncodeOptions("allowduplicatekeys=1;keepkeyorder=1"); + var bytes = new byte[] { + (byte)0xbb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x02, (byte)0xf0, 0x0d, 0x2a, 0x21, + }; + CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(bytes, options)); + } + { + var options = new CBOREncodeOptions("allowduplicatekeys=1;keepkeyorder=1"); + var bytes = new byte[] { + (byte)0xba, 0x00, 0x00, 0x00, 0x02, + (byte)0xf9, 0x48, 0x37, + (byte)0xda, + (byte)0xb5, 0x72, + (byte)0xcf, + (byte)0xf8, 0x31, 0x3b, 0x06, 0x78, + (byte)0xdb, 0x44, 0x7d, (byte)0xba, (byte)0xbd, 0x7d, 0x39, (byte)0x98, + (byte)0xb9, + }; + CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(bytes, options)); + } + { + var options = new CBOREncodeOptions("allowduplicatekeys=1"); + var bytes = new byte[] { + (byte)0xbf, 0x0d, + (byte)0xdb, 0x7f, 0x53, + (byte)0xd5, 0x1e, + (byte)0xab, 0x1f, + (byte)0xb2, + (byte)0xc2, + (byte)0xb8, 0x02, 0x7f, 0x7a, 0x00, 0x00, 0x00, 0x09, + (byte)0xf0, + (byte)0xb8, + (byte)0xbf, + (byte)0xbf, 0x00, + (byte)0xf0, + (byte)0x9d, + (byte)0x84, + (byte)0xa1, + (byte)0xff, 0x1a, 0x00, 0x46, 0x31, + (byte)0xdf, 0x7f, 0x69, 0x05, 0x47, 0x76, 0x4f, 0x01, + (byte)0xf4, + (byte)0x80, + (byte)0x80, + (byte)0x80, (byte)0xff, 0x3a, 0x0a, (byte)0xaa, (byte)0xf2, 0x00, + (byte)0xff, + }; + CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(bytes, options)); + } + { + var options = new CBOREncodeOptions("allowduplicatekeys=1"); + var bytes = new byte[] { + (byte)0xbf, 0x0d, + (byte)0xdb, 0x7f, 0x53, + (byte)0xd5, 0x1e, + (byte)0xab, 0x1f, 0x23, + (byte)0xc2, + (byte)0xb8, 0x02, 0x7f, 0x69, + (byte)0xc2, + (byte)0xa8, 0x7f, 0x39, 0x7f, + (byte)0xe4, + (byte)0xa1, + (byte)0xae, 0x1c, + (byte)0xff, 0x17, 0x7f, 0x69, 0x05, 0x47, 0x76, 0x4f, 0x01, + (byte)0xec, + (byte)0x90, + (byte)0xb2, 0x0a, (byte)0xff, (byte)0xfa, 0x12, 0x49, 0x20, 0x61, + (byte)0xff, + }; + CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(bytes, options)); + } + { + var options = new CBOREncodeOptions("allowduplicatekeys=1"); + var bytes = new byte[] { + (byte)0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, + (byte)0xd8, 0x52, + (byte)0xbf, 0x0c, + (byte)0xf9, 0x68, 0x67, 0x3b, + (byte)0xdb, + (byte)0x85, 0x5b, 0x59, + (byte)0xfd, 0x03, 0x6c, + (byte)0x80, + (byte)0xf8, + (byte)0xc4, 0x7f, 0x67, 0x73, 0x2b, 0x51, 0x31, 0x5d, 0x26, 0x67, + (byte)0xff, 0x5f, 0x5b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, + (byte)0xc7, + (byte)0xb9, 0x6b, + (byte)0xb0, + (byte)0xb6, + (byte)0xbe, 0x6d, + (byte)0x9e, 0x41, 0x34, 0x5a, 0x00, 0x00, 0x00, 0x02, + (byte)0xc4, 0x4a, + (byte)0xff, 0x67, + (byte)0xe1, + (byte)0x99, + (byte)0x92, + (byte)0xf0, + (byte)0xb5, (byte)0xa4, (byte)0xa2, 0x3a, 0x77, 0x11, 0x4c, 0x6f, + (byte)0xff, + }; + CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(bytes, options)); + } + { + var options = new CBOREncodeOptions("allowduplicatekeys=1;keepkeyorder=1"); + var bytes = new byte[] { + (byte)0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, + (byte)0x9f, + (byte)0xf9, 0x03, + (byte)0xf1, 0x3b, 0x1a, 0x6f, + (byte)0xc2, 0x1b, + (byte)0xce, 0x23, + (byte)0xcb, 0x2e, + (byte)0xbf, + (byte)0xf8, 0x25, + (byte)0xfb, 0x01, 0x54, 0x4a, 0x78, 0x13, + (byte)0xff, 0x12, + (byte)0x91, + (byte)0xff, + (byte)0xbf, 0x78, 0x04, 0x7a, 0x43, 0x30, 0x04, 0x41, 0x55, 0x7f, 0x7a, + 0x00, 0x00, 0x00, 0x03, + (byte)0xda, + (byte)0xb3, 0x64, 0x7b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x58, + (byte)0xff, 0x39, (byte)0xa2, 0x48, (byte)0xff, (byte)0xff, + }; + CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(bytes, options)); + } + { + var options = new CBOREncodeOptions("allowduplicatekeys=1"); + var bytes = new byte[] { + (byte)0x81, + (byte)0xda, + (byte)0x8a, 0x18, 0x00, 0x00, + (byte)0xda, + (byte)0xd5, + (byte)0xf5, + (byte)0x96, 0x10, + (byte)0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + (byte)0xbf, 0x6f, 0x22, 0x65, 0x65, + (byte)0xf1, + (byte)0x86, + (byte)0x9d, + (byte)0xad, 0x22, 0x42, + (byte)0xc5, + (byte)0xb1, 0x62, 0x58, 0x01, 0x5e, + (byte)0xda, 0x47, 0x47, + (byte)0x87, + (byte)0x94, + (byte)0xed, 0x7f, 0x6c, + (byte)0xf0, + (byte)0x9c, + (byte)0xbc, + (byte)0x96, 0x2f, 0x47, 0x7c, 0x00, 0x50, 0x67, 0x67, 0x10, 0x78, 0x03, + (byte)0xc3, + (byte)0x90, 0x17, + (byte)0xff, 0x19, + (byte)0xd2, + (byte)0xe7, + (byte)0x99, 0x00, 0x01, 0x1b, 0x2a, 0x6e, 0x6f, 0x67, 0x4b, 0x18, 0x60, + 0x51, 0x1b, 0x46, + (byte)0x9f, (byte)0xd3, (byte)0xb7, (byte)0xf4, 0x74, (byte)0xad, 0x6c, + (byte)0xff, + }; + CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(bytes, options)); + } + { + var options = new CBOREncodeOptions("allowduplicatekeys=1;keepkeyorder=1"); + var bytes = new byte[] { + (byte)0xda, + (byte)0xcf, + (byte)0xf0, + (byte)0xbe, 0x18, + (byte)0x99, 0x00, 0x01, + (byte)0xb9, 0x00, 0x01, + (byte)0xbf, 0x7f, 0x61, 0x5d, 0x7a, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, + 0x20, 0x5a, 0x66, 0x1c, 0x7a, 0x00, 0x00, 0x00, 0x02, 0x7d, 0x7f, 0x60, + 0x78, 0x01, 0x43, + (byte)0xff, 0x1a, + (byte)0xca, 0x5c, + (byte)0x83, 0x47, 0x7f, 0x79, 0x00, 0x0a, + (byte)0xcc, + (byte)0x88, 0x00, 0x73, 0x5f, 0x00, 0x26, 0x08, 0x72, 0x60, + (byte)0xff, 0x00, + (byte)0xff, 0x1b, + (byte)0xbb, 0x19, (byte)0xbf, (byte)0x9f, 0x55, (byte)0xee, 0x56, 0x09, + }; + CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(bytes, options)); + } + } + [Test] + public void TestMapCompareRegressions() { + CBORObject m1, m2; + m1 = CBORObject.NewMap().Add(3, 4).Add(1, 2); + m2 = CBORObject.NewOrderedMap().Add(3, 4).Add(1, 2); + Assert.AreEqual(0, m1.CompareTo(m2)); + TestCommon.CompareTestEqualAndConsistent(m1, m2); + m1 = CBORObject.NewMap().Add(3, 2).Add(1, 2); + m2 = CBORObject.NewOrderedMap().Add(3, 4).Add(1, 2); + TestCommon.CompareTestLess(m1, m2); + m1 = CBORObject.NewMap().Add(3, 7).Add(1, 2); + m2 = CBORObject.NewOrderedMap().Add(3, 4).Add(1, 2); + TestCommon.CompareTestGreater(m1, m2); + m1 = CBORObject.NewMap().Add(3, 4).Add(1, 0); + m2 = CBORObject.NewOrderedMap().Add(3, 4).Add(1, 2); + TestCommon.CompareTestLess(m1, m2); + m1 = CBORObject.NewMap().Add(3, 4).Add(1, 7); + m2 = CBORObject.NewOrderedMap().Add(3, 4).Add(1, 2); + TestCommon.CompareTestGreater(m1, m2); + } [Test] public void TestToObject_TypeMapper() { var mapper = new CBORTypeMapper() @@ -10062,670 +10062,670 @@ public void TestToObject_TypeMapper() { } } -[Test] -public void TestRegressionFour() { - CBORObject o1 = CBORObject.FromObject(new byte[] { (byte)5, (byte)2 }); - CBORObject o2 = CBORObject.FromObject(new byte[] { (byte)0x85, (byte)2 }); - TestCommon.CompareTestLess(o1, o2); -} - -[Test] -public void TestRegressionOne() { -{ -CBOREncodeOptions options = new CBOREncodeOptions(); -byte[] bytes = new byte[] { - (byte)0xbf, 0x0d, - (byte)0xdb, 0x7f, 0x53, - (byte)0xd5, 0x1e, - (byte)0xab, 0x1f, - (byte)0xb2, - (byte)0xc2, - (byte)0xb8, 0x02, 0x7f, 0x7a, 0x00, 0x00, 0x00, 0x09, - (byte)0xf0, - (byte)0xb8, - (byte)0xbf, - (byte)0xbf, 0x00, - (byte)0xf0, - (byte)0x9d, - (byte)0x84, - (byte)0xa1, - (byte)0xff, 0x1a, 0x00, 0x46, 0x31, - (byte)0xdf, 0x7f, 0x69, 0x05, 0x47, 0x76, 0x4f, 0x01, - (byte)0xf4, - (byte)0x80, - (byte)0x80, - (byte)0x80, (byte)0xff, 0x3a, 0x0a, (byte)0xaa, (byte)0xf2, 0x00, - (byte)0xff, -}; -byte[] encodedBytes = new byte[] { - (byte)0xa1, 0x0d, - (byte)0xdb, 0x7f, 0x53, - (byte)0xd5, 0x1e, - (byte)0xab, 0x1f, - (byte)0xb2, - (byte)0xc2, - (byte)0xa2, 0x69, 0x05, 0x47, 0x76, 0x4f, 0x01, - (byte)0xf4, - (byte)0x80, - (byte)0x80, - (byte)0x80, 0x3a, 0x0a, - (byte)0xaa, - (byte)0xf2, 0x00, 0x69, - (byte)0xf0, - (byte)0xb8, - (byte)0xbf, - (byte)0xbf, 0x00, - (byte)0xf0, (byte)0x9d, (byte)0x84, (byte)0xa1, 0x1a, 0x00, 0x46, 0x31, - (byte)0xdf, -}; -CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(bytes)); -CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(encodedBytes)); -} -} + [Test] + public void TestRegressionFour() { + CBORObject o1 = CBORObject.FromObject(new byte[] { (byte)5, (byte)2 }); + CBORObject o2 = CBORObject.FromObject(new byte[] { (byte)0x85, (byte)2 }); + TestCommon.CompareTestLess(o1, o2); + } -[Test] -public void TestRegressionTwo() { -{ -CBOREncodeOptions options = new CBOREncodeOptions(); -byte[] bytes = new byte[] { - (byte)0xb8, 0x02, 0x7f, 0x7a, 0x00, 0x00, 0x00, - 0x09, - (byte)0xf0, - (byte)0xb8, - (byte)0xbf, - (byte)0xbf, 0x00, - (byte)0xf0, - (byte)0x9d, - (byte)0x84, - (byte)0xa1, - (byte)0xff, 0x1a, 0x00, 0x46, 0x31, - (byte)0xdf, 0x7f, 0x69, 0x05, 0x47, 0x76, 0x4f, 0x01, - (byte)0xf4, - (byte)0x80, - (byte)0x80, - (byte)0x80, (byte)0xff, 0x3a, 0x0a, (byte)0xaa, (byte)0xf2, 0x00, -}; -byte[] encodedBytes = new byte[] { - (byte)0xa2, 0x69, 0x05, 0x47, 0x76, 0x4f, - 0x01, - (byte)0xf4, - (byte)0x80, - (byte)0x80, - (byte)0x80, 0x3a, 0x0a, - (byte)0xaa, - (byte)0xf2, 0x00, 0x69, - (byte)0xf0, - (byte)0xb8, - (byte)0xbf, - (byte)0xbf, 0x00, - (byte)0xf0, (byte)0x9d, (byte)0x84, (byte)0xa1, 0x1a, 0x00, 0x46, 0x31, - (byte)0xdf, -}; -CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(bytes)); -CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(encodedBytes)); -} -} + [Test] + public void TestRegressionOne() { + { + CBOREncodeOptions options = new CBOREncodeOptions(); + byte[] bytes = new byte[] { + (byte)0xbf, 0x0d, + (byte)0xdb, 0x7f, 0x53, + (byte)0xd5, 0x1e, + (byte)0xab, 0x1f, + (byte)0xb2, + (byte)0xc2, + (byte)0xb8, 0x02, 0x7f, 0x7a, 0x00, 0x00, 0x00, 0x09, + (byte)0xf0, + (byte)0xb8, + (byte)0xbf, + (byte)0xbf, 0x00, + (byte)0xf0, + (byte)0x9d, + (byte)0x84, + (byte)0xa1, + (byte)0xff, 0x1a, 0x00, 0x46, 0x31, + (byte)0xdf, 0x7f, 0x69, 0x05, 0x47, 0x76, 0x4f, 0x01, + (byte)0xf4, + (byte)0x80, + (byte)0x80, + (byte)0x80, (byte)0xff, 0x3a, 0x0a, (byte)0xaa, (byte)0xf2, 0x00, + (byte)0xff, + }; + byte[] encodedBytes = new byte[] { + (byte)0xa1, 0x0d, + (byte)0xdb, 0x7f, 0x53, + (byte)0xd5, 0x1e, + (byte)0xab, 0x1f, + (byte)0xb2, + (byte)0xc2, + (byte)0xa2, 0x69, 0x05, 0x47, 0x76, 0x4f, 0x01, + (byte)0xf4, + (byte)0x80, + (byte)0x80, + (byte)0x80, 0x3a, 0x0a, + (byte)0xaa, + (byte)0xf2, 0x00, 0x69, + (byte)0xf0, + (byte)0xb8, + (byte)0xbf, + (byte)0xbf, 0x00, + (byte)0xf0, (byte)0x9d, (byte)0x84, (byte)0xa1, 0x1a, 0x00, 0x46, 0x31, + (byte)0xdf, + }; + CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(bytes)); + CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(encodedBytes)); + } + } -[Test] -public void TestRegressionThree() { -{ -CBOREncodeOptions options = new CBOREncodeOptions(); -byte[] bytes = new byte[] { - (byte)0xb8, 0x02, 0x7f, 0x7a, 0x00, 0x00, 0x00, - 0x09, - (byte)0xf0, - (byte)0xb8, - (byte)0xbf, - (byte)0xbf, 0x00, - (byte)0xf0, - (byte)0x9d, - (byte)0x84, - (byte)0xa1, - (byte)0xff, 0, 0x7f, 0x69, 0x05, 0x47, 0x76, 0x4f, 0x01, - (byte)0xf4, - (byte)0x80, - (byte)0x80, - (byte)0x80, (byte)0xff, 0, -}; -byte[] encodedBytes = new byte[] { - (byte)0xa2, 0x69, 0x05, 0x47, 0x76, 0x4f, - 0x01, - (byte)0xf4, - (byte)0x80, - (byte)0x80, - (byte)0x80, 0, 0x69, - (byte)0xf0, - (byte)0xb8, - (byte)0xbf, (byte)0xbf, 0x00, (byte)0xf0, (byte)0x9d, (byte)0x84, - (byte)0xa1, 0, -}; -CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(bytes)); -CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(encodedBytes)); -} -} + [Test] + public void TestRegressionTwo() { + { + CBOREncodeOptions options = new CBOREncodeOptions(); + byte[] bytes = new byte[] { + (byte)0xb8, 0x02, 0x7f, 0x7a, 0x00, 0x00, 0x00, + 0x09, + (byte)0xf0, + (byte)0xb8, + (byte)0xbf, + (byte)0xbf, 0x00, + (byte)0xf0, + (byte)0x9d, + (byte)0x84, + (byte)0xa1, + (byte)0xff, 0x1a, 0x00, 0x46, 0x31, + (byte)0xdf, 0x7f, 0x69, 0x05, 0x47, 0x76, 0x4f, 0x01, + (byte)0xf4, + (byte)0x80, + (byte)0x80, + (byte)0x80, (byte)0xff, 0x3a, 0x0a, (byte)0xaa, (byte)0xf2, 0x00, + }; + byte[] encodedBytes = new byte[] { + (byte)0xa2, 0x69, 0x05, 0x47, 0x76, 0x4f, + 0x01, + (byte)0xf4, + (byte)0x80, + (byte)0x80, + (byte)0x80, 0x3a, 0x0a, + (byte)0xaa, + (byte)0xf2, 0x00, 0x69, + (byte)0xf0, + (byte)0xb8, + (byte)0xbf, + (byte)0xbf, 0x00, + (byte)0xf0, (byte)0x9d, (byte)0x84, (byte)0xa1, 0x1a, 0x00, 0x46, 0x31, + (byte)0xdf, + }; + CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(bytes)); + CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(encodedBytes)); + } + } -[Test] -public void TestStringCompareBug() { - CBORObject a, b, c, d; - var bytes = new byte[] { - 0x69, 0x05, 0x47, 0x76, 0x4f, 0x01, - (byte)0xf4, - (byte)0x80, - (byte)0x80, - (byte)0x80, - }; - a = CBORObject.DecodeFromBytes(bytes); - c = a; - bytes = new byte[] { - 0x7f, 0x69, 0x05, 0x47, 0x76, 0x4f, 0x01, - (byte)0xf4, - (byte)0x80, - (byte)0x80, - (byte)0x80, (byte)0xff, - }; - b = CBORObject.DecodeFromBytes(bytes); - d = b; - TestCommon.CompareTestEqual(a, b); - bytes = new byte[] { - 0x7f, 0x7a, 0x00, 0x00, 0x00, 0x09, - (byte)0xf0, - (byte)0xb8, - (byte)0xbf, - (byte)0xbf, 0x00, - (byte)0xf0, - (byte)0x9d, - (byte)0x84, - (byte)0xa1, - (byte)0xff, - }; - a = CBORObject.DecodeFromBytes(bytes); - bytes = new byte[] { - 0x7f, 0x69, - (byte)0xf0, - (byte)0xb8, - (byte)0xbf, - (byte)0xbf, 0x00, - (byte)0xf0, - (byte)0x9d, - (byte)0x84, - (byte)0xa1, - (byte)0xff, - }; - b = CBORObject.DecodeFromBytes(bytes); - TestCommon.CompareTestEqual(a, b); - TestCommon.CompareTestLess(c, a); - TestCommon.CompareTestLess(c, b); - TestCommon.CompareTestLess(d, a); - TestCommon.CompareTestLess(d, b); - CBORObject o1 = CBORObject.NewMap(); - o1.Add(b, CBORObject.FromObject(0)); - o1.Add(c, CBORObject.FromObject(0)); - CBORObject o2 = CBORObject.NewMap(); - o2.Add(c, CBORObject.FromObject(0)); - o2.Add(b, CBORObject.FromObject(0)); - TestCommon.CompareTestEqual(a, b); -} + [Test] + public void TestRegressionThree() { + { + CBOREncodeOptions options = new CBOREncodeOptions(); + byte[] bytes = new byte[] { + (byte)0xb8, 0x02, 0x7f, 0x7a, 0x00, 0x00, 0x00, + 0x09, + (byte)0xf0, + (byte)0xb8, + (byte)0xbf, + (byte)0xbf, 0x00, + (byte)0xf0, + (byte)0x9d, + (byte)0x84, + (byte)0xa1, + (byte)0xff, 0, 0x7f, 0x69, 0x05, 0x47, 0x76, 0x4f, 0x01, + (byte)0xf4, + (byte)0x80, + (byte)0x80, + (byte)0x80, (byte)0xff, 0, + }; + byte[] encodedBytes = new byte[] { + (byte)0xa2, 0x69, 0x05, 0x47, 0x76, 0x4f, + 0x01, + (byte)0xf4, + (byte)0x80, + (byte)0x80, + (byte)0x80, 0, 0x69, + (byte)0xf0, + (byte)0xb8, + (byte)0xbf, (byte)0xbf, 0x00, (byte)0xf0, (byte)0x9d, (byte)0x84, + (byte)0xa1, 0, + }; + CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(bytes)); + CBORTestCommon.AssertRoundTrip(CBORObject.DecodeFromBytes(encodedBytes)); + } + } -[Test] -[Timeout(2000)] -public void TestSlowDecode() { -byte[] bytes = new byte[] { - (byte)0xa4, - (byte)0xa3, - (byte)0xa4, - (byte)0xa3, - (byte)0xa3, - (byte)0xf0, 0x02, - (byte)0xf1, - (byte)0xf5, - (byte)0xf2, 0x02, - (byte)0xf7, - (byte)0xa0, 0x02, - (byte)0xa3, - (byte)0xf0, 0x01, - (byte)0xf1, 0x01, - (byte)0xf2, - (byte)0xf7, - (byte)0xf7, - (byte)0xf5, - (byte)0xa0, 0x01, - (byte)0xa3, - (byte)0xa3, 0x00, - (byte)0xf5, 0x01, - (byte)0xf4, 0x02, 0x02, 0x02, - (byte)0xa0, 0x01, - (byte)0xa3, 0x00, - (byte)0xa0, 0x01, - (byte)0xa0, 0x02, 0x02, - (byte)0xf6, 0x02, 0x40, - (byte)0xf5, 0x02, - (byte)0xa4, - (byte)0xa3, - (byte)0xf0, 0x02, - (byte)0xf1, - (byte)0xf7, - (byte)0xf2, - (byte)0xf6, 0x00, - (byte)0xa3, - (byte)0xa4, - (byte)0xa3, - (byte)0xf1, - (byte)0xf4, - (byte)0xf2, 0x02, - (byte)0xf3, 0x01, 0x02, - (byte)0xa0, - (byte)0xa0, - (byte)0xa3, - (byte)0xf0, 0x00, - (byte)0xf1, - (byte)0xf7, - (byte)0xf2, - (byte)0xf5, 0x00, 0x40, - (byte)0xf4, - (byte)0xf4, - (byte)0xa4, 0x00, - (byte)0xf6, 0x01, - (byte)0xf4, 0x02, 0x00, 0x40, 0x01, - (byte)0xf5, - (byte)0xa4, - (byte)0xf0, - (byte)0xa0, - (byte)0xf1, - (byte)0xa0, - (byte)0xf2, - (byte)0xf4, 0x40, 0x00, 0x02, 0x01, - (byte)0xa3, - (byte)0xa3, - (byte)0xf1, - (byte)0xf6, - (byte)0xf2, - (byte)0xf6, - (byte)0xf3, - (byte)0xf4, - (byte)0xa0, - (byte)0xa3, 0x00, 0x00, 0x01, - (byte)0xf4, 0x02, - (byte)0xf7, - (byte)0xf6, - (byte)0xa3, - (byte)0xa4, - (byte)0xf1, - (byte)0xf5, - (byte)0xf2, - (byte)0xf6, - (byte)0xf3, 0x01, 0x40, - (byte)0xa0, 0x00, - (byte)0xa4, 0x00, 0x02, 0x01, - (byte)0xa0, 0x02, 0x01, 0x40, 0x00, - (byte)0xf4, - (byte)0xa4, - (byte)0xa4, - (byte)0xa3, - (byte)0xf0, - (byte)0xf5, - (byte)0xf1, - (byte)0xf7, - (byte)0xf2, - (byte)0xf7, - (byte)0xf4, - (byte)0xa3, 0x00, - (byte)0xf6, 0x01, 0x02, 0x02, - (byte)0xf5, - (byte)0xf5, - (byte)0xa3, - (byte)0xa3, - (byte)0xa3, - (byte)0xf0, - (byte)0xf4, - (byte)0xf1, - (byte)0xf5, - (byte)0xf2, - (byte)0xf6, 0x01, - (byte)0xa3, - (byte)0xa4, - (byte)0xa4, - (byte)0xa3, - (byte)0xa4, - (byte)0xa3, - (byte)0xa3, - (byte)0xf0, - (byte)0xf4, - (byte)0xf1, - (byte)0xf6, - (byte)0xf2, 0x02, 0x01, - (byte)0xa0, - (byte)0xf6, - (byte)0xa3, - (byte)0xf1, - (byte)0xf7, - (byte)0xf2, 0x00, - (byte)0xf3, 0x01, 0x01, - (byte)0xf4, - (byte)0xa3, - (byte)0xf1, 0x01, - (byte)0xf2, 0x00, - (byte)0xf3, - (byte)0xf6, - (byte)0xf5, - (byte)0xa3, - (byte)0xf1, - (byte)0xf5, - (byte)0xf2, - (byte)0xa0, - (byte)0xf3, - (byte)0xf6, - (byte)0xf4, 0x40, 0x02, 0x02, - (byte)0xa4, - (byte)0xa3, - (byte)0xa4, - (byte)0xf1, - (byte)0xf7, - (byte)0xf2, - (byte)0xf4, - (byte)0xf3, - (byte)0xf7, 0x40, 0x01, 0x00, - (byte)0xa4, - (byte)0xf0, - (byte)0xf6, - (byte)0xf1, - (byte)0xf5, - (byte)0xf2, 0x00, 0x40, - (byte)0xf5, - (byte)0xa0, - (byte)0xa4, - (byte)0xa3, 0x00, 0x00, 0x01, - (byte)0xf5, 0x02, - (byte)0xf6, 0x00, - (byte)0xa0, 0x00, - (byte)0xa3, 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x40, 0x02, 0x00, - (byte)0xf6, - (byte)0xa3, 0x00, - (byte)0xf7, 0x01, 0x00, 0x02, 0x01, 0x02, - (byte)0xa3, - (byte)0xa4, - (byte)0xa4, 0x00, - (byte)0xf4, 0x01, - (byte)0xf5, 0x02, 0x00, 0x40, - (byte)0xf7, 0x00, - (byte)0xa4, - (byte)0xf1, - (byte)0xf6, - (byte)0xf2, - (byte)0xf4, - (byte)0xf3, - (byte)0xf5, 0x40, - (byte)0xa0, - (byte)0xf7, - (byte)0xa4, 0x00, 0x00, 0x01, - (byte)0xa0, 0x02, - (byte)0xf5, 0x40, 0x00, 0x02, 0x40, 0x01, - (byte)0xf7, - (byte)0xa4, - (byte)0xa3, - (byte)0xa3, 0x00, - (byte)0xf6, 0x01, - (byte)0xf4, 0x02, - (byte)0xf4, 0x02, - (byte)0xa3, - (byte)0xf0, - (byte)0xf6, - (byte)0xf1, - (byte)0xf4, - (byte)0xf2, 0x01, - (byte)0xf4, - (byte)0xa3, - (byte)0xa4, - (byte)0xa3, - (byte)0xf1, - (byte)0xf4, - (byte)0xf2, - (byte)0xa0, - (byte)0xf3, 0x01, - (byte)0xf6, - (byte)0xa0, - (byte)0xf6, - (byte)0xa3, - (byte)0xf0, - (byte)0xf5, - (byte)0xf1, 0x00, - (byte)0xf2, - (byte)0xf5, 0x02, 0x40, - (byte)0xf6, - (byte)0xf6, - (byte)0xa4, - (byte)0xf0, 0x01, - (byte)0xf1, - (byte)0xf4, - (byte)0xf2, - (byte)0xf6, 0x40, - (byte)0xf4, - (byte)0xa0, - (byte)0xa4, - (byte)0xa3, - (byte)0xa4, 0x00, - (byte)0xa0, 0x01, 0x00, 0x02, - (byte)0xf6, 0x40, - (byte)0xf4, 0x00, - (byte)0xa4, - (byte)0xa4, - (byte)0xf0, - (byte)0xf4, - (byte)0xf1, - (byte)0xf5, - (byte)0xf2, 0x00, 0x40, - (byte)0xa0, - (byte)0xf6, - (byte)0xa4, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x40, - (byte)0xf6, - (byte)0xa0, - (byte)0xa4, - (byte)0xf1, - (byte)0xf5, - (byte)0xf2, - (byte)0xf4, - (byte)0xf3, - (byte)0xf4, 0x40, - (byte)0xf5, - (byte)0xa0, 0x40, - (byte)0xf7, 0x02, - (byte)0xa4, - (byte)0xa4, 0x00, 0x02, 0x01, 0x02, 0x02, 0x01, 0x40, - (byte)0xf5, - (byte)0xf7, - (byte)0xa4, - (byte)0xf1, - (byte)0xa0, - (byte)0xf2, - (byte)0xf6, - (byte)0xf3, - (byte)0xf4, 0x40, - (byte)0xf6, - (byte)0xf4, - (byte)0xa4, - (byte)0xf0, 0x00, - (byte)0xf1, - (byte)0xf7, - (byte)0xf2, 0x02, 0x40, - (byte)0xf4, - (byte)0xf4, 0x40, 0x02, - (byte)0xf4, - (byte)0xf6, - (byte)0xa3, - (byte)0xf1, - (byte)0xf5, - (byte)0xf2, - (byte)0xf6, - (byte)0xf3, 0x00, - (byte)0xf7, - (byte)0xa3, - (byte)0xf0, - (byte)0xf7, - (byte)0xf1, - (byte)0xf5, - (byte)0xf2, 0x00, 0x01, 0x40, 0x01, 0x01, 0x00, - (byte)0xf7, - (byte)0xa0, 0x00, - (byte)0xa3, - (byte)0xa4, - (byte)0xf1, 0x02, - (byte)0xf2, - (byte)0xf4, - (byte)0xf3, - (byte)0xf7, 0x40, - (byte)0xf6, - (byte)0xf7, - (byte)0xa4, - (byte)0xf1, - (byte)0xf6, - (byte)0xf2, - (byte)0xf4, - (byte)0xf3, - (byte)0xf4, 0x40, - (byte)0xf6, - (byte)0xf6, - (byte)0xa4, - (byte)0xa3, - (byte)0xf1, - (byte)0xf6, - (byte)0xf2, 0x00, - (byte)0xf3, - (byte)0xf4, - (byte)0xf5, - (byte)0xa0, - (byte)0xf6, - (byte)0xa3, 0x00, 0x01, 0x01, - (byte)0xa0, 0x02, 0x01, - (byte)0xa0, 0x40, 0x02, 0x00, - (byte)0xf5, 0x40, - (byte)0xf5, - (byte)0xa0, - (byte)0xa4, - (byte)0xa3, 0x00, - (byte)0xf5, 0x01, 0x02, 0x02, 0x00, - (byte)0xf6, - (byte)0xa0, - (byte)0xf6, - (byte)0xa3, - (byte)0xf1, - (byte)0xf6, - (byte)0xf2, - (byte)0xf5, - (byte)0xf3, - (byte)0xf5, 0x00, 0x40, - (byte)0xf5, - (byte)0xf6, 0x02, 0x40, 0x01, 0x01, - (byte)0xa4, - (byte)0xf1, - (byte)0xa0, - (byte)0xf2, 0x01, - (byte)0xf3, - (byte)0xf5, 0x40, 0x00, 0x02, - (byte)0xa0, - (byte)0xa0, 0x00, - (byte)0xa3, - (byte)0xf0, - (byte)0xf4, - (byte)0xf1, - (byte)0xa0, - (byte)0xf2, 0x00, 0x01, 0x40, 0x02, 0x00, - (byte)0xa4, - (byte)0xf0, 0x01, - (byte)0xf1, 0x02, - (byte)0xf2, - (byte)0xa0, 0x40, - (byte)0xf5, 0x02, - (byte)0xa4, - (byte)0xa3, - (byte)0xf0, 0x00, - (byte)0xf1, 0x01, - (byte)0xf2, - (byte)0xf5, - (byte)0xf7, - (byte)0xa3, - (byte)0xa3, - (byte)0xf1, 0x01, - (byte)0xf2, 0x01, - (byte)0xf3, 0x01, - (byte)0xa0, - (byte)0xa0, 0x01, - (byte)0xa3, - (byte)0xf1, - (byte)0xf4, - (byte)0xf2, 0x00, - (byte)0xf3, - (byte)0xf4, - (byte)0xf6, 0x02, - (byte)0xa3, - (byte)0xf1, - (byte)0xf4, - (byte)0xf2, 0x01, - (byte)0xf3, - (byte)0xf4, 0x02, 0x40, 0x00, - (byte)0xa0, 0x40, - (byte)0xa0, - (byte)0xf5, - (byte)0xa4, - (byte)0xf0, - (byte)0xf7, - (byte)0xf1, - (byte)0xf4, - (byte)0xf2, - (byte)0xa0, 0x40, - (byte)0xa0, 0x00, - (byte)0xa4, 0x00, 0x00, 0x01, - (byte)0xa0, 0x02, - (byte)0xf5, 0x40, - (byte)0xf7, - (byte)0xf7, 0x00, - (byte)0xa3, 0x00, 0x01, 0x01, 0x01, 0x02, - (byte)0xf4, - (byte)0xf7, - (byte)0xf7, - (byte)0xa0, - (byte)0xa0, - (byte)0xa3, - (byte)0xf0, - (byte)0xf6, - (byte)0xf1, 0x01, - (byte)0xf2, 0x01, 0x00, - (byte)0xf6, 0x40, - (byte)0xf6, - (byte)0xf6, - (byte)0xa4, - (byte)0xf1, - (byte)0xf7, - (byte)0xf2, 0x01, - (byte)0xf3, 0x01, 0x40, - (byte)0xf7, - (byte)0xf5, - (byte)0xa4, - (byte)0xf1, - (byte)0xf6, - (byte)0xf2, 0x00, - (byte)0xf3, - (byte)0xa0, 0x40, 0x01, 0x02, 0x40, 0x01, - (byte)0xa0, - (byte)0xa0, 0x02, 0x40, 0x01, 0x02, - (byte)0xa4, - (byte)0xf0, - (byte)0xf4, - (byte)0xf1, - (byte)0xf5, - (byte)0xf2, - (byte)0xf5, 0x40, - (byte)0xf7, - (byte)0xa0, - (byte)0xf5, - (byte)0xa0, - (byte)0xf5, - (byte)0xa3, 0x00, ( - byte)0xf6, 0x01, (byte)0xf6, 0x02, (byte)0xa0, (byte)0xf4, 0x40, - (byte)0xf7, -}; -var options = new CBOREncodeOptions("allowduplicatekeys=1"); -for (var i = 0; i < 10; ++i) { - CBORObject.DecodeFromBytes(bytes, options); -} -} + [Test] + public void TestStringCompareBug() { + CBORObject a, b, c, d; + var bytes = new byte[] { + 0x69, 0x05, 0x47, 0x76, 0x4f, 0x01, + (byte)0xf4, + (byte)0x80, + (byte)0x80, + (byte)0x80, + }; + a = CBORObject.DecodeFromBytes(bytes); + c = a; + bytes = new byte[] { + 0x7f, 0x69, 0x05, 0x47, 0x76, 0x4f, 0x01, + (byte)0xf4, + (byte)0x80, + (byte)0x80, + (byte)0x80, (byte)0xff, + }; + b = CBORObject.DecodeFromBytes(bytes); + d = b; + TestCommon.CompareTestEqual(a, b); + bytes = new byte[] { + 0x7f, 0x7a, 0x00, 0x00, 0x00, 0x09, + (byte)0xf0, + (byte)0xb8, + (byte)0xbf, + (byte)0xbf, 0x00, + (byte)0xf0, + (byte)0x9d, + (byte)0x84, + (byte)0xa1, + (byte)0xff, + }; + a = CBORObject.DecodeFromBytes(bytes); + bytes = new byte[] { + 0x7f, 0x69, + (byte)0xf0, + (byte)0xb8, + (byte)0xbf, + (byte)0xbf, 0x00, + (byte)0xf0, + (byte)0x9d, + (byte)0x84, + (byte)0xa1, + (byte)0xff, + }; + b = CBORObject.DecodeFromBytes(bytes); + TestCommon.CompareTestEqual(a, b); + TestCommon.CompareTestLess(c, a); + TestCommon.CompareTestLess(c, b); + TestCommon.CompareTestLess(d, a); + TestCommon.CompareTestLess(d, b); + CBORObject o1 = CBORObject.NewMap(); + o1.Add(b, CBORObject.FromObject(0)); + o1.Add(c, CBORObject.FromObject(0)); + CBORObject o2 = CBORObject.NewMap(); + o2.Add(c, CBORObject.FromObject(0)); + o2.Add(b, CBORObject.FromObject(0)); + TestCommon.CompareTestEqual(a, b); + } + + [Test] + [Timeout(2000)] + public void TestSlowDecode() { + byte[] bytes = new byte[] { + (byte)0xa4, + (byte)0xa3, + (byte)0xa4, + (byte)0xa3, + (byte)0xa3, + (byte)0xf0, 0x02, + (byte)0xf1, + (byte)0xf5, + (byte)0xf2, 0x02, + (byte)0xf7, + (byte)0xa0, 0x02, + (byte)0xa3, + (byte)0xf0, 0x01, + (byte)0xf1, 0x01, + (byte)0xf2, + (byte)0xf7, + (byte)0xf7, + (byte)0xf5, + (byte)0xa0, 0x01, + (byte)0xa3, + (byte)0xa3, 0x00, + (byte)0xf5, 0x01, + (byte)0xf4, 0x02, 0x02, 0x02, + (byte)0xa0, 0x01, + (byte)0xa3, 0x00, + (byte)0xa0, 0x01, + (byte)0xa0, 0x02, 0x02, + (byte)0xf6, 0x02, 0x40, + (byte)0xf5, 0x02, + (byte)0xa4, + (byte)0xa3, + (byte)0xf0, 0x02, + (byte)0xf1, + (byte)0xf7, + (byte)0xf2, + (byte)0xf6, 0x00, + (byte)0xa3, + (byte)0xa4, + (byte)0xa3, + (byte)0xf1, + (byte)0xf4, + (byte)0xf2, 0x02, + (byte)0xf3, 0x01, 0x02, + (byte)0xa0, + (byte)0xa0, + (byte)0xa3, + (byte)0xf0, 0x00, + (byte)0xf1, + (byte)0xf7, + (byte)0xf2, + (byte)0xf5, 0x00, 0x40, + (byte)0xf4, + (byte)0xf4, + (byte)0xa4, 0x00, + (byte)0xf6, 0x01, + (byte)0xf4, 0x02, 0x00, 0x40, 0x01, + (byte)0xf5, + (byte)0xa4, + (byte)0xf0, + (byte)0xa0, + (byte)0xf1, + (byte)0xa0, + (byte)0xf2, + (byte)0xf4, 0x40, 0x00, 0x02, 0x01, + (byte)0xa3, + (byte)0xa3, + (byte)0xf1, + (byte)0xf6, + (byte)0xf2, + (byte)0xf6, + (byte)0xf3, + (byte)0xf4, + (byte)0xa0, + (byte)0xa3, 0x00, 0x00, 0x01, + (byte)0xf4, 0x02, + (byte)0xf7, + (byte)0xf6, + (byte)0xa3, + (byte)0xa4, + (byte)0xf1, + (byte)0xf5, + (byte)0xf2, + (byte)0xf6, + (byte)0xf3, 0x01, 0x40, + (byte)0xa0, 0x00, + (byte)0xa4, 0x00, 0x02, 0x01, + (byte)0xa0, 0x02, 0x01, 0x40, 0x00, + (byte)0xf4, + (byte)0xa4, + (byte)0xa4, + (byte)0xa3, + (byte)0xf0, + (byte)0xf5, + (byte)0xf1, + (byte)0xf7, + (byte)0xf2, + (byte)0xf7, + (byte)0xf4, + (byte)0xa3, 0x00, + (byte)0xf6, 0x01, 0x02, 0x02, + (byte)0xf5, + (byte)0xf5, + (byte)0xa3, + (byte)0xa3, + (byte)0xa3, + (byte)0xf0, + (byte)0xf4, + (byte)0xf1, + (byte)0xf5, + (byte)0xf2, + (byte)0xf6, 0x01, + (byte)0xa3, + (byte)0xa4, + (byte)0xa4, + (byte)0xa3, + (byte)0xa4, + (byte)0xa3, + (byte)0xa3, + (byte)0xf0, + (byte)0xf4, + (byte)0xf1, + (byte)0xf6, + (byte)0xf2, 0x02, 0x01, + (byte)0xa0, + (byte)0xf6, + (byte)0xa3, + (byte)0xf1, + (byte)0xf7, + (byte)0xf2, 0x00, + (byte)0xf3, 0x01, 0x01, + (byte)0xf4, + (byte)0xa3, + (byte)0xf1, 0x01, + (byte)0xf2, 0x00, + (byte)0xf3, + (byte)0xf6, + (byte)0xf5, + (byte)0xa3, + (byte)0xf1, + (byte)0xf5, + (byte)0xf2, + (byte)0xa0, + (byte)0xf3, + (byte)0xf6, + (byte)0xf4, 0x40, 0x02, 0x02, + (byte)0xa4, + (byte)0xa3, + (byte)0xa4, + (byte)0xf1, + (byte)0xf7, + (byte)0xf2, + (byte)0xf4, + (byte)0xf3, + (byte)0xf7, 0x40, 0x01, 0x00, + (byte)0xa4, + (byte)0xf0, + (byte)0xf6, + (byte)0xf1, + (byte)0xf5, + (byte)0xf2, 0x00, 0x40, + (byte)0xf5, + (byte)0xa0, + (byte)0xa4, + (byte)0xa3, 0x00, 0x00, 0x01, + (byte)0xf5, 0x02, + (byte)0xf6, 0x00, + (byte)0xa0, 0x00, + (byte)0xa3, 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x40, 0x02, 0x00, + (byte)0xf6, + (byte)0xa3, 0x00, + (byte)0xf7, 0x01, 0x00, 0x02, 0x01, 0x02, + (byte)0xa3, + (byte)0xa4, + (byte)0xa4, 0x00, + (byte)0xf4, 0x01, + (byte)0xf5, 0x02, 0x00, 0x40, + (byte)0xf7, 0x00, + (byte)0xa4, + (byte)0xf1, + (byte)0xf6, + (byte)0xf2, + (byte)0xf4, + (byte)0xf3, + (byte)0xf5, 0x40, + (byte)0xa0, + (byte)0xf7, + (byte)0xa4, 0x00, 0x00, 0x01, + (byte)0xa0, 0x02, + (byte)0xf5, 0x40, 0x00, 0x02, 0x40, 0x01, + (byte)0xf7, + (byte)0xa4, + (byte)0xa3, + (byte)0xa3, 0x00, + (byte)0xf6, 0x01, + (byte)0xf4, 0x02, + (byte)0xf4, 0x02, + (byte)0xa3, + (byte)0xf0, + (byte)0xf6, + (byte)0xf1, + (byte)0xf4, + (byte)0xf2, 0x01, + (byte)0xf4, + (byte)0xa3, + (byte)0xa4, + (byte)0xa3, + (byte)0xf1, + (byte)0xf4, + (byte)0xf2, + (byte)0xa0, + (byte)0xf3, 0x01, + (byte)0xf6, + (byte)0xa0, + (byte)0xf6, + (byte)0xa3, + (byte)0xf0, + (byte)0xf5, + (byte)0xf1, 0x00, + (byte)0xf2, + (byte)0xf5, 0x02, 0x40, + (byte)0xf6, + (byte)0xf6, + (byte)0xa4, + (byte)0xf0, 0x01, + (byte)0xf1, + (byte)0xf4, + (byte)0xf2, + (byte)0xf6, 0x40, + (byte)0xf4, + (byte)0xa0, + (byte)0xa4, + (byte)0xa3, + (byte)0xa4, 0x00, + (byte)0xa0, 0x01, 0x00, 0x02, + (byte)0xf6, 0x40, + (byte)0xf4, 0x00, + (byte)0xa4, + (byte)0xa4, + (byte)0xf0, + (byte)0xf4, + (byte)0xf1, + (byte)0xf5, + (byte)0xf2, 0x00, 0x40, + (byte)0xa0, + (byte)0xf6, + (byte)0xa4, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x40, + (byte)0xf6, + (byte)0xa0, + (byte)0xa4, + (byte)0xf1, + (byte)0xf5, + (byte)0xf2, + (byte)0xf4, + (byte)0xf3, + (byte)0xf4, 0x40, + (byte)0xf5, + (byte)0xa0, 0x40, + (byte)0xf7, 0x02, + (byte)0xa4, + (byte)0xa4, 0x00, 0x02, 0x01, 0x02, 0x02, 0x01, 0x40, + (byte)0xf5, + (byte)0xf7, + (byte)0xa4, + (byte)0xf1, + (byte)0xa0, + (byte)0xf2, + (byte)0xf6, + (byte)0xf3, + (byte)0xf4, 0x40, + (byte)0xf6, + (byte)0xf4, + (byte)0xa4, + (byte)0xf0, 0x00, + (byte)0xf1, + (byte)0xf7, + (byte)0xf2, 0x02, 0x40, + (byte)0xf4, + (byte)0xf4, 0x40, 0x02, + (byte)0xf4, + (byte)0xf6, + (byte)0xa3, + (byte)0xf1, + (byte)0xf5, + (byte)0xf2, + (byte)0xf6, + (byte)0xf3, 0x00, + (byte)0xf7, + (byte)0xa3, + (byte)0xf0, + (byte)0xf7, + (byte)0xf1, + (byte)0xf5, + (byte)0xf2, 0x00, 0x01, 0x40, 0x01, 0x01, 0x00, + (byte)0xf7, + (byte)0xa0, 0x00, + (byte)0xa3, + (byte)0xa4, + (byte)0xf1, 0x02, + (byte)0xf2, + (byte)0xf4, + (byte)0xf3, + (byte)0xf7, 0x40, + (byte)0xf6, + (byte)0xf7, + (byte)0xa4, + (byte)0xf1, + (byte)0xf6, + (byte)0xf2, + (byte)0xf4, + (byte)0xf3, + (byte)0xf4, 0x40, + (byte)0xf6, + (byte)0xf6, + (byte)0xa4, + (byte)0xa3, + (byte)0xf1, + (byte)0xf6, + (byte)0xf2, 0x00, + (byte)0xf3, + (byte)0xf4, + (byte)0xf5, + (byte)0xa0, + (byte)0xf6, + (byte)0xa3, 0x00, 0x01, 0x01, + (byte)0xa0, 0x02, 0x01, + (byte)0xa0, 0x40, 0x02, 0x00, + (byte)0xf5, 0x40, + (byte)0xf5, + (byte)0xa0, + (byte)0xa4, + (byte)0xa3, 0x00, + (byte)0xf5, 0x01, 0x02, 0x02, 0x00, + (byte)0xf6, + (byte)0xa0, + (byte)0xf6, + (byte)0xa3, + (byte)0xf1, + (byte)0xf6, + (byte)0xf2, + (byte)0xf5, + (byte)0xf3, + (byte)0xf5, 0x00, 0x40, + (byte)0xf5, + (byte)0xf6, 0x02, 0x40, 0x01, 0x01, + (byte)0xa4, + (byte)0xf1, + (byte)0xa0, + (byte)0xf2, 0x01, + (byte)0xf3, + (byte)0xf5, 0x40, 0x00, 0x02, + (byte)0xa0, + (byte)0xa0, 0x00, + (byte)0xa3, + (byte)0xf0, + (byte)0xf4, + (byte)0xf1, + (byte)0xa0, + (byte)0xf2, 0x00, 0x01, 0x40, 0x02, 0x00, + (byte)0xa4, + (byte)0xf0, 0x01, + (byte)0xf1, 0x02, + (byte)0xf2, + (byte)0xa0, 0x40, + (byte)0xf5, 0x02, + (byte)0xa4, + (byte)0xa3, + (byte)0xf0, 0x00, + (byte)0xf1, 0x01, + (byte)0xf2, + (byte)0xf5, + (byte)0xf7, + (byte)0xa3, + (byte)0xa3, + (byte)0xf1, 0x01, + (byte)0xf2, 0x01, + (byte)0xf3, 0x01, + (byte)0xa0, + (byte)0xa0, 0x01, + (byte)0xa3, + (byte)0xf1, + (byte)0xf4, + (byte)0xf2, 0x00, + (byte)0xf3, + (byte)0xf4, + (byte)0xf6, 0x02, + (byte)0xa3, + (byte)0xf1, + (byte)0xf4, + (byte)0xf2, 0x01, + (byte)0xf3, + (byte)0xf4, 0x02, 0x40, 0x00, + (byte)0xa0, 0x40, + (byte)0xa0, + (byte)0xf5, + (byte)0xa4, + (byte)0xf0, + (byte)0xf7, + (byte)0xf1, + (byte)0xf4, + (byte)0xf2, + (byte)0xa0, 0x40, + (byte)0xa0, 0x00, + (byte)0xa4, 0x00, 0x00, 0x01, + (byte)0xa0, 0x02, + (byte)0xf5, 0x40, + (byte)0xf7, + (byte)0xf7, 0x00, + (byte)0xa3, 0x00, 0x01, 0x01, 0x01, 0x02, + (byte)0xf4, + (byte)0xf7, + (byte)0xf7, + (byte)0xa0, + (byte)0xa0, + (byte)0xa3, + (byte)0xf0, + (byte)0xf6, + (byte)0xf1, 0x01, + (byte)0xf2, 0x01, 0x00, + (byte)0xf6, 0x40, + (byte)0xf6, + (byte)0xf6, + (byte)0xa4, + (byte)0xf1, + (byte)0xf7, + (byte)0xf2, 0x01, + (byte)0xf3, 0x01, 0x40, + (byte)0xf7, + (byte)0xf5, + (byte)0xa4, + (byte)0xf1, + (byte)0xf6, + (byte)0xf2, 0x00, + (byte)0xf3, + (byte)0xa0, 0x40, 0x01, 0x02, 0x40, 0x01, + (byte)0xa0, + (byte)0xa0, 0x02, 0x40, 0x01, 0x02, + (byte)0xa4, + (byte)0xf0, + (byte)0xf4, + (byte)0xf1, + (byte)0xf5, + (byte)0xf2, + (byte)0xf5, 0x40, + (byte)0xf7, + (byte)0xa0, + (byte)0xf5, + (byte)0xa0, + (byte)0xf5, + (byte)0xa3, 0x00, + (byte)0xf6, 0x01, (byte)0xf6, 0x02, (byte)0xa0, (byte)0xf4, 0x40, + (byte)0xf7, + }; + var options = new CBOREncodeOptions("allowduplicatekeys=1"); + for (var i = 0; i < 10; ++i) { + CBORObject.DecodeFromBytes(bytes, options); + } + } } }