mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-14 19:16:35 +02:00
Added JsonParser_String_Tests.cpp
This commit is contained in:
46
test/JsonParser_String_Tests.cpp
Normal file
46
test/JsonParser_String_Tests.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <ArduinoJson/StaticJsonBuffer.h>
|
||||
#include <ArduinoJson/JsonValue.h>
|
||||
|
||||
class JsonParser_String_Tests : public testing::Test
|
||||
{
|
||||
protected:
|
||||
void whenInputIs(const char* json)
|
||||
{
|
||||
strcpy(_jsonString, json);
|
||||
_result = _jsonBuffer.parseValue(_jsonString);
|
||||
}
|
||||
|
||||
void outputMustBe(const char* expected)
|
||||
{
|
||||
EXPECT_STREQ(expected, _result);
|
||||
}
|
||||
|
||||
char _jsonString[256];
|
||||
StaticJsonBuffer<42> _jsonBuffer;
|
||||
const char* _result;
|
||||
};
|
||||
|
||||
TEST_F(JsonParser_String_Tests, SimpleString)
|
||||
{
|
||||
whenInputIs("\"hello world\"");
|
||||
outputMustBe("hello world");
|
||||
}
|
||||
|
||||
TEST_F(JsonParser_String_Tests, CurlyBraces)
|
||||
{
|
||||
whenInputIs("\"{hello:world}\"");
|
||||
outputMustBe("{hello:world}");
|
||||
}
|
||||
|
||||
TEST_F(JsonParser_String_Tests, SquareBraquets)
|
||||
{
|
||||
whenInputIs("\"[hello,world]\"");
|
||||
outputMustBe("[hello,world]");
|
||||
}
|
||||
|
||||
TEST_F(JsonParser_String_Tests, EscapedQuote)
|
||||
{
|
||||
whenInputIs("\"hello \\\"world\\\"\"");
|
||||
outputMustBe("hello \"world\"");
|
||||
}
|
Reference in New Issue
Block a user