Skip to content

Commit

Permalink
Fixes to the generated "selectField()" member function of the <varian…
Browse files Browse the repository at this point in the history
…t> field.
  • Loading branch information
arobenko committed Aug 8, 2023
1 parent 9e1d68a commit 8766fde
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/commsdsl2comms/src/CommsVariantField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 10 additions & 0 deletions app/commsdsl2comms/test/test28/test28Test.th
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class TestSuite : public CxxTest::TestSuite
public:
void test1();
void test2();
void test3();

using Interface =
test28::Message<
Expand Down Expand Up @@ -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);
}

0 comments on commit 8766fde

Please sign in to comment.