forked from bblanchon/ArduinoJson
Added more test of escaped chars
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Arduino JSON library
|
||||
* Benoit Blanchon 2014 - MIT License
|
||||
/*
|
||||
* Arduino JSON library
|
||||
* Benoit Blanchon 2014 - MIT License
|
||||
*/
|
||||
|
||||
#include "CppUnitTest.h"
|
||||
@ -14,7 +14,7 @@ namespace ArduinoJsonParserTests
|
||||
TEST_CLASS(JsonStringTests)
|
||||
{
|
||||
const char* actual;
|
||||
char json[256];
|
||||
char json[256];
|
||||
JsonParser<32> parser;
|
||||
|
||||
public:
|
||||
|
@ -56,4 +56,52 @@ TEST_F(JsonParser_String_Tests, EscapedSingleQuote)
|
||||
{
|
||||
whenInputIs("\"hello \\\'world\\\'\"");
|
||||
outputMustBe("hello 'world'");
|
||||
}
|
||||
|
||||
TEST_F(JsonParser_String_Tests, EscapedSolidus)
|
||||
{
|
||||
whenInputIs("\"hello \\/world\\/\"");
|
||||
outputMustBe("hello /world/");
|
||||
}
|
||||
|
||||
TEST_F(JsonParser_String_Tests, EscapedReverseSolidus)
|
||||
{
|
||||
whenInputIs("\"hello \\\\world\\\\\"");
|
||||
outputMustBe("hello \\world\\");
|
||||
}
|
||||
|
||||
TEST_F(JsonParser_String_Tests, EscapedBackspace)
|
||||
{
|
||||
whenInputIs("\"hello \\bworld\\b");
|
||||
outputMustBe("hello \bworld\b");
|
||||
}
|
||||
|
||||
TEST_F(JsonParser_String_Tests, EscapedFormfeed)
|
||||
{
|
||||
whenInputIs("\"hello \\fworld\\f");
|
||||
outputMustBe("hello \fworld\f");
|
||||
}
|
||||
|
||||
TEST_F(JsonParser_String_Tests, EscapedNewline)
|
||||
{
|
||||
whenInputIs("\"hello \\nworld\\n");
|
||||
outputMustBe("hello \nworld\n");
|
||||
}
|
||||
|
||||
TEST_F(JsonParser_String_Tests, EscapedCarriageReturn)
|
||||
{
|
||||
whenInputIs("\"hello \\rworld\\r");
|
||||
outputMustBe("hello \rworld\r");
|
||||
}
|
||||
|
||||
TEST_F(JsonParser_String_Tests, EscapedTab)
|
||||
{
|
||||
whenInputIs("\"hello \\tworld\\t");
|
||||
outputMustBe("hello \tworld\t");
|
||||
}
|
||||
|
||||
TEST_F(JsonParser_String_Tests, AllEscapedCharsTogether)
|
||||
{
|
||||
whenInputIs("\"1\\\"2\\\\3\\/4\\b5\\f6\\n7\\r8\\t9\"");
|
||||
outputMustBe("1\"2\\3/4\b5\f6\n7\r8\t9");
|
||||
}
|
Reference in New Issue
Block a user