mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-14 11:06:35 +02:00
Test with a missing closing brace
This commit is contained in:
@ -151,8 +151,13 @@ JsonNode* JsonParser::parseArray()
|
||||
|
||||
JsonNode* JsonParser::parseObject()
|
||||
{
|
||||
_ptr+=2;
|
||||
return _buffer->createObjectNode();
|
||||
JsonNode* node = _buffer->createObjectNode();
|
||||
|
||||
skipOneChar(); // skip the '['
|
||||
skipSpaces();
|
||||
|
||||
if (isObjectStop())
|
||||
return node;
|
||||
}
|
||||
|
||||
JsonNode *JsonParser::parseBoolean()
|
||||
|
@ -7,14 +7,43 @@ class JsonParser_Object_Test : public testing::Test
|
||||
{
|
||||
protected:
|
||||
|
||||
void whenInputIs(const char* jsonString)
|
||||
{
|
||||
strcpy(_jsonString, jsonString);
|
||||
_object = _jsonBuffer.parseObject(_jsonString);
|
||||
}
|
||||
|
||||
void parseMustSucceed()
|
||||
{
|
||||
EXPECT_TRUE(_object.success());
|
||||
}
|
||||
|
||||
void parseMustFail()
|
||||
{
|
||||
EXPECT_FALSE(_object.success());
|
||||
}
|
||||
|
||||
void sizeMustBe(int expected)
|
||||
{
|
||||
EXPECT_EQ(expected, _object.size());
|
||||
}
|
||||
|
||||
private:
|
||||
StaticJsonBuffer<10> _jsonBuffer;
|
||||
JsonObject _object;
|
||||
char _jsonString[256];
|
||||
};
|
||||
|
||||
TEST_F(JsonParser_Object_Test, EmptyObject)
|
||||
{
|
||||
StaticJsonBuffer<10> jsonBuffer;
|
||||
char jsonString[] = "{}";
|
||||
JsonObject object = jsonBuffer.parseObject(jsonString);
|
||||
whenInputIs("{}");
|
||||
parseMustSucceed();
|
||||
sizeMustBe(0);
|
||||
}
|
||||
|
||||
EXPECT_TRUE(object.success());
|
||||
TEST_F(JsonParser_Object_Test, MissingClosingBrace)
|
||||
{
|
||||
whenInputIs("{");
|
||||
parseMustFail();
|
||||
sizeMustBe(0);
|
||||
}
|
Reference in New Issue
Block a user