Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/mfast/instructions/field_instruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down Expand Up @@ -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)) {}
Expand Down
1 change: 1 addition & 0 deletions src/mfast/instructions/template_instruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_; }
Expand Down
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 29 additions & 0 deletions tests/message_pmap_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "catch.hpp"
#include <mfast.h>

#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);
}