feat(C++): Support underlying_type for union (#7954)

* feat(C++): support underlying type for union

* chore: add conform checks for underlying type changes
This commit is contained in:
sssooonnnggg
2023-05-15 12:22:38 +08:00
committed by GitHub
parent fe5e4c71c5
commit 1d3afb90c5
10 changed files with 1004 additions and 17 deletions

View File

@@ -841,6 +841,15 @@ void ParseUnionTest() {
"table B { e:U; } root_type B;"
"{ e_type: N_A, e: {} }"),
true);
// Test union underlying type
const char *source = "table A {} table B {} union U : int {A, B} table C {test_union: U; test_vector_of_union: [U];}";
flatbuffers::Parser parser3;
parser3.opts.lang_to_generate = flatbuffers::IDLOptions::kCpp;
TEST_EQ(parser3.Parse(source), true);
parser3.opts.lang_to_generate &= flatbuffers::IDLOptions::kJava;
TEST_EQ(parser3.Parse(source), false);
}
void ValidSameNameDifferentNamespaceTest() {