Skip to content

Commit 056dedb

Browse files
committed
Add unit test for the full pmap case
1 parent 7e99e73 commit 056dedb

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
lines changed

tests/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ FASTTYPEGEN_TARGET(simple_types11 simple11.xml)
2323
FASTTYPEGEN_TARGET(simple_types12 simple12.xml)
2424
FASTTYPEGEN_TARGET(simple_types13 simple13.xml)
2525
FASTTYPEGEN_TARGET(simple_types14 simple14.xml)
26+
FASTTYPEGEN_TARGET(simple_types15 simple15.xml)
2627

2728

2829
FASTTYPEGEN_TARGET(test_types1 test1.xml test2.xml)
@@ -42,6 +43,8 @@ add_executable (mfast_test
4243
encoder_test.cpp
4344
encoder_decoder_test.cpp
4445
encoder_decoder_test_v2.cpp
46+
encoder_decoder_pmap.cpp
47+
encoder_decoder_pmap_v2.cpp
4548
field_comparator_test.cpp
4649
group_encoder_decoder_v2.cpp
4750
group_encoder_decoder.cpp
@@ -66,6 +69,7 @@ add_executable (mfast_test
6669
${FASTTYPEGEN_simple_types12_OUTPUTS}
6770
${FASTTYPEGEN_simple_types13_OUTPUTS}
6871
${FASTTYPEGEN_simple_types14_OUTPUTS}
72+
${FASTTYPEGEN_simple_types15_OUTPUTS}
6973
fast_type_gen_test.cpp
7074
dictionary_builder_test.cpp
7175
json_test.cpp

tests/encoder_decoder_pmap.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include "catch.hpp"
2+
#include <mfast.h>
3+
4+
#include "fast_test_coding_case.hpp"
5+
6+
#include "simple15.h"
7+
8+
using namespace test::coding;
9+
10+
TEST_CASE("full pmap occupied encoder/decoder","[full_pmap_occupied_encoder_decoder]")
11+
{
12+
fast_test_coding_case<simple15::templates_description> test_case;
13+
14+
SECTION("encode fields")
15+
{
16+
simple15::Test_1 test_1;
17+
simple15::Test_1_mref test_1_mref = test_1.mref();
18+
test_1_mref.set_field_1_1().as(1);
19+
test_1_mref.set_field_1_2().as(2);
20+
test_1_mref.set_field_1_3().as(3);
21+
test_1_mref.set_field_1_4().as(4);
22+
test_1_mref.set_field_1_5().as(5);
23+
test_1_mref.set_field_1_6().as(6);
24+
test_1_mref.set_field_1_7().as(7);
25+
REQUIRE(test_case.encoding(test_1.cref(),"\x3F\xC0\x82\x83\x84\x85\x86\x87\x88",true));
26+
REQUIRE(test_case.decoding("\x3F\xC0\x82\x83\x84\x85\x86\x87\x88",test_1.cref(),true));
27+
}
28+
}

tests/encoder_decoder_pmap_v2.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include "catch.hpp"
2+
#include <mfast.h>
3+
4+
#include "fast_test_coding_case_v2.hpp"
5+
6+
#include "simple15.h"
7+
8+
using namespace test::coding;
9+
10+
TEST_CASE("full pmap occupied encoder_v2/decoder_v2","[full_pmap_occupied_encoder_v2_decoder_v2]")
11+
{
12+
fast_test_coding_case_v2<simple15::templates_description> test_case;
13+
14+
SECTION("encode fields")
15+
{
16+
simple15::Test_1 test_1;
17+
simple15::Test_1_mref test_1_mref = test_1.mref();
18+
test_1_mref.set_field_1_1().as(1);
19+
test_1_mref.set_field_1_2().as(2);
20+
test_1_mref.set_field_1_3().as(3);
21+
test_1_mref.set_field_1_4().as(4);
22+
test_1_mref.set_field_1_5().as(5);
23+
test_1_mref.set_field_1_6().as(6);
24+
test_1_mref.set_field_1_7().as(7);
25+
REQUIRE(test_case.encoding(test_1.cref(),"\x3F\xC0\x82\x83\x84\x85\x86\x87\x88",true));
26+
REQUIRE(test_case.decoding("\x3F\xC0\x82\x83\x84\x85\x86\x87\x88",test_1.cref(),true));
27+
}
28+
}

tests/simple15.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version=\" 1.0 \"?>
2+
<templates xmlns="http://www.fixprotocol.org/ns/fast/td/1.1">
3+
<template name="Test_1" id="1">
4+
<uInt32 name="field_1_1" id="11" presence="optional"><copy/></uInt32>
5+
<uInt32 name="field_1_2" id="12" presence="optional"><copy/></uInt32>
6+
<uInt32 name="field_1_3" id="13" presence="optional"><copy/></uInt32>
7+
<uInt32 name="field_1_4" id="14" presence="optional"><copy/></uInt32>
8+
<uInt32 name="field_1_5" id="15" presence="optional"><copy/></uInt32>
9+
<uInt32 name="field_1_6" id="16" presence="optional"><copy/></uInt32>
10+
<uInt32 name="field_1_7" id="17" presence="optional"><copy/></uInt32>
11+
</template>
12+
</templates>

0 commit comments

Comments
 (0)