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
3 changes: 2 additions & 1 deletion src/mfast/coder/encoder/fast_encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ void fast_encoder_impl::visit(message_cref cref, bool force_reset) {
template_instruction *instruction = *this->find(template_id);

if (instruction != nullptr) {
current_pmap().init(&this->strm_, std::max<std::size_t>(instruction->segment_pmap_size(), 1));
constexpr std::size_t template_id_bit = 1;
current_pmap().init(&this->strm_, std::max<std::size_t>(instruction->segment_pmap_size() + template_id_bit, 1));
} else {
using namespace coder;
BOOST_THROW_EXCEPTION(fast_dynamic_error("D9")
Expand Down
3 changes: 2 additions & 1 deletion src/mfast/coder/encoder_v2/fast_encoder_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ void fast_encoder_core::encode_segment(const message_cref cref,

encoder_presence_map pmap;
this->current_ = &pmap;
pmap.init(&this->strm_, std::max<std::size_t>(instruction->segment_pmap_size(), 1));
constexpr std::size_t template_id_bit = 1;
pmap.init(&this->strm_, std::max<std::size_t>(instruction->segment_pmap_size() + template_id_bit, 1));
pmap.set_next_bit(need_encode_template_id);

if (need_encode_template_id) {
Expand Down
4 changes: 4 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ FASTTYPEGEN_TARGET(simple_types11 simple11.xml)
FASTTYPEGEN_TARGET(simple_types12 simple12.xml)
FASTTYPEGEN_TARGET(simple_types13 simple13.xml)
FASTTYPEGEN_TARGET(simple_types14 simple14.xml)
FASTTYPEGEN_TARGET(simple_types15 simple15.xml)


FASTTYPEGEN_TARGET(test_types1 test1.xml test2.xml)
Expand All @@ -42,6 +43,8 @@ add_executable (mfast_test
encoder_test.cpp
encoder_decoder_test.cpp
encoder_decoder_test_v2.cpp
encoder_decoder_pmap.cpp
encoder_decoder_pmap_v2.cpp
field_comparator_test.cpp
group_encoder_decoder_v2.cpp
group_encoder_decoder.cpp
Expand All @@ -66,6 +69,7 @@ add_executable (mfast_test
${FASTTYPEGEN_simple_types12_OUTPUTS}
${FASTTYPEGEN_simple_types13_OUTPUTS}
${FASTTYPEGEN_simple_types14_OUTPUTS}
${FASTTYPEGEN_simple_types15_OUTPUTS}
fast_type_gen_test.cpp
dictionary_builder_test.cpp
json_test.cpp
Expand Down
28 changes: 28 additions & 0 deletions tests/encoder_decoder_pmap.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "catch.hpp"
#include <mfast.h>

#include "fast_test_coding_case.hpp"

#include "simple15.h"

using namespace test::coding;

TEST_CASE("full pmap occupied encoder/decoder","[full_pmap_occupied_encoder_decoder]")
{
fast_test_coding_case<simple15::templates_description> test_case;

SECTION("encode fields")
{
simple15::Test_1 test_1;
simple15::Test_1_mref test_1_mref = test_1.mref();
test_1_mref.set_field_1_1().as(1);
test_1_mref.set_field_1_2().as(2);
test_1_mref.set_field_1_3().as(3);
test_1_mref.set_field_1_4().as(4);
test_1_mref.set_field_1_5().as(5);
test_1_mref.set_field_1_6().as(6);
test_1_mref.set_field_1_7().as(7);
REQUIRE(test_case.encoding(test_1.cref(),"\x3F\xC0\x82\x83\x84\x85\x86\x87\x88",true));
REQUIRE(test_case.decoding("\x3F\xC0\x82\x83\x84\x85\x86\x87\x88",test_1.cref(),true));
}
}
28 changes: 28 additions & 0 deletions tests/encoder_decoder_pmap_v2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "catch.hpp"
#include <mfast.h>

#include "fast_test_coding_case_v2.hpp"

#include "simple15.h"

using namespace test::coding;

TEST_CASE("full pmap occupied encoder_v2/decoder_v2","[full_pmap_occupied_encoder_v2_decoder_v2]")
{
fast_test_coding_case_v2<simple15::templates_description> test_case;

SECTION("encode fields")
{
simple15::Test_1 test_1;
simple15::Test_1_mref test_1_mref = test_1.mref();
test_1_mref.set_field_1_1().as(1);
test_1_mref.set_field_1_2().as(2);
test_1_mref.set_field_1_3().as(3);
test_1_mref.set_field_1_4().as(4);
test_1_mref.set_field_1_5().as(5);
test_1_mref.set_field_1_6().as(6);
test_1_mref.set_field_1_7().as(7);
REQUIRE(test_case.encoding(test_1.cref(),"\x3F\xC0\x82\x83\x84\x85\x86\x87\x88",true));
REQUIRE(test_case.decoding("\x3F\xC0\x82\x83\x84\x85\x86\x87\x88",test_1.cref(),true));
}
}
12 changes: 12 additions & 0 deletions tests/simple15.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version=\" 1.0 \"?>
<templates xmlns="http://www.fixprotocol.org/ns/fast/td/1.1">
<template name="Test_1" id="1">
<uInt32 name="field_1_1" id="11" presence="optional"><copy/></uInt32>
<uInt32 name="field_1_2" id="12" presence="optional"><copy/></uInt32>
<uInt32 name="field_1_3" id="13" presence="optional"><copy/></uInt32>
<uInt32 name="field_1_4" id="14" presence="optional"><copy/></uInt32>
<uInt32 name="field_1_5" id="15" presence="optional"><copy/></uInt32>
<uInt32 name="field_1_6" id="16" presence="optional"><copy/></uInt32>
<uInt32 name="field_1_7" id="17" presence="optional"><copy/></uInt32>
</template>
</templates>