From fdd380bbc06ecd6f84769321fc7fe5e2fef3a89b Mon Sep 17 00:00:00 2001 From: miloyip Date: Tue, 29 Jul 2014 13:01:35 +0800 Subject: [PATCH] Added insitu parsing test for kParseStopWhenDoneFlag Related to discussion in #83 --- test/unittest/readertest.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/unittest/readertest.cpp b/test/unittest/readertest.cpp index 61bc38c8d..1b71db87b 100644 --- a/test/unittest/readertest.cpp +++ b/test/unittest/readertest.cpp @@ -578,6 +578,29 @@ TEST(Reader, ParseIterative_MultipleRoot) { TestMultipleRoot(); } +template +void TestInsituMultipleRoot() { + char* buffer = strdup("{}[] a"); + InsituStringStream s(buffer); + ParseMultipleRootHandler h; + Reader reader; + EXPECT_TRUE(reader.Parse(s, h)); + EXPECT_EQ(2u, h.step_); + EXPECT_TRUE(reader.Parse(s, h)); + EXPECT_EQ(4u, h.step_); + EXPECT_EQ(' ', s.Take()); + EXPECT_EQ('a', s.Take()); + free(buffer); +} + +TEST(Reader, ParseInsitu_MultipleRoot) { + TestInsituMultipleRoot(); +} + +TEST(Reader, ParseInsituIterative_MultipleRoot) { + TestInsituMultipleRoot(); +} + #define TEST_ERROR(errorCode, str) \ { \ char buffer[1001]; \