🔨 cleanup

parent 9d6b3731
{
"data3":"ColreUHAtuYoUOx1N4ZloouQt2o6ugnUT6eYtS10gu7niM8i0vEiNufpk1RlMQXaHXlIwQBDsMFDFUQcFeg2vW5eD259Xm",
"data4":"zCxriJhL726WNNTdJJzurgSA8vKT6rHA0cFCb9koZcLUMXg4rmoXVPqIHWYaCV0ovl2t6xm7I1Hm36jXpLlXEb8fRfbwBeTW2V0OAsVqYH8eAT",
"data0":"9EVqHm5ARqcEB5jq2D14U2bCJPyBY0JWDr1Tjh8gTB0sWUNjqYiWDxFzlx6S",
"data7":"Bi1ujcgEvfADfBeyZudE7nwxc3Ik8qpYjsJIfKmwOMEbV2L3Bi0x2tcRpGuf4fiyvIbypDvJN1PPdQtfQW1Gv6zccXHwwZwKzUq6",
"data5":{
"integers":[
756509,
116117,
776378,
275045,
703447,
50156,
685803,
147958,
941747,
905651,
57367,
530248,
312888,
740951,
988947,
450154
],
"float1":76.572,
"float2":83.5299,
"nested1":{
"integers":[
756509,
116117,
776378,
275045,
703447,
50156,
685803,
147958,
941747,
905651,
57367,
530248,
312888,
740951,
988947,
450154
],
"floats":[
43121609.5543,
99454976.3019,
32945584.756,
18122905.9212,
45893183.44,
63052200.6225,
69032152.6897,
3748217.6946,
75449850.474,
37111527.415,
84852536.859,
32906366.487,
27027600.417,
63874310.5614,
39440408.51,
97176857.1716,
97438252.1171,
49728043.5056,
40818570.245,
41415831.8949,
24796297.4251,
2819085.3449,
84263963.4848,
74503228.6878,
67925677.403,
4758851.9417,
75227407.9214,
76946667.8403,
72518275.9469,
94167085.9588,
75883067.8321,
27389831.6101,
57987075.5053,
1298995.2674,
14590614.6939,
45292214.2242,
3332166.364,
53784167.729,
25193846.1867,
81456965.477,
68532032.39,
73820009.7952,
57736110.5717,
37304166.7363,
20054244.864,
29746392.7397,
86467624.6,
45192685.8793,
44008816.5186,
1861872.8736,
14595859.467,
87795257.6703,
57768720.8303,
18290154.3126,
45893183.44,
63052200.6225,
69032152.6897,
3748217.6946,
75449850.474,
37111527.415,
84852536.859,
32906366.487,
27027600.417,
63874310.5614,
39440408.51,
97176857.1716,
97438252.1171,
49728043.5056,
40818570.245,
41415831.8949,
24796297.4251,
2819085.3449,
84263963.4848,
74503228.6878,
67925677.403,
4758851.9417,
75227407.9214,
76946667.8403,
72518275.9469,
94167085.9588,
75883067.8321,
27389831.6101,
57987075.5053,
1298995.2674,
80858801.2712,
98262252.4656,
51612877.944,
33397812.7835,
36089655.3049,
50164685.8153,
16852105.5192,
61171929.752,
86376339.7175,
73009014.5521,
7397302.331,
34345128.9589,
98343269.4418,
95039116.9058,
44833102.5752,
51052997.8873,
22719195.6783,
64883244.8699
]
},
"nested2":{
"integers":[
756509,
116117,
776378,
275045,
703447,
50156,
685803,
147958,
941747,
905651,
57367,
530248,
312888,
740951,
988947,
450154
],
"float1":76.572,
"float2":83.5299
}
},
"strings":[
"edx5XzRkPVeEW2MBQzQMcUSuMI4FntjhlJ9VGhQaBHKPEazAaT",
"2fQUbzRUax4A",
"jURcBZ0vrJcmf2roZUMzZJQoTsKZDIdj7KhO7itskKvM80jBU9",
"8jKLmo3N2zYdKyTyfTczfr2x6bPaarorlnTNJ7r8lIkiZyBvrP",
"jbUeAVOdBSPzYmYhH0sabUHUH39O5e",
"I8yAQKZsyZhMfpzWjArQU9pQ6PfU6b14q2eWvQjtCUdgAUxFjg",
"97N8ZmGcxRZO4ZabzRRcY4KVHqxJwQ8qY",
"0DtY1aWXmUfJENt9rYW9",
"DtpBUEppPwMnWexi8eIIxlXRO3GUpPgeNFG9ONpWJYvk8xBkVj",
"YsX8V2xOrTw6LhNIMMhO4F4VXFyXUXFr66L3sTkLWgFA9NZuBV",
"fKYYthv8iFvaYoFoYZyB",
"zGuLsPXoJqMbO4PcePteZfDMYFXdWtvNF8WvaplXypsd6"
],
"data1":"9EVqHm5ARqcEB5jq21v2g0jVcG9CXB0Abk7uAF4NHYyTzeF3TnHhpZBECD14U2bCJPyBY0JWDr1Tjh8gTB0sWUNjqYiWDxFzlx6S",
"integers":[
756509,
116117,
776378,
275045,
703447,
50156,
685803,
147958,
941747,
905651,
57367,
530248,
312888,
740951,
988947,
450154
],
"more_nested":{
"integers":[
756509,
116117,
776378,
275045,
703447,
50156,
685803,
147958,
941747,
905651,
57367,
530248,
312888,
740951,
988947,
450154
],
"float1":76.572,
"float2":83.5299,
"nested1":{
"integers":[
756509,
116117,
776378,
275045,
703447,
50156,
685803,
147958,
941747,
905651,
57367,
530248,
312888,
740951,
988947,
450154
]
},
"nested2":{
"strings":[
"2fQUbzRUax4A",
"jURcBZ0vrJcmf2roZUMzZJQoTsKZDIdj7KhO7itskKvM80jBU9",
"8jKLmo3N2zYdKyTyfTczfr2x6bPaarorlnTNJ7r8lIkiZyBvrP",
"jbUeAVOdBSPzYmYhH0sabUHUH39O5e",
"I8yAQKZsyZhMfpzWjArQU9pQ6PfU6b14q2eWvQjtCUdgAUxFjg",
"97N8ZmGcxRZO4ZabzRRcY4KVHqxJwQ8qY",
"0DtY1aWXmUfJENt9rYW9",
"DtpBUEppPwMnWexi8eIIxlXRO3GUpPgeNFG9ONpWJYvk8xBkVj",
"YsX8V2xOrTw6LhNIMMhO4F4VXFyXUXFr66L3sTkLWgFA9NZuBV",
"fKYYthv8iFvaYoFoYZyB",
"zGuLsPXoJqMbO4PcePteZfDMYFXdWtvNF8WvaplXypsd6"
],
"integers":[
756509,
116117,
776378,
57367,
530248,
312888,
740951,
988947,
450154
]
}
}
}
\ No newline at end of file
This diff is collapsed.
{
"Media":{
"uri":"http://javaone.com/keynote.mpg",
"title":"Javaone Keynote",
"width":640,
"height":480,
"format":"video/mpg4",
"duration":18000000,
"size":58982400,
"bitrate":262144,
"persons":[
"Bill Gates",
"Steve Jobs"
],
"player":"JAVA",
"copyright":null
},
"Images":[
{
"uri":"http://javaone.com/keynote_large.jpg",
"title":"Javaone Keynote",
"width":1024,
"height":768,
"size":"LARGE"
},
{
"uri":"http://javaone.com/keynote_small.jpg",
"title":"Javaone Keynote",
"width":320,
"height":240,
"size":"SMALL"
}
]
}
\ No newline at end of file
This diff is collapsed.
{
"id_str":"121769183821312000",
"retweet_count":0,
"in_reply_to_screen_name":null,
"in_reply_to_user_id":null,
"truncated":false,
"retweeted":false,
"possibly_sensitive":false,
"in_reply_to_status_id_str":null,
"entities":{
"urls":[
{
"url":"http:\/\/t.co\/wtioKkFS",
"display_url":"dlvr.it\/pWQy2",
"indices":[
33,
53
],
"expanded_url":"http:\/\/dlvr.it\/pWQy2"
}
],
"hashtags":[
],
"user_mentions":[
]
},
"geo":null,
"place":null,
"coordinates":null,
"created_at":"Thu Oct 06 02:10:10 +0000 2011",
"in_reply_to_user_id_str":null,
"user":{
"id_str":"77029015",
"profile_link_color":"009999",
"protected":false,
"url":"http:\/\/www.techday.co.nz\/",
"screen_name":"techdaynz",
"statuses_count":5144,
"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1479058408\/techday_48_normal.jpg",
"name":"TechDay",
"default_profile_image":false,
"default_profile":false,
"profile_background_color":"131516",
"lang":"en",
"profile_background_tile":false,
"utc_offset":43200,
"description":"",
"is_translator":false,
"show_all_inline_media":false,
"contributors_enabled":false,
"profile_background_image_url_https":"https:\/\/si0.twimg.com\/profile_background_images\/75893948\/Techday_Background.jpg",
"created_at":"Thu Sep 24 20:02:01 +0000 2009",
"profile_sidebar_fill_color":"efefef",
"follow_request_sent":false,
"friends_count":3215,
"followers_count":3149,
"time_zone":"Auckland",
"favourites_count":0,
"profile_sidebar_border_color":"eeeeee",
"profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/1479058408\/techday_48_normal.jpg",
"following":false,
"geo_enabled":false,
"notifications":false,
"profile_use_background_image":true,
"listed_count":151,
"verified":false,
"profile_text_color":"333333",
"location":"Ponsonby, Auckland, NZ",
"id":77029015,
"profile_background_image_url":"http:\/\/a0.twimg.com\/profile_background_images\/75893948\/Techday_Background.jpg"
},
"contributors":null,
"source":"\u003Ca href=\"http:\/\/dlvr.it\" rel=\"nofollow\"\u003Edlvr.it\u003C\/a\u003E",
"in_reply_to_status_id":null,
"favorited":false,
"id":121769183821312000,
"text":"Apple CEO's message to employees http:\/\/t.co\/wtioKkFS"
}
\ No newline at end of file
https://github.com/ubjson/universal-binary-json-java/tree/master/src/test/resources/org/ubjson
\ No newline at end of file
...@@ -1165,13 +1165,6 @@ TEST_CASE("UBJSON") ...@@ -1165,13 +1165,6 @@ TEST_CASE("UBJSON")
SECTION("errors") SECTION("errors")
{ {
SECTION("empty byte vector")
{
CHECK_THROWS_AS(json::from_ubjson(std::vector<uint8_t>()), json::parse_error&);
CHECK_THROWS_WITH(json::from_ubjson(std::vector<uint8_t>()),
"[json.exception.parse_error.110] parse error at 1: unexpected end of input");
}
SECTION("strict mode") SECTION("strict mode")
{ {
std::vector<uint8_t> vec = {'Z', 'Z'}; std::vector<uint8_t> vec = {'Z', 'Z'};
...@@ -1335,6 +1328,13 @@ TEST_CASE("UBJSON") ...@@ -1335,6 +1328,13 @@ TEST_CASE("UBJSON")
SECTION("parse errors") SECTION("parse errors")
{ {
SECTION("empty byte vector")
{
CHECK_THROWS_AS(json::from_ubjson(std::vector<uint8_t>()), json::parse_error&);
CHECK_THROWS_WITH(json::from_ubjson(std::vector<uint8_t>()),
"[json.exception.parse_error.110] parse error at 1: unexpected end of input");
}
SECTION("char") SECTION("char")
{ {
SECTION("eof after C byte") SECTION("eof after C byte")
...@@ -1477,8 +1477,9 @@ TEST_CASE("UBJSON") ...@@ -1477,8 +1477,9 @@ TEST_CASE("UBJSON")
} }
} }
/*
// use this testcase outside [hide] to run it with Valgrind // use this testcase outside [hide] to run it with Valgrind
TEST_CASE("single CBOR roundtrip") TEST_CASE("single UBJSON roundtrip")
{ {
SECTION("sample.json") SECTION("sample.json")
{ {
...@@ -1489,11 +1490,11 @@ TEST_CASE("single CBOR roundtrip") ...@@ -1489,11 +1490,11 @@ TEST_CASE("single CBOR roundtrip")
json j1 = json::parse(f_json); json j1 = json::parse(f_json);
// parse MessagePack file // parse MessagePack file
std::ifstream f_cbor(filename + ".cbor", std::ios::binary); std::ifstream f_ubjson(filename + ".ubj", std::ios::binary);
std::vector<uint8_t> packed((std::istreambuf_iterator<char>(f_cbor)), std::vector<uint8_t> packed((std::istreambuf_iterator<char>(f_ubjson)),
std::istreambuf_iterator<char>()); std::istreambuf_iterator<char>());
json j2; json j2;
CHECK_NOTHROW(j2 = json::from_cbor(packed)); CHECK_NOTHROW(j2 = json::from_ubjson(packed));
// compare parsed JSON values // compare parsed JSON values
CHECK(j1 == j2); CHECK(j1 == j2);
...@@ -1503,29 +1504,31 @@ TEST_CASE("single CBOR roundtrip") ...@@ -1503,29 +1504,31 @@ TEST_CASE("single CBOR roundtrip")
SECTION("std::ostringstream") SECTION("std::ostringstream")
{ {
std::ostringstream ss; std::ostringstream ss;
json::to_cbor(j1, ss); json::to_ubjson(j1, ss);
json j3 = json::from_cbor(ss.str()); json j3 = json::from_ubjson(ss.str());
CHECK(j1 == j3); CHECK(j1 == j3);
} }
SECTION("std::string") SECTION("std::string")
{ {
std::string s; std::string s;
json::to_cbor(j1, s); json::to_ubjson(j1, s);
json j3 = json::from_cbor(s); json j3 = json::from_ubjson(s);
CHECK(j1 == j3); CHECK(j1 == j3);
} }
} }
// check with different start index // check with different start index
packed.insert(packed.begin(), 5, 0xff); // packed.insert(packed.begin(), 5, 0xff);
CHECK(j1 == json::from_cbor(packed.begin() + 5, packed.end())); // CHECK(j1 == json::from_ubjson(packed.begin() + 5, packed.end()));
} }
} }
*/
TEST_CASE("CBOR roundtrips", "[hide]") /*
TEST_CASE("UBJSON roundtrips", "[hide]")
{ {
SECTION("input from flynn") SECTION("input from py-ubjson")
{ {
for (std::string filename : for (std::string filename :
{ {
...@@ -1684,13 +1687,13 @@ TEST_CASE("CBOR roundtrips", "[hide]") ...@@ -1684,13 +1687,13 @@ TEST_CASE("CBOR roundtrips", "[hide]")
SECTION("std::vector<uint8_t>") SECTION("std::vector<uint8_t>")
{ {
// parse CBOR file // parse UBJSON file
std::ifstream f_cbor(filename + ".cbor", std::ios::binary); std::ifstream f_ubjson(filename + ".ubj", std::ios::binary);
std::vector<uint8_t> packed( std::vector<uint8_t> packed(
(std::istreambuf_iterator<char>(f_cbor)), (std::istreambuf_iterator<char>(f_ubjson)),
std::istreambuf_iterator<char>()); std::istreambuf_iterator<char>());
json j2; json j2;
CHECK_NOTHROW(j2 = json::from_cbor(packed)); CHECK_NOTHROW(j2 = json::from_ubjson(packed));
// compare parsed JSON values // compare parsed JSON values
CHECK(j1 == j2); CHECK(j1 == j2);
...@@ -1698,10 +1701,10 @@ TEST_CASE("CBOR roundtrips", "[hide]") ...@@ -1698,10 +1701,10 @@ TEST_CASE("CBOR roundtrips", "[hide]")
SECTION("std::ifstream") SECTION("std::ifstream")
{ {
// parse CBOR file // parse UBJSON file
std::ifstream f_cbor(filename + ".cbor", std::ios::binary); std::ifstream f_ubjson(filename + ".ubj", std::ios::binary);
json j2; json j2;
CHECK_NOTHROW(j2 = json::from_cbor(f_cbor)); CHECK_NOTHROW(j2 = json::from_ubjson(f_ubjson));
// compare parsed JSON values // compare parsed JSON values
CHECK(j1 == j2); CHECK(j1 == j2);
...@@ -1709,36 +1712,21 @@ TEST_CASE("CBOR roundtrips", "[hide]") ...@@ -1709,36 +1712,21 @@ TEST_CASE("CBOR roundtrips", "[hide]")
SECTION("uint8_t* and size") SECTION("uint8_t* and size")
{ {
// parse CBOR file // parse UBJSON file
std::ifstream f_cbor(filename + ".cbor", std::ios::binary); std::ifstream f_ubjson(filename + ".ubj", std::ios::binary);
std::vector<uint8_t> packed( std::vector<uint8_t> packed(
(std::istreambuf_iterator<char>(f_cbor)), (std::istreambuf_iterator<char>(f_ubjson)),
std::istreambuf_iterator<char>()); std::istreambuf_iterator<char>());
json j2; json j2;
CHECK_NOTHROW(j2 = json::from_cbor({packed.data(), packed.size()})); CHECK_NOTHROW(j2 = json::from_ubjson({packed.data(), packed.size()}));
// compare parsed JSON values // compare parsed JSON values
CHECK(j1 == j2); CHECK(j1 == j2);
} }
SECTION("output to output adapters")
{
// parse CBOR file
std::ifstream f_cbor(filename + ".cbor", std::ios::binary);
std::vector<uint8_t> packed(
(std::istreambuf_iterator<char>(f_cbor)),
std::istreambuf_iterator<char>());
SECTION("std::vector<uint8_t>")
{
std::vector<uint8_t> vec;
json::to_cbor(j1, vec);
CHECK(vec == packed);
}
}
} }
} }
} }
*/
TEST_CASE("Universal Binary JSON Specification Examples 1") TEST_CASE("Universal Binary JSON Specification Examples 1")
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment