Skip to content

Commit 99ca09d

Browse files
committed
Add set unit tests
1 parent bc76954 commit 99ca09d

File tree

5 files changed

+159
-0
lines changed

5 files changed

+159
-0
lines changed

tests/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ FASTTYPEGEN_TARGET(simple_types16 simple16.xml)
2929
if(XETRA_FAST_SPECIFICATION)
3030
FASTTYPEGEN_TARGET(simple_types17 simple17.xml)
3131
FASTTYPEGEN_TARGET(simple_types18 simple18.xml)
32+
FASTTYPEGEN_TARGET(simple_types19 simple19.xml)
3233
endif(XETRA_FAST_SPECIFICATION)
3334

3435
FASTTYPEGEN_TARGET(test_types1 test1.xml test2.xml)
@@ -96,10 +97,14 @@ if(XETRA_FAST_SPECIFICATION)
9697
set(test_sources ${test_sources}
9798
${FASTTYPEGEN_simple_types17_OUTPUTS}
9899
${FASTTYPEGEN_simple_types18_OUTPUTS}
100+
${FASTTYPEGEN_simple_types19_OUTPUTS}
99101
timestamp_encoder_decoder_v2.cpp
100102
timestamp_encoder_decoder.cpp
101103
xetra_enum_encoder_decoder_v2.cpp
102104
xetra_enum_encoder_decoder.cpp
105+
set_basic_test.cpp
106+
set_encoder_decoder_v2.cpp
107+
set_encoder_decoder.cpp
103108
)
104109
endif(XETRA_FAST_SPECIFICATION)
105110

tests/set_basic_test.cpp

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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("set data type basic test with default value")
12+
{
13+
fast_test_coding_case_v2<simple18::templates_description> test_case;
14+
simple18::Test_1 test_1;
15+
16+
{
17+
simple18::Test_1_mref test_1_mref = test_1.mref();
18+
auto TradeCondition = test_1_mref.set_TradeCondition();
19+
TradeCondition.set_OpeningPrice();
20+
TradeCondition.set_OfficialClosingPrice();
21+
}
22+
23+
{
24+
simple18::Test_1_cref test_1_cref = test_1.cref();
25+
auto TradeCondition = test_1_cref.get_TradeCondition();
26+
27+
REQUIRE(TradeCondition.value() == (0x00 | simple18::TradeConditionSet::ExchangeLast | simple18::TradeConditionSet::OpeningPrice | simple18::TradeConditionSet::OfficialClosingPrice));
28+
29+
REQUIRE(TradeCondition.has_ExchangeLast());
30+
REQUIRE(TradeCondition.has_OpeningPrice());
31+
REQUIRE(TradeCondition.has_OfficialClosingPrice());
32+
REQUIRE(!TradeCondition.has_Retail());
33+
}
34+
}
35+
36+
TEST_CASE("set data type basic test")
37+
{
38+
fast_test_coding_case_v2<simple18::templates_description> test_case;
39+
simple18::Test_3 test_3;
40+
41+
{
42+
simple18::Test_3_mref test_3_mref = test_3.mref();
43+
auto TradeCondition = test_3_mref.set_TradeCondition();
44+
TradeCondition.set_OpeningPrice();
45+
TradeCondition.set_OfficialClosingPrice();
46+
}
47+
48+
{
49+
simple18::Test_3_cref test_3_cref = test_3.cref();
50+
auto TradeCondition = test_3_cref.get_TradeCondition();
51+
52+
REQUIRE(TradeCondition.value() == (0x00 | simple18::TradeConditionSet::OpeningPrice | simple18::TradeConditionSet::OfficialClosingPrice));
53+
54+
REQUIRE(!TradeCondition.has_ExchangeLast());
55+
REQUIRE(TradeCondition.has_OpeningPrice());
56+
REQUIRE(TradeCondition.has_OfficialClosingPrice());
57+
REQUIRE(!TradeCondition.has_Retail());
58+
}
59+
}

tests/set_encoder_decoder.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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("set encoder/decoder","[set_encoder_decoder]")
12+
{
13+
fast_test_coding_case<simple18::templates_description> test_case;
14+
simple18::Test_1 test_1;
15+
simple18::Test_1_mref test_1_mref = test_1.mref();
16+
17+
test_1_mref.set_field1().as(10);
18+
19+
auto TradeCondition = test_1_mref.set_TradeCondition();
20+
TradeCondition.set_OpeningPrice();
21+
TradeCondition.set_OfficialClosingPrice();
22+
23+
REQUIRE(test_case.encoding(test_1.cref(),"\xF0\x81\x8A\x94",true));
24+
REQUIRE(test_case.decoding("\xF0\x81\x8A\x94",test_1.cref(),true));
25+
}

tests/set_encoder_decoder_v2.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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("set encoder_V2/decoder_v2","[set_encoder_v2_decoder_v2]")
12+
{
13+
fast_test_coding_case_v2<simple18::templates_description> test_case;
14+
simple18::Test_1 test_1;
15+
simple18::Test_1_mref test_1_mref = test_1.mref();
16+
17+
test_1_mref.set_field1().as(10);
18+
19+
auto TradeCondition = test_1_mref.set_TradeCondition();
20+
TradeCondition.set_OpeningPrice();
21+
TradeCondition.set_OfficialClosingPrice();
22+
23+
REQUIRE(test_case.encoding(test_1.cref(),"\xF0\x81\x8A\x94",true));
24+
REQUIRE(test_case.decoding("\xF0\x81\x8A\x94",test_1.cref(),true));
25+
}

tests/simple19.xml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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="TradeConditionSet">
7+
<set>
8+
<element name="U" id="ExchangeLast"/>
9+
<element name="R" id="OpeningPrice"/>
10+
<element name="AX" id="HighPrice"/>
11+
<element name="AY" id="LowPrice"/>
12+
<element name="AJ" id="OfficialClosingPrice"/>
13+
<element name="AW" id="LastAuctionPrice"/>
14+
<element name="k" id="OutOfSequenceETH"/>
15+
<element name="BD" id="PreviousClosingPrice"/>
16+
<element name="a" id="VolumeOnly"/>
17+
<element name="BC" id="TradingOnTermsOfIssue"/>
18+
<element name="SA" id="SpecialAuction"/>
19+
<element name="TC" id="TradeAtClose"/>
20+
<element name="XR" id="Retail"/>
21+
<element name="BB" id="MidpointPrice"/>
22+
</set>
23+
</define>
24+
<template name="Test_1" id="1">
25+
<uInt32 name="field1" id="11"><copy/></uInt32>
26+
<field name="TradeCondition" id="277" presence="optional">
27+
<type name="TradeConditionSet">
28+
<default value="1"/>
29+
</type>
30+
</field>
31+
</template>
32+
<template name="Test_2" id="2">
33+
<uInt32 name="field4" id="21"><copy/></uInt32>
34+
<uInt32 name="field5" id="22"><copy/></uInt32>
35+
<uInt32 name="field6" id="23"><copy/></uInt32>
36+
</template>
37+
<template name="Test_3" id="3">
38+
<uInt32 name="field3" id="11"><copy/></uInt32>
39+
<field name="TradeCondition" id="277" presence="optional">
40+
<type name="TradeConditionSet">
41+
<default/>
42+
</type>
43+
</field>
44+
</template>
45+
</templates>

0 commit comments

Comments
 (0)