Support all JSON escape codes (including \u) for parsing & text gen.

Bug: 16624362
Change-Id: Ia09ea404c0c11dd1dc6993a8cbd155bf8152b65f
Tested: on Windows & Linux.
This commit is contained in:
Wouter van Oortmerssen
2014-08-20 13:22:16 -07:00
parent f7b0d130b6
commit ebac1e1940
8 changed files with 172 additions and 27 deletions

View File

@@ -516,7 +516,19 @@ void EnumStringsTest() {
"{ F:[ \"E.C\", \"E.A E.B E.C\" ] }", ""), true);
}
void UnicodeTest() {
flatbuffers::Parser parser;
TEST_EQ(parser.Parse("table T { F:string; }"
"root_type T;"
"{ F:\"\\u20AC\\u00A2\\u30E6\\u30FC\\u30B6\\u30FC"
"\\u5225\\u30B5\\u30A4\\u30C8\\x01\\x80\" }", ""), true);
std::string jsongen;
flatbuffers::GeneratorOptions opts;
opts.indent_step = -1;
GenerateText(parser, parser.builder_.GetBufferPointer(), opts, &jsongen);
TEST_EQ(jsongen == "{F: \"\\u20AC\\u00A2\\u30E6\\u30FC\\u30B6\\u30FC"
"\\u5225\\u30B5\\u30A4\\u30C8\\x01\\x80\"}", true);
}
int main(int /*argc*/, const char * /*argv*/[]) {
// Run our various test suites:
@@ -534,6 +546,7 @@ int main(int /*argc*/, const char * /*argv*/[]) {
ErrorTest();
ScientificTest();
EnumStringsTest();
UnicodeTest();
if (!testing_fails) {
TEST_OUTPUT_LINE("ALL TESTS PASSED");