Parse empty array with leading spaces

This commit is contained in:
Benoit Blanchon
2014-10-14 18:01:49 +02:00
parent 081b345e7c
commit 81f3460806
2 changed files with 10 additions and 0 deletions

View File

@ -22,6 +22,8 @@ JsonArray JsonBuffer::parseArray(const char* json)
{ {
JsonNode* root; JsonNode* root;
while(*json == ' ') json++;
if (json[0] == '[') if (json[0] == '[')
{ {
root = createNode(); root = createNode();

View File

@ -15,6 +15,14 @@ TEST_F(JsonArray_Parser_Tests, EmptyArray)
EXPECT_EQ(0, array.size()); EXPECT_EQ(0, array.size());
} }
TEST_F(JsonArray_Parser_Tests, EmptyArrayWithLeadingSpaces)
{
JsonArray array = json.parseArray(" []");
EXPECT_TRUE(array.success());
EXPECT_EQ(0, array.size());
}
TEST_F(JsonArray_Parser_Tests, Garbage) TEST_F(JsonArray_Parser_Tests, Garbage)
{ {
JsonArray array = json.parseArray("%*$£¤"); JsonArray array = json.parseArray("%*$£¤");