Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
peteroupc committed May 29, 2020
1 parent 63248bb commit 589d6d0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CBOR/PeterO/Cbor/CBORDataUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ private static long GetIntegerValue(long bits) {
long mant = bits & ((1L << 52) - 1);
mant |= 1L << 52;
int shift = 52 - (exp - 0x3ff);
return (mant >> shift) * sign;
return (mant >> shift) * sgn;
}

/// <summary>Parses a number whose format follows the JSON
Expand Down
29 changes: 15 additions & 14 deletions CBORTest/CBORObjectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ public class CBORObjectTest {
"\"\\ud800\udc00\"",
"\"\ud800\\udc00\"", "\"\\U0023\"", "\"\\u002x\"", "\"\\u00xx\"",
"\"\\u0xxx\"", "\"\\u0\"", "\"\\u00\"", "\"\\u000\"", "trbb",
"trub", "falsb", "nulb", "[true", "[true,", "[true]!","tr
","tr","fa","nu",
"fa ","nu ","fa lse","nu ll","tr ue",
"trub", "falsb", "nulb", "[true", "[true,", "[true]!", "tr\u0020",
"tr", "fa", "nu",
"fa ", "nu ", "fa lse", "nu ll", "tr ue",
"[\"\ud800\\udc00\"]", "[\"\\ud800\udc00\"]",
"[\"\\udc00\ud800\udc00\"]", "[\"\\ud800\ud800\udc00\"]",
"[\"\\ud800\"]", "[1,2,", "[1,2,3", "{,\"0\":0,\"1\":1}",
"{\"0\"::0}","{\"0\":0,,\"1\":1}",
"{\"0\":0,\"1\":1,}", "[,0,1,2]", "[0,,1,2]","[0:1]","[0:1:2]",
"{\"0\"::0}", "{\"0\":0,,\"1\":1}",
"{\"0\":0,\"1\":1,}", "[,0,1,2]", "[0,,1,2]", "[0:1]", "[0:1:2]",
"[0,1,,2]", "[0,1,2,]", "[0001]", "{a:true}",
"{\"a\"://comment\ntrue}", "{\"a\":/*comment*/true}", "{'a':true}",
"{\"a\":'b'}", "{\"a\t\":true}", "{\"a\r\":true}", "{\"a\n\":true}",
Expand All @@ -35,15 +35,16 @@ public class CBORObjectTest {
"true\u0005", "8024\"", "8024x", "8024}", "8024\u0300",
"8024\u0005", "{\"test\":5}}", "{\"test\":5}{", "[5]]", "[5][",
"0000", "0x1", "0xf", "0x20", "0x01",
"-3x", "-3e89x",
"-3x", "-3e89x", "\u0005true", "\"x\\u0005z\"",
"0,2", "0,05", "-0,2", "-0,05",
"0X1", "0Xf", "0X20", "0X01", ".2", ".05", "-.2",
"-.05", "23.", "23.e0", "23.e1", "0.", "[0000]", "[0x1]",
"[0xf]", "[0x20]", "[0x01]", "[.2]", "[.05]", "[-.2]", "[-.05]",
"[23.]", "[23.e0]", "[23.e1]", "[0.]", "\"abc", "\"ab\u0004c\"",
"\u0004\"abc\"",
"{\"x\":true \"y\":true}",
"{\"x\":true\n\"y\":true}",
"0,1,2,3","\"x\",true",
"0,1,2,3", "\"x\",true",
"\"x\",true",
"\"x\":true",
"\"x\":true,\"y\":true",
Expand All @@ -54,8 +55,8 @@ public class CBORObjectTest {
"{\"x\":true, \"y\"}",
"{\"x\", \"y\":true}",
"{[\"x\"]:true}",
"{null:true}","{true:true}","{false:true}",
"{[0]:true}","{1:true}","{{\"a\":true}:true}",
"{null:true}", "{true:true}", "{false:true}",
"{[0]:true}", "{1:true}", "{{\"a\":true}:true}",
"[1,\u0004" + "2]",
};

Expand All @@ -64,7 +65,7 @@ public class CBORObjectTest {
"[0.1]",
"[0.1001]",
"[0.0]",
"[-3 " + ",-5]",
"[-3 " + ",-5]", "\n\r\t\u0020true",
"[0.00]", "[0.000]", "[0.01]", "[0.001]", "[0.5]", "[0E5]",
"[0E+6]", "[\"\ud800\udc00\"]", "[\"\\ud800\\udc00\"]",
"[\"\\ud800\\udc00\ud800\udc00\"]", "23.0e01", "23.0e00", "[23.0e01]",
Expand Down Expand Up @@ -7189,9 +7190,9 @@ public static void AssertJSONInteger(
long longval) {
CBORObject cbor = FromJSON(json, numconv);
if (cbor.Type != CBORType.Integer) {
string msg = json+" "+numconv+" " + longval;
string msg = json+ " " + numconv + " " + longval;
msg = msg.Substring(0, Math.Min(100, msg.Length));
if (msg.Length > 100) {
if (msg.Length > 100) {
msg += "...";
}
Assert.AreEqual(CBORType.Integer, cbor.Type, msg);
Expand All @@ -7205,9 +7206,9 @@ public static void AssertJSONInteger(
int intval) {
CBORObject cbor = FromJSON(json, numconv);
if (cbor.Type != CBORType.Integer) {
string msg = json+" "+numconv+" " + intval;
string msg = json+ " " + numconv + " " + intval;
msg = msg.Substring(0, Math.Min(100, msg.Length));
if (msg.Length > 100) {
if (msg.Length > 100) {
{ msg += "...";
} }
Assert.AreEqual(CBORType.Integer, cbor.Type, msg);
Expand Down
Empty file added doc/created.rid
Empty file.
1 change: 1 addition & 0 deletions docs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<docs/>

0 comments on commit 589d6d0

Please sign in to comment.