Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/miloyip/rapidjson.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authormiloyip <miloyip@gmail.com>2014-07-29 09:01:35 +0400
committermiloyip <miloyip@gmail.com>2014-07-29 09:01:35 +0400
commitfdd380bbc06ecd6f84769321fc7fe5e2fef3a89b (patch)
tree2553cf6aa2b2173ccbccf82b8240f2a743c77689 /test
parente6f344637b3163e74f0f1bd5f94d5595ed36d9d1 (diff)
Added insitu parsing test for kParseStopWhenDoneFlag
Related to discussion in #83
Diffstat (limited to 'test')
-rw-r--r--test/unittest/readertest.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/unittest/readertest.cpp b/test/unittest/readertest.cpp
index 61bc38c8..1b71db87 100644
--- a/test/unittest/readertest.cpp
+++ b/test/unittest/readertest.cpp
@@ -578,6 +578,29 @@ TEST(Reader, ParseIterative_MultipleRoot) {
TestMultipleRoot<kParseIterativeFlag | kParseStopWhenDoneFlag>();
}
+template <unsigned parseFlags>
+void TestInsituMultipleRoot() {
+ char* buffer = strdup("{}[] a");
+ InsituStringStream s(buffer);
+ ParseMultipleRootHandler h;
+ Reader reader;
+ EXPECT_TRUE(reader.Parse<kParseInsituFlag | parseFlags>(s, h));
+ EXPECT_EQ(2u, h.step_);
+ EXPECT_TRUE(reader.Parse<kParseInsituFlag | parseFlags>(s, h));
+ EXPECT_EQ(4u, h.step_);
+ EXPECT_EQ(' ', s.Take());
+ EXPECT_EQ('a', s.Take());
+ free(buffer);
+}
+
+TEST(Reader, ParseInsitu_MultipleRoot) {
+ TestInsituMultipleRoot<kParseStopWhenDoneFlag>();
+}
+
+TEST(Reader, ParseInsituIterative_MultipleRoot) {
+ TestInsituMultipleRoot<kParseIterativeFlag | kParseStopWhenDoneFlag>();
+}
+
#define TEST_ERROR(errorCode, str) \
{ \
char buffer[1001]; \