Commit 9e6f6c0b authored by Jason Choy's avatar Jason Choy

Added name annotation tests for nested structs and named unions

parent 26c91af8
......@@ -1657,14 +1657,31 @@ TEST(Encoding, NameAnnotation) {
MallocMessageBuilder message;
auto root = message.initRoot<test::RenamedStruct>();
EXPECT_FALSE(root.isGoodFieldName());
root.setGoodFieldName(true);
EXPECT_EQ(true, root.getGoodFieldName());
EXPECT_TRUE(root.isGoodFieldName());
root.setBar(0xff);
EXPECT_FALSE(root.isGoodFieldName());
root.setAnotherGoodFieldName(test::RenamedStruct::RenamedEnum::QUX);
EXPECT_EQ(test::RenamedStruct::RenamedEnum::QUX, root.getAnotherGoodFieldName());
EXPECT_FALSE(root.getNamedUnion().isQux());
auto quxBuilder = root.getNamedUnion().initQux();
EXPECT_TRUE(root.getNamedUnion().isQux());
EXPECT_FALSE(root.getNamedUnion().getQux().hasAnotherGoodNestedFieldName());
quxBuilder.setGoodNestedFieldName(true);
EXPECT_EQ(true, quxBuilder.getGoodNestedFieldName());
EXPECT_FALSE(quxBuilder.hasAnotherGoodNestedFieldName());
auto nestedFieldBuilder = quxBuilder.initAnotherGoodNestedFieldName();
EXPECT_TRUE(quxBuilder.hasAnotherGoodNestedFieldName());
nestedFieldBuilder.setGoodNestedFieldName(true);
EXPECT_EQ(true, nestedFieldBuilder.getGoodNestedFieldName());
EXPECT_FALSE(nestedFieldBuilder.hasAnotherGoodNestedFieldName());
}
} // namespace
......
......@@ -702,4 +702,15 @@ struct TestNameAnnotation $Cxx.name("RenamedStruct") {
}
anotherBadFieldName @2 :BadlyNamedEnum $Cxx.name("anotherGoodFieldName");
struct NestedStruct $Cxx.name("RenamedNestedStruct") {
badNestedFieldName @0 :Bool $Cxx.name("goodNestedFieldName");
anotherBadNestedFieldName @1 :NestedStruct $Cxx.name("anotherGoodNestedFieldName");
}
namedUnion :union {
foo @3 :Void;
bar @4 :Void;
baz @5 :NestedStruct $Cxx.name("qux");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment