Skip to content

Commit

Permalink
Bug 1284031 (Part 2) - Add new StreamingLexer tests for zero-length s…
Browse files Browse the repository at this point in the history
…tates. r=njn
  • Loading branch information
sethfowler committed Jul 16, 2016
1 parent 1a552d6 commit c9df47a
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions image/test/gtest/TestStreamingLexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,40 @@ TEST_F(ImageStreamingLexer, OneByteChunksWithUnbufferedFromSourceBuffer)
mSourceBuffer->Complete(NS_OK);
}

TEST_F(ImageStreamingLexer, ZeroLengthState)
{
mSourceBuffer->Append(mData, sizeof(mData));
mSourceBuffer->Complete(NS_OK);

// Create a special StreamingLexer for this test because we want the first
// state to be zero length.
StreamingLexer<TestState> lexer(Transition::To(TestState::ONE, 0));

Maybe<TerminalState> result =
lexer.Lex(mIterator, mExpectNoResume, DoLexWithZeroLengthStates);

EXPECT_TRUE(result.isSome());
EXPECT_EQ(Some(TerminalState::SUCCESS), result);
}

TEST_F(ImageStreamingLexer, ZeroLengthStateWithUnbuffered)
{
mSourceBuffer->Append(mData, sizeof(mData));
mSourceBuffer->Complete(NS_OK);

// Create a special StreamingLexer for this test because we want the first
// state to be both zero length and unbuffered.
StreamingLexer<TestState> lexer(Transition::ToUnbuffered(TestState::ONE,
TestState::UNBUFFERED,
0));

Maybe<TerminalState> result =
lexer.Lex(mIterator, mExpectNoResume, DoLexWithZeroLengthStatesUnbuffered);

EXPECT_TRUE(result.isSome());
EXPECT_EQ(Some(TerminalState::SUCCESS), result);
}

TEST_F(ImageStreamingLexer, TerminateSuccessFromSourceBuffer)
{
mSourceBuffer->Append(mData, sizeof(mData));
Expand Down

0 comments on commit c9df47a

Please sign in to comment.