Commit 7c6c617d authored by Kenton Varda's avatar Kenton Varda

Generate usable code for groups, although making schemas work is still an open…

Generate usable code for groups, although making schemas work is still an open problem.  I think I'm going to do the schema rewrite now.
parent c1e33ebf
This diff is collapsed.
......@@ -402,6 +402,44 @@ TEST(Encoding, UnnamedUnion) {
}
}
TEST(Encoding, Groups) {
MallocMessageBuilder builder;
auto root = builder.initRoot<test::TestGroups>();
{
auto foo = root.getGroups().initFoo();
foo.setCorge(12345678);
foo.setGrault(123456789012345ll);
foo.setGarply("foobar");
EXPECT_EQ(12345678, foo.getCorge());
EXPECT_EQ(123456789012345ll, foo.getGrault());
EXPECT_EQ("foobar", foo.getGarply());
}
{
auto bar = root.getGroups().initBar();
bar.setCorge(23456789);
bar.setGrault("barbaz");
bar.setGarply(234567890123456ll);
EXPECT_EQ(23456789, bar.getCorge());
EXPECT_EQ("barbaz", bar.getGrault());
EXPECT_EQ(234567890123456ll, bar.getGarply());
}
{
auto baz = root.getGroups().initBaz();
baz.setCorge(34567890);
baz.setGrault("bazqux");
baz.setGarply("quxquux");
EXPECT_EQ(34567890, baz.getCorge());
EXPECT_EQ("bazqux", baz.getGrault());
EXPECT_EQ("quxquux", baz.getGarply());
}
}
TEST(Encoding, UnionDefault) {
MallocMessageBuilder builder;
TestUnionDefaults::Reader reader = builder.getRoot<TestUnionDefaults>().asReader();
......
......@@ -272,19 +272,19 @@ struct TestUnnamedUnion {
struct TestGroups {
groups union {
foo group {
fooCorge @0 :Int32;
fooGrault @2 :Int64;
bazGarply @8 :Text;
corge @0 :Int32;
grault @2 :Int64;
garply @8 :Text;
}
bar group {
barCorge @3 :Int32;
barGrault @4 :Text;
barGarply @5 :Int64;
corge @3 :Int32;
grault @4 :Text;
garply @5 :Int64;
}
baz group {
bazCorge @1 :Int32;
bazGrault @6 :Text;
bazGarply @7 :Text;
corge @1 :Int32;
grault @6 :Text;
garply @7 :Text;
}
}
}
......
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