additional tests for #1042 and #1642

This commit is contained in:
Alex Fabijanic 2017-06-21 16:45:39 +02:00
parent d866e7444d
commit 18a5a380d2
2 changed files with 11 additions and 2 deletions

View File

@ -1163,11 +1163,13 @@ void StringTest::testJSONString()
assert (toJSON("\\", false) == "\\\\");
assert (toJSON("\"", false) == "\\\"");
assert (toJSON("/", false) == "\\/");
assert (toJSON("\a", false) == "\\a");
assert (toJSON("\b", false) == "\\b");
assert (toJSON("\f", false) == "\\f");
assert (toJSON("\n", false) == "\\n");
assert (toJSON("\r", false) == "\\r");
assert (toJSON("\t", false) == "\\t");
assert (toJSON("\v", false) == "\\v");
assert (toJSON("a", false) == "a");
// ??? on MSVC, the assert macro expansion

View File

@ -1870,9 +1870,16 @@ void JSONTest::testEscapeUnicode()
std::stringstream ss;
object->stringify(ss);
//assert(ss.str().compare("{\"name\":\"B\\u0000b\"}") == 0);
assert(ss.str().compare("{\"name\":\"\\u4E2D\"}") == 0);
std::cout << ss.str() << std::endl;
const unsigned char utf8Chars[] = {'{', '"', 'n', 'a', 'm', 'e', '"', ':',
'"', 'g', 195, 188, 'n', 't', 'e', 'r', '"', '}', 0};
std::string utf8Text((const char*) utf8Chars);
parser.reset();
result = parser.parse(utf8Text);
object = result.extract<Object::Ptr>();
ss.str(""); object->stringify(ss);
assert (ss.str() == "{\"name\":\"g\\u00FCnter\"}");
}