Skip to content
This repository was archived by the owner on Mar 26, 2020. It is now read-only.

Commit c67b94b

Browse files
committed
Add chunk parsing tests.
1 parent bbf6855 commit c67b94b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,23 @@ JSON11_TEST_CASE(json11_test) {
250250
std::vector<Point> points = { { 1, 2 }, { 10, 20 }, { 100, 200 } };
251251
std::string points_json = Json(points).dump();
252252
printf("%s\n", points_json.c_str());
253+
254+
/* Test chunk parsing */
255+
JsonParser parser = { JsonParse::COMMENTS };
256+
for (auto c: simple_test) {
257+
parser.consume(std::string(1, c));
258+
}
259+
my_json = parser.json();
260+
JSON11_TEST_ASSERT(my_json == json);
261+
262+
parser.reset();
263+
for (auto c: comment_test) {
264+
parser.consume(std::string(1, c));
265+
}
266+
267+
my_json = parser.json();
268+
JSON11_TEST_ASSERT(parser.last_error().empty());
269+
JSON11_TEST_ASSERT(my_json == json_comment);
253270
}
254271

255272
#if JSON11_TEST_STANDALONE_MAIN

0 commit comments

Comments
 (0)