Renamed EscapedString into QuotedString

This commit is contained in:
Benoit Blanchon
2014-10-18 22:04:13 +02:00
parent bbc2aa4f2a
commit fc4faacfec
6 changed files with 21 additions and 22 deletions

View File

@ -1,17 +1,17 @@
#include <gtest/gtest.h>
#include <ArduinoJson/Internals/EscapedString.h>
#include <ArduinoJson/Internals/QuotedString.h>
#include <ArduinoJson/Internals/StringBuilder.h>
using namespace ArduinoJson::Internals;
class EscapedString_PrintTo_Tests : public testing::Test
class QuotedString_PrintTo_Tests : public testing::Test
{
protected:
void whenInputIs(const char* input)
{
StringBuilder sb(buffer, sizeof(buffer));
returnValue = EscapedString::printTo(input, &sb);
returnValue = QuotedString::printTo(input, &sb);
}
void outputMustBe(const char* expected)
@ -25,61 +25,61 @@ private:
size_t returnValue;
};
TEST_F(EscapedString_PrintTo_Tests, Null)
TEST_F(QuotedString_PrintTo_Tests, Null)
{
whenInputIs(0);
outputMustBe("null");
}
TEST_F(EscapedString_PrintTo_Tests, EmptyString)
TEST_F(QuotedString_PrintTo_Tests, EmptyString)
{
whenInputIs("");
outputMustBe("\"\"");
}
TEST_F(EscapedString_PrintTo_Tests, QuotationMark)
TEST_F(QuotedString_PrintTo_Tests, QuotationMark)
{
whenInputIs("\"");
outputMustBe("\"\\\"\"");
}
TEST_F(EscapedString_PrintTo_Tests, ReverseSolidus)
TEST_F(QuotedString_PrintTo_Tests, ReverseSolidus)
{
whenInputIs("\\");
outputMustBe("\"\\\\\"");
}
TEST_F(EscapedString_PrintTo_Tests, Solidus)
TEST_F(QuotedString_PrintTo_Tests, Solidus)
{
whenInputIs("/");
outputMustBe("\"/\""); // but the JSON format allows \/
}
TEST_F(EscapedString_PrintTo_Tests, Backspace)
TEST_F(QuotedString_PrintTo_Tests, Backspace)
{
whenInputIs("\b");
outputMustBe("\"\\b\"");
}
TEST_F(EscapedString_PrintTo_Tests, Formfeed)
TEST_F(QuotedString_PrintTo_Tests, Formfeed)
{
whenInputIs("\f");
outputMustBe("\"\\f\"");
}
TEST_F(EscapedString_PrintTo_Tests, Newline)
TEST_F(QuotedString_PrintTo_Tests, Newline)
{
whenInputIs("\n");
outputMustBe("\"\\n\"");
}
TEST_F(EscapedString_PrintTo_Tests, CarriageReturn)
TEST_F(QuotedString_PrintTo_Tests, CarriageReturn)
{
whenInputIs("\r");
outputMustBe("\"\\r\"");
}
TEST_F(EscapedString_PrintTo_Tests, HorizontalTab)
TEST_F(QuotedString_PrintTo_Tests, HorizontalTab)
{
whenInputIs("\t");
outputMustBe("\"\\t\"");