Added a test with special chars

This commit is contained in:
Benoît Blanchon
2014-06-26 13:10:52 +02:00
parent 25118ad8c0
commit d12e25bd8a
2 changed files with 25 additions and 6 deletions

View File

@ -39,6 +39,25 @@ void StringBuilder::appendEscaped(const char* s)
append("\\\\");
break;
case '\b':
append("\\b");
break;
case '\f':
append("\\f");
break;
case '\n':
append("\\n");
break;
case '\r':
append("\\r");
break;
case '\t':
append("\\t");
break;
default:
buffer[length++] = *s;

View File

@ -7,7 +7,7 @@ namespace JsonGeneratorTests
{
TEST_CLASS(StringBuilderAppendEscapedTests)
{
char buffer[16];
char buffer[20];
StringBuilder* sb;
public:
@ -44,15 +44,15 @@ namespace JsonGeneratorTests
TEST_METHOD(OverCapacity)
{
append("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
assertResultIs("\"ABCDEFGHIJKLM\"");
assertResultIs("\"ABCDEFGHIJKLMNOPQ\"");
}
/*
TEST_METHOD(SpecialChars)
{
append("\\\"\b\f\n\r");
assertResultIs("\\\\\\\"\\\b\\\f\\\n\\\r");
append("\\\"\b\f\n\r\t");
assertResultIs("\"\\\\\\\"\\b\\f\\n\\r\\t\"");
}
*/
void append(const char* s)
{
sb->appendEscaped(s);