Skip to content

Commit 05d6f4a

Browse files
committed
More tests in the group encoder
1 parent 5dc3762 commit 05d6f4a

File tree

4 files changed

+104
-0
lines changed

4 files changed

+104
-0
lines changed

tests/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ FASTTYPEGEN_TARGET(simple_types9 simple9.xml)
2121
FASTTYPEGEN_TARGET(simple_types10 simple10.xml)
2222
FASTTYPEGEN_TARGET(simple_types11 simple11.xml)
2323
FASTTYPEGEN_TARGET(simple_types12 simple12.xml)
24+
FASTTYPEGEN_TARGET(simple_types13 simple13.xml)
2425

2526

2627
FASTTYPEGEN_TARGET(test_types1 test1.xml test2.xml)
@@ -41,6 +42,8 @@ add_executable (mfast_test
4142
encoder_decoder_test.cpp
4243
encoder_decoder_test_v2.cpp
4344
field_comparator_test.cpp
45+
group_encoder_decoder_v2.cpp
46+
group_encoder_decoder.cpp
4447
coder_test.cpp
4548
value_storage_test.cpp
4649
${FASTTYPEGEN_test_types1_OUTPUTS}
@@ -60,6 +63,7 @@ add_executable (mfast_test
6063
${FASTTYPEGEN_simple_types10_OUTPUTS}
6164
${FASTTYPEGEN_simple_types11_OUTPUTS}
6265
${FASTTYPEGEN_simple_types12_OUTPUTS}
66+
${FASTTYPEGEN_simple_types13_OUTPUTS}
6367
fast_type_gen_test.cpp
6468
dictionary_builder_test.cpp
6569
json_test.cpp

tests/group_encoder_decoder.cpp

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include "catch.hpp"
2+
#include <mfast.h>
3+
4+
#include "fast_test_coding_case.hpp"
5+
#include "byte_stream.h"
6+
7+
#include "simple13.h"
8+
9+
using namespace test::coding;
10+
11+
TEST_CASE("only field without group encoder/decoder","[field_without_group_encoder_decoder]")
12+
{
13+
fast_test_coding_case<simple13::templates_description> test_case;
14+
15+
simple13::Test_1 test_1;
16+
simple13::Test_1_mref test_1_mref = test_1.mref();
17+
18+
test_1_mref.set_field_1_1().as(30);
19+
test_1_mref.set_field_1_2().as(40);
20+
21+
REQUIRE(test_case.encoding(test_1.cref(),"\xC0\x81\x9F\xA8",true));
22+
REQUIRE(test_case.decoding("\xC0\x81\x9F\xA8",test_1.cref(),true));
23+
}
24+
25+
TEST_CASE("field with group encoder/decoder","[field_without_group_encoder_decoder]")
26+
{
27+
fast_test_coding_case<simple13::templates_description> test_case;
28+
29+
simple13::Test_1 test_1;
30+
simple13::Test_1_mref test_1_mref = test_1.mref();
31+
32+
test_1_mref.set_field_1_1().as(30);
33+
test_1_mref.set_field_1_2().as(40);
34+
35+
auto group_1 = test_1_mref.set_group_1();
36+
group_1.set_field_1_4().as(10);
37+
38+
REQUIRE(test_case.encoding(test_1.cref(),"\xE0\x81\x9F\xA8\x80\x8B",true));
39+
REQUIRE(test_case.decoding("\xE0\x81\x9F\xA8\x80\x8B",test_1.cref(),true));
40+
}
41+
42+

tests/group_encoder_decoder_v2.cpp

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include "catch.hpp"
2+
#include <mfast.h>
3+
4+
#include "fast_test_coding_case_v2.hpp"
5+
#include "byte_stream.h"
6+
7+
#include "simple13.h"
8+
9+
using namespace test::coding;
10+
11+
TEST_CASE("only field without group encoder_v2/decoder_v2","[field_without_group_encoder_v2_decoder_v2]")
12+
{
13+
fast_test_coding_case_v2<simple13::templates_description> test_case;
14+
15+
simple13::Test_1 test_1;
16+
simple13::Test_1_mref test_1_mref = test_1.mref();
17+
18+
test_1_mref.set_field_1_1().as(30);
19+
test_1_mref.set_field_1_2().as(40);
20+
21+
REQUIRE(test_case.encoding(test_1.cref(),"\xC0\x81\x9F\xA8",true));
22+
REQUIRE(test_case.decoding("\xC0\x81\x9F\xA8",test_1.cref(),true));
23+
}
24+
25+
TEST_CASE("field with group encoder_v2/decoder_v2","[field_without_group_encoder_v2_decoder_v2]")
26+
{
27+
fast_test_coding_case_v2<simple13::templates_description> test_case;
28+
29+
simple13::Test_1 test_1;
30+
simple13::Test_1_mref test_1_mref = test_1.mref();
31+
32+
test_1_mref.set_field_1_1().as(30);
33+
test_1_mref.set_field_1_2().as(40);
34+
35+
auto group_1 = test_1_mref.set_group_1();
36+
group_1.set_field_1_4().as(10);
37+
38+
REQUIRE(test_case.encoding(test_1.cref(),"\xE0\x81\x9F\xA8\x80\x8B",true));
39+
REQUIRE(test_case.decoding("\xE0\x81\x9F\xA8\x80\x8B",test_1.cref(),true));
40+
}
41+
42+

tests/simple13.xml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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"></uInt32>
5+
<uInt32 name="field_1_2" id="12"></uInt32>
6+
<group name="group_1" presence="optional">
7+
<string name="field_1_3" id="13">
8+
<default value="test"/>
9+
</string>
10+
<uInt32 name="field_1_4" id="14" presence="optional"></uInt32>
11+
</group>
12+
</template>
13+
<template name="Test_2" id="2">
14+
<uInt32 name="field_2_1" id="21" presence="optional"></uInt32>
15+
</template>
16+
</templates>

0 commit comments

Comments
 (0)