Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for dynamic objects that are not nested in any container …
…type (e.g. array or map).
- Loading branch information
Louis Somers
committed
Feb 26, 2021
1 parent
8f9edaa
commit 87979ec
Showing
18 changed files
with
705 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using LsMsgPack; | ||
using NUnit.Framework; | ||
|
||
namespace LsMsgPackUnitTests { | ||
[TestFixture] | ||
public class MpRootTests { | ||
|
||
[TestCase(7, 1, "hello")] | ||
[TestCase(13, new object[] { (byte)0, new object[] { (short)597, (short)492 }, new object[0], (byte)0, (byte)0, "\u0001" })] | ||
public void RoundTripTest(int expectedLength, params object[] items) { | ||
MpRoot root = MsgPackItem.PackMultiple(items); | ||
byte[] bytes = root.ToBytes(); | ||
|
||
Assert.AreEqual(expectedLength, bytes.Length, string.Concat("Expected ", expectedLength, " serialized bytes items but got ", bytes.Length, " bytes.")); | ||
|
||
MpRoot result = MsgPackItem.UnpackMultiple(bytes); | ||
|
||
Assert.AreEqual(items.Length, result.Count, string.Concat("Expected ",items.Length," items but got ", result.Count, " items after round trip.")); | ||
|
||
for (int t = 0; t < result.Count; t++) { | ||
object expected = items[t]; | ||
object actual = result[t].Value; | ||
|
||
Assert.AreEqual(expected, actual, "The returned value ", actual, " differs from the input value ", expected); | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="NUnit" version="3.10.1" targetFramework="net452" /> | ||
<package id="NUnit" version="3.13.1" targetFramework="net461" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.