* Added unit test to JSON unicode change

This commit is contained in:
Rangel Reale 2012-12-28 21:19:53 -02:00
parent 3a2116233b
commit 92ba6563f0
2 changed files with 31 additions and 0 deletions

View File

@ -859,6 +859,35 @@ void JSONTest::testTemplate()
}
void JSONTest::testUnicode()
{
const unsigned char supp[] = {0x61, 0xE1, 0xE9, 0x78, 0xED, 0xF3, 0xFA, 0x0};
std::string text((const char*) supp);
std::string json = "{ \"test\" : \"a\u00E1\u00E9x\u00ED\u00F3\u00FA\" }";
Parser parser;
Var result;
try
{
DefaultHandler handler;
parser.setHandler(&handler);
parser.parse(json);
result = handler.result();
}
catch(JSONException& jsone)
{
std::cout << jsone.message() << std::endl;
assert(false);
}
assert(result.type() == typeid(Object::Ptr));
Object::Ptr object = result.extract<Object::Ptr>();
Var test = object->get("test");
assert(test.convert<std::string>() == text);
}
std::string JSONTest::getTestFilesPath(const std::string& type)
{
std::ostringstream ostr;
@ -918,6 +947,7 @@ CppUnit::Test* JSONTest::suite()
CppUnit_addTest(pSuite, JSONTest, testValidJanssonFiles);
CppUnit_addTest(pSuite, JSONTest, testInvalidJanssonFiles);
CppUnit_addTest(pSuite, JSONTest, testTemplate);
CppUnit_addTest(pSuite, JSONTest, testUnicode);
return pSuite;
}

View File

@ -76,6 +76,7 @@ public:
void testInvalidJanssonFiles();
void testTemplate();
void testItunes();
void testUnicode();
void setUp();
void tearDown();