diff --git a/compiler/src/test/scala/org/capnproto/EncodingSuite.scala b/compiler/src/test/scala/org/capnproto/EncodingSuite.scala index 3658449..8043c66 100644 --- a/compiler/src/test/scala/org/capnproto/EncodingSuite.scala +++ b/compiler/src/test/scala/org/capnproto/EncodingSuite.scala @@ -230,6 +230,17 @@ class EncodingSuite extends FunSuite { TestUtil.checkSettedDefaultMessage(defaults.asReader()) } + test("Unions") { + val builder = new MessageBuilder() + val root = builder.initRoot(TestUnion.factory) + val u0 = root.initUnion0() + u0.initU0f1sp(10) + assert(u0.which() == TestUnion.Union0.Which.U0F1SP) + + u0.initPrimitiveList(10) + assert(u0.which() == TestUnion.Union0.Which.PRIMITIVE_LIST) + } + test("Groups") { val builder = new MessageBuilder() val root = builder.initRoot(TestGroups.factory) diff --git a/compiler/src/test/schema/test.capnp b/compiler/src/test/schema/test.capnp index 2f6aa9c..afb2497 100644 --- a/compiler/src/test/schema/test.capnp +++ b/compiler/src/test/schema/test.capnp @@ -180,6 +180,8 @@ struct TestUnion { u0f1s32 @15: Int32; u0f1s64 @16: Int64; u0f1sp @17: Text; + + primitiveList @56: List(UInt32); } # Pack one bit in order to make pathological situation for union1. @@ -393,6 +395,14 @@ struct GenericMap(K, V) c @3 :List(List(List(Entry))); } +# TODO. this is currently broken +#struct TestGenericUnion(T) { +# union0: union { +# nothing @0 :Void; +# something @1 :T; +# } +#} + struct TestEmptyStruct {} struct TestConstants {