Skip to content

Commit b961695

Browse files
committed
Unit test for the case of the xetra enum
1 parent b47a9cf commit b961695

File tree

4 files changed

+120
-0
lines changed

4 files changed

+120
-0
lines changed

tests/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ FASTTYPEGEN_TARGET(simple_types16 simple16.xml)
2828

2929
if(XETRA_FAST_SPECIFICATION)
3030
FASTTYPEGEN_TARGET(simple_types17 simple17.xml)
31+
FASTTYPEGEN_TARGET(simple_types18 simple18.xml)
3132
endif(XETRA_FAST_SPECIFICATION)
3233

3334
FASTTYPEGEN_TARGET(test_types1 test1.xml test2.xml)
@@ -94,8 +95,11 @@ set(test_sources
9495
if(XETRA_FAST_SPECIFICATION)
9596
set(test_sources ${test_sources}
9697
${FASTTYPEGEN_simple_types17_OUTPUTS}
98+
${FASTTYPEGEN_simple_types18_OUTPUTS}
9799
timestamp_encoder_decoder_v2.cpp
98100
timestamp_encoder_decoder.cpp
101+
xetra_enum_encoder_decoder_v2.cpp
102+
xetra_enum_encoder_decoder.cpp
99103
)
100104
endif(XETRA_FAST_SPECIFICATION)
101105

tests/simple18.xml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<templates
3+
xmlns="http://www.fixprotocol.org/ns/fast/td/1.2"
4+
xmlns:scp="http://www.fixprotocol.org/ns/fast/scp/1.2"
5+
templateNs="https://www.deutsche-boerse.com/rta">
6+
<define name="TypeMDStatisticStatus">
7+
<enum>
8+
<element name="1" id="Active"/>
9+
<element name="2" id="Inactive"/>
10+
</enum>
11+
</define>
12+
<define name="TypeUnit">
13+
<enum>
14+
<element name="0" id="Seconds"/>
15+
<element name="3" id="MilliSeconds"/>
16+
<element name="10" id="Minutes"/>
17+
<element name="12" id="Days"/>
18+
</enum>
19+
</define>
20+
<!-- Define templates-->
21+
<template name="Test_1" id="1">
22+
<string name="MsgType" id="35"><constant value="DP"/></string>
23+
<field name="MDStatisticStatus" id="2477"><type name="TypeMDStatisticStatus"><default value="0"/></type></field>
24+
<field name="MDStatisticFrequencyUnit" id="2461" presence="optional"><type name="TypeUnit"/></field>
25+
</template>
26+
<template name="Test_2" id="2">
27+
<string name="MsgType" id="36"><constant value="DQ"/></string>
28+
<field name="MDStatisticIntervalUnit" id="2467"><type name="TypeUnit"><default value="3"/></type></field>
29+
</template>
30+
</templates>

tests/xetra_enum_encoder_decoder.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include "catch.hpp"
2+
#include <mfast.h>
3+
4+
#include "fast_test_coding_case.hpp"
5+
#include "byte_stream.h"
6+
7+
#include "simple18.h"
8+
9+
using namespace test::coding;
10+
11+
TEST_CASE("xetra enum test encoder/decoder","[xetra_enum_encoder_decoder]")
12+
{
13+
SECTION("No optional enum / Active")
14+
{
15+
fast_test_coding_case<simple18::templates_description> test_case;
16+
simple18::Test_1 test_1;
17+
simple18::Test_1_mref test_1_mref = test_1.mref();
18+
test_1_mref.set_MDStatisticStatus().as_Active();
19+
REQUIRE(test_case.encoding(test_1.cref(),"\xc0\x81\x80",true));
20+
REQUIRE(test_case.decoding("\xc0\x81\x80",test_1.cref(),true));
21+
}
22+
23+
SECTION("No optional enum / Inactive")
24+
{
25+
fast_test_coding_case<simple18::templates_description> test_case;
26+
simple18::Test_1 test_1;
27+
simple18::Test_1_mref test_1_mref = test_1.mref();
28+
test_1_mref.set_MDStatisticStatus().as_Inactive();
29+
REQUIRE(test_case.encoding(test_1.cref(),"\xe0\x81\x81\x80",true));
30+
REQUIRE(test_case.decoding("\xe0\x81\x81\x80",test_1.cref(),true));
31+
}
32+
33+
SECTION("Optional enum")
34+
{
35+
fast_test_coding_case<simple18::templates_description> test_case;
36+
simple18::Test_1 test_1;
37+
simple18::Test_1_mref test_1_mref = test_1.mref();
38+
test_1_mref.set_MDStatisticStatus().as_Inactive();
39+
test_1_mref.set_MDStatisticFrequencyUnit().as_Minutes();
40+
REQUIRE(test_case.encoding(test_1.cref(),"\xe0\x81\x81\x83",true));
41+
REQUIRE(test_case.decoding("\xe0\x81\x81\x83",test_1.cref(),true));
42+
}
43+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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 "simple18.h"
8+
9+
using namespace test::coding;
10+
11+
TEST_CASE("xetra enum test encoder_V2/decoder_v2","[xetra_enum_encoder_v2_decoder_v2]")
12+
{
13+
SECTION("No optional enum / Active")
14+
{
15+
fast_test_coding_case_v2<simple18::templates_description> test_case;
16+
simple18::Test_1 test_1;
17+
simple18::Test_1_mref test_1_mref = test_1.mref();
18+
test_1_mref.set_MDStatisticStatus().as_Active();
19+
REQUIRE(test_case.encoding(test_1.cref(),"\xc0\x81\x80",true));
20+
REQUIRE(test_case.decoding("\xc0\x81\x80",test_1.cref(),true));
21+
}
22+
23+
SECTION("No optional enum / Inactive")
24+
{
25+
fast_test_coding_case_v2<simple18::templates_description> test_case;
26+
simple18::Test_1 test_1;
27+
simple18::Test_1_mref test_1_mref = test_1.mref();
28+
test_1_mref.set_MDStatisticStatus().as_Inactive();
29+
REQUIRE(test_case.encoding(test_1.cref(),"\xe0\x81\x81\x80",true));
30+
REQUIRE(test_case.decoding("\xe0\x81\x81\x80",test_1.cref(),true));
31+
}
32+
33+
SECTION("Optional enum")
34+
{
35+
fast_test_coding_case_v2<simple18::templates_description> test_case;
36+
simple18::Test_1 test_1;
37+
simple18::Test_1_mref test_1_mref = test_1.mref();
38+
test_1_mref.set_MDStatisticStatus().as_Inactive();
39+
test_1_mref.set_MDStatisticFrequencyUnit().as_Minutes();
40+
REQUIRE(test_case.encoding(test_1.cref(),"\xe0\x81\x81\x83",true));
41+
REQUIRE(test_case.decoding("\xe0\x81\x81\x83",test_1.cref(),true));
42+
}
43+
}

0 commit comments

Comments
 (0)