Commit face7240 authored by thebusytypist's avatar thebusytypist

Revise unittests of compound value(array or object)'s initial state transition.

parent 3038a785
...@@ -809,7 +809,7 @@ struct IterativeParsingReaderHandler { ...@@ -809,7 +809,7 @@ struct IterativeParsingReaderHandler {
} }
TEST(Reader, IterativeParsing_StateTransition_Start) { TEST(Reader, IterativeParsing_StateTransition_Start) {
// Start->ArrayInitial // Start -> ArrayInitial
{ {
IterativeParsingReaderHandler<> handler; IterativeParsingReaderHandler<> handler;
Reader reader; Reader reader;
...@@ -823,7 +823,7 @@ TEST(Reader, IterativeParsing_StateTransition_Start) { ...@@ -823,7 +823,7 @@ TEST(Reader, IterativeParsing_StateTransition_Start) {
EXPECT_TRUE(handler.IsStartArrayTriggered); EXPECT_TRUE(handler.IsStartArrayTriggered);
} }
// Start->ObjectInitial // Start -> ObjectInitial
{ {
IterativeParsingReaderHandler<> handler; IterativeParsingReaderHandler<> handler;
Reader reader; Reader reader;
...@@ -965,7 +965,7 @@ TEST(Reader, IterativeParsing_StateTransition_KeyValueDelimiter) { ...@@ -965,7 +965,7 @@ TEST(Reader, IterativeParsing_StateTransition_KeyValueDelimiter) {
} }
TEST(Reader, IterativeParsing_StateTransition_MemberValue) { TEST(Reader, IterativeParsing_StateTransition_MemberValue) {
// MemberValue -> ObjectFinish // MemberValue -> ObjectFinish -> Finish
{ {
ITERATIVE_PARSING_PREPARE_STATE_UNTIL("{\"k\": 123}", 9); ITERATIVE_PARSING_PREPARE_STATE_UNTIL("{\"k\": 123}", 9);
handler.Reset(); handler.Reset();
...@@ -1025,12 +1025,26 @@ TEST(Reader, IterativeParsing_StateTransition_MemberDelimiter) { ...@@ -1025,12 +1025,26 @@ TEST(Reader, IterativeParsing_StateTransition_MemberDelimiter) {
TEST(Reader, IterativeParsing_StateTransition_ArrayInitial) { TEST(Reader, IterativeParsing_StateTransition_ArrayInitial) {
// ArrayInitial -> ArrayInitial // ArrayInitial -> ArrayInitial
{ {
TEST_COMPOUNDTYPE_INITIAL_STATE( ITERATIVE_PARSING_PREPARE_STATE_UNTIL("[[1]]", 1);
Array, handler.Reset();
"[]",
Reader::IterativeParsingArrayInitialState, EXPECT_FALSE(reader.HasParseError());
EXPECT_EQ(Reader::IterativeParsingArrayInitialState, state);
Reader::IterativeParsingState d = reader.Transit<kParseIterativeFlag>(
state,
Reader::IterativeParsingLeftBracketToken, Reader::IterativeParsingLeftBracketToken,
Reader::IterativeParsingElementState); Reader::IterativeParsingArrayInitialState,
is, handler);
EXPECT_FALSE(reader.HasParseError());
EXPECT_EQ(Reader::IterativeParsingArrayInitialState, d);
// Check initialized element count.
int c = *reader.stack_.template Pop<int>(1);
EXPECT_EQ(0, c);
// Check pushed state.
Reader::IterativeParsingState s = *reader.stack_.template Pop<Reader::IterativeParsingState>(1);
EXPECT_EQ(Reader::IterativeParsingElementState, s);
} }
// ArrayInitial -> ArrayFinish -> Finish // ArrayInitial -> ArrayFinish -> Finish
...@@ -1055,12 +1069,26 @@ TEST(Reader, IterativeParsing_StateTransition_ArrayInitial) { ...@@ -1055,12 +1069,26 @@ TEST(Reader, IterativeParsing_StateTransition_ArrayInitial) {
// ArrayInitial -> ObjectInitial // ArrayInitial -> ObjectInitial
{ {
TEST_COMPOUNDTYPE_INITIAL_STATE( ITERATIVE_PARSING_PREPARE_STATE_UNTIL("[{\"k\": 1}]", 1);
Object, handler.Reset();
"{}",
Reader::IterativeParsingStartState, EXPECT_FALSE(reader.HasParseError());
EXPECT_EQ(Reader::IterativeParsingArrayInitialState, state);
Reader::IterativeParsingState d = reader.Transit<kParseIterativeFlag>(
state,
Reader::IterativeParsingLeftCurlyBracketToken, Reader::IterativeParsingLeftCurlyBracketToken,
Reader::IterativeParsingStartState); Reader::IterativeParsingObjectInitialState,
is, handler);
EXPECT_FALSE(reader.HasParseError());
EXPECT_EQ(Reader::IterativeParsingObjectInitialState, d);
// Check initialized element count.
int c = *reader.stack_.template Pop<int>(1);
EXPECT_EQ(0, c);
// Check pushed state.
Reader::IterativeParsingState s = *reader.stack_.template Pop<Reader::IterativeParsingState>(1);
EXPECT_EQ(Reader::IterativeParsingElementState, s);
} }
// ArrayInitial -> Element // ArrayInitial -> Element
......
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