add Unions test
This commit is contained in:
parent
cb0fdba7b8
commit
2c43bd712f
2 changed files with 21 additions and 0 deletions
|
@ -230,6 +230,17 @@ class EncodingSuite extends FunSuite {
|
||||||
TestUtil.checkSettedDefaultMessage(defaults.asReader())
|
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") {
|
test("Groups") {
|
||||||
val builder = new MessageBuilder()
|
val builder = new MessageBuilder()
|
||||||
val root = builder.initRoot(TestGroups.factory)
|
val root = builder.initRoot(TestGroups.factory)
|
||||||
|
|
|
@ -180,6 +180,8 @@ struct TestUnion {
|
||||||
u0f1s32 @15: Int32;
|
u0f1s32 @15: Int32;
|
||||||
u0f1s64 @16: Int64;
|
u0f1s64 @16: Int64;
|
||||||
u0f1sp @17: Text;
|
u0f1sp @17: Text;
|
||||||
|
|
||||||
|
primitiveList @56: List(UInt32);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Pack one bit in order to make pathological situation for union1.
|
# 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)));
|
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 TestEmptyStruct {}
|
||||||
|
|
||||||
struct TestConstants {
|
struct TestConstants {
|
||||||
|
|
Loading…
Reference in a new issue