_StructModuleWhich: Use enum

This commit is contained in:
John Vandenberg
2021-05-31 16:32:46 +08:00
parent 0c904443bd
commit 1795cac230
2 changed files with 19 additions and 7 deletions

View File

@@ -200,8 +200,13 @@ def test_union_enum(all_types):
msg = all_types.UnionAllTypes.new_message(**{'unionStructField1': {'textField': "foo"}})
assert msg.which == all_types.UnionAllTypes.Union.UnionStructField1
assert msg.which == 'unionStructField1'
assert msg.which == 0
msg = all_types.UnionAllTypes.new_message(**{'unionStructField2': {'textField': "foo"}})
assert msg.which == all_types.UnionAllTypes.Union.UnionStructField2
assert msg.which == 'unionStructField2'
assert msg.which == 1
assert all_types.GroupedUnionAllTypes.Union.G1 == 0
assert all_types.GroupedUnionAllTypes.Union.G2 == 1