Merge pull request #166 from spl/fix-memorystream-peek

Fix MemoryStream::Peek() and add test for fix
This commit is contained in:
Milo Yip
2014-10-23 12:46:33 +08:00
2 changed files with 11 additions and 1 deletions

View File

@@ -21,6 +21,7 @@
#include "unittest.h"
#include "rapidjson/reader.h"
#include "rapidjson/memorystream.h"
using namespace rapidjson;
@@ -674,6 +675,15 @@ TEST(Reader, ParseObject_Error) {
// Must be a comma or '}' after an object member
TEST_ERROR(kParseErrorObjectMissCommaOrCurlyBracket, "{\"a\":1]");
// This tests that MemoryStream is checking the length in Peek().
{
MemoryStream ms("{\"a\"", 1);
BaseReaderHandler<> h;
Reader reader;
EXPECT_FALSE(reader.Parse<kParseStopWhenDoneFlag>(ms, h));
EXPECT_EQ(kParseErrorObjectMissName, reader.GetParseErrorCode());
}
}
#undef TEST_ERROR