diff options
Diffstat (limited to 'modules/codec/tests/codec.cpp')
-rw-r--r-- | modules/codec/tests/codec.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/modules/codec/tests/codec.cpp b/modules/codec/tests/codec.cpp index b9ac4ea..05899cc 100644 --- a/modules/codec/tests/codec.cpp +++ b/modules/codec/tests/codec.cpp @@ -24,6 +24,11 @@ using TestUnion = Union< Member<UInt64, "number"> >; +using TestSameTypeUnion = Union< + Member<UInt64, "one">, + Member<UInt64, "two"> +>; + using TestTuple = Tuple< TwoDimArray, UInt64 @@ -238,6 +243,19 @@ SAW_TEST("KelSimple Struct write and read back"){ SAW_EXPECT(native.template get<"number">().get() == 410, "Incorrect Decoding in number"); } +SAW_TEST("Native Union same type compilation"){ + using namespace saw; + + data<schema::TestSameTypeUnion, encode::Native> native; + + native.template init<"two">().set(50u); + + SAW_EXPECT(!native.template holds_alternative<"one">(), "Two should be initialized"); + SAW_EXPECT(native.template holds_alternative<"two">(), "Two should be initialized"); + + SAW_EXPECT(native.template get<"two">().get() == 50u, "Should be 50"); +} + SAW_TEST("KelSimple Union write and read back"){ using namespace saw; |