diff options
author | Claudius "keldu" Holeksa <mail@keldu.de> | 2024-02-07 17:50:39 +0100 |
---|---|---|
committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2024-02-07 17:50:39 +0100 |
commit | cbf30026ef0dd7d785f51db5c1aa5891a0b92024 (patch) | |
tree | 75a6841d5f974f7b890fbbdac24bead11231d040 /modules/codec/tests | |
parent | fad7c2f1d2a210b6372cf8214e30d5176457d989 (diff) |
codec: Fixed union initialization when ambiguous cases occur
Diffstat (limited to 'modules/codec/tests')
-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; |