diff --git a/app/commsdsl2comms/src/CommsVariantField.cpp b/app/commsdsl2comms/src/CommsVariantField.cpp index de9f00bb..1fc56d69 100644 --- a/app/commsdsl2comms/src/CommsVariantField.cpp +++ b/app/commsdsl2comms/src/CommsVariantField.cpp @@ -1035,7 +1035,7 @@ std::string CommsVariantField::commsDefSelectFieldCodeInternal() const " return;\n" " }\n\n" " reset();\n" - " switch (Base::currentField()) {\n" + " switch (idx) {\n" " #^#CASES#$#\n" " default: break;\n" " }\n" diff --git a/app/commsdsl2comms/test/test28/test28Test.th b/app/commsdsl2comms/test/test28/test28Test.th index 7da41ee9..a565d267 100644 --- a/app/commsdsl2comms/test/test28/test28Test.th +++ b/app/commsdsl2comms/test/test28/test28Test.th @@ -11,6 +11,7 @@ class TestSuite : public CxxTest::TestSuite public: void test1(); void test2(); + void test3(); using Interface = test28::Message< @@ -55,3 +56,12 @@ void TestSuite::test2() Msg2 msg; msg.field_f1().initField_p120().field_val().value() = 0xff; } + +void TestSuite::test3() +{ + Msg1 msg; + msg.field_variant1().initField_p1(); + TS_ASSERT_EQUALS(msg.field_variant1().currentField(), 0U); + msg.field_variant1().selectField(1U); + TS_ASSERT_EQUALS(msg.field_variant1().currentField(), 1U); +}