Skip to content

Commit

Permalink
Added insitu parsing test for kParseStopWhenDoneFlag
Browse files Browse the repository at this point in the history
Related to discussion in #83
  • Loading branch information
miloyip committed Jul 29, 2014
1 parent e6f3446 commit fdd380b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/unittest/readertest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]; \
Expand Down

0 comments on commit fdd380b

Please sign in to comment.