From 67119a4bdcd04942eb61cf539d40cf92c4daeb27 Mon Sep 17 00:00:00 2001 From: Roberto Martin Fantini Date: Mon, 24 Feb 2025 17:28:26 +0100 Subject: [PATCH 1/3] Add the pmap case for the optional group from 10.5 point of the norm --- src/mfast/instructions/field_instruction.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mfast/instructions/field_instruction.h b/src/mfast/instructions/field_instruction.h index 6425043d..67aef59c 100644 --- a/src/mfast/instructions/field_instruction.h +++ b/src/mfast/instructions/field_instruction.h @@ -165,7 +165,8 @@ class MFAST_EXPORT field_instruction { virtual void update_invariant() { nullable_flag_ = optional_flag_ && (operator_id_ != operator_constant); has_pmap_bit_ = operator_id_ > operator_delta || - ((operator_id_ == operator_constant) && optional_flag_); + ((operator_id_ == operator_constant) && optional_flag_)|| + (field_type_ == field_type_group && optional_flag_); } // uint16_t field_index_; @@ -208,7 +209,8 @@ inline field_instruction::field_instruction(operator_enum_t operator_id, optional_flag_(optional), nullable_flag_(optional && (operator_id != operator_constant)), has_pmap_bit_(operator_id > operator_delta || - ((operator_id == operator_constant) && optional)), + ((operator_id == operator_constant) && optional) || + (field_type == field_type_group && optional)), has_initial_value_(false), field_type_(field_type), previous_value_shared_(false), id_(id), name_(name), ns_(ns), tag_(std::move(tag)) {} From 75f1d13c7496b408d4d53931f2a045c685e22de1 Mon Sep 17 00:00:00 2001 From: Roberto Martin Fantini Date: Mon, 24 Feb 2025 17:28:57 +0100 Subject: [PATCH 2/3] Add one buit for the tempalte id --- src/mfast/instructions/template_instruction.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mfast/instructions/template_instruction.h b/src/mfast/instructions/template_instruction.h index c3451bb3..b455e2ff 100644 --- a/src/mfast/instructions/template_instruction.h +++ b/src/mfast/instructions/template_instruction.h @@ -22,6 +22,7 @@ class MFAST_EXPORT template_instruction : public group_field_instruction { cpp_ns, tag), template_ns_(template_ns), reset_(reset) { field_type_ = field_type_template; + segment_pmap_size_++; // Add one to the template id bit } const char *template_ns() const { return template_ns_; } From a8c91cc5549126a5dc73631534e332537d550d2f Mon Sep 17 00:00:00 2001 From: Roberto Martin Fantini Date: Mon, 24 Feb 2025 17:29:48 +0100 Subject: [PATCH 3/3] Add unit test for the pmap case --- tests/CMakeLists.txt | 1 + tests/message_pmap_test.cpp | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 tests/message_pmap_test.cpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 2859a552..b9867489 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -61,6 +61,7 @@ add_executable (mfast_test aggregate_view_test.cpp simple_coder_test.cpp scp_reset_test.cpp + message_pmap_test.cpp ) target_link_libraries (mfast_test diff --git a/tests/message_pmap_test.cpp b/tests/message_pmap_test.cpp new file mode 100644 index 00000000..de816a4b --- /dev/null +++ b/tests/message_pmap_test.cpp @@ -0,0 +1,29 @@ +#include "catch.hpp" +#include + +#include "simple1.h" +#include "simple2.h" + +TEST_CASE("test message pmap message number of bits of a field message content","[message_pmap_number_bits_field]") +{ + simple1::Test msg; + simple1::Test_mref msg_ref = msg.mref(); + + msg_ref.set_field1().as(1); + msg_ref.set_field2().as(2); + msg_ref.set_field3().as(3); + + CHECK(msg.instruction()->segment_pmap_size() == 4); +} + +TEST_CASE("test message pmap message number of bits of a field and group message content","[message_pmap_number_bits_group]") +{ + simple2::Test msg; + simple2::Test_mref msg_ref = msg.mref(); + + msg_ref.set_field1().as(1); + msg_ref.set_group1().set_field2().as(2); + msg_ref.set_group1().set_field3().as(3); + + CHECK(msg.instruction()->segment_pmap_size() == 3); +}