mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-05 04:58:57 +00:00
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:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user