Skip to content

Commit e89b2e3

Browse files
committed
Add unit test for the case of the Xetra timestamp
1 parent 8d6b522 commit e89b2e3

4 files changed

Lines changed: 72 additions & 1 deletion

File tree

tests/CMakeLists.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,17 @@ FASTTYPEGEN_TARGET(simple_types14 simple14.xml)
2626
FASTTYPEGEN_TARGET(simple_types15 simple15.xml)
2727
FASTTYPEGEN_TARGET(simple_types16 simple16.xml)
2828

29+
if(XETRA_FAST_SPECIFICATION)
30+
FASTTYPEGEN_TARGET(simple_types17 simple17.xml)
31+
endif(XETRA_FAST_SPECIFICATION)
32+
2933
FASTTYPEGEN_TARGET(test_types1 test1.xml test2.xml)
3034
FASTTYPEGEN_TARGET(test_types3 test3.xml)
3135
FASTTYPEGEN_TARGET(test_types4 test4.xml)
3236
FASTTYPEGEN_TARGET(test_types5 test5.xml)
3337
FASTTYPEGEN_TARGET(test_scp scp.xml)
3438

35-
add_executable (mfast_test
39+
set(test_sources
3640
test_main.cpp
3741
arena_allocator_test.cpp
3842
field_ref_test.cpp
@@ -87,6 +91,16 @@ add_executable (mfast_test
8791
enum_encoder_decoder.cpp
8892
)
8993

94+
if(XETRA_FAST_SPECIFICATION)
95+
set(test_sources ${test_sources}
96+
${FASTTYPEGEN_simple_types17_OUTPUTS}
97+
timestamp_encoder_decoder_v2.cpp
98+
timestamp_encoder_decoder.cpp
99+
)
100+
endif(XETRA_FAST_SPECIFICATION)
101+
102+
add_executable (mfast_test ${test_sources})
103+
90104
target_link_libraries (mfast_test
91105
mfast_static
92106
mfast_coder_static

tests/simple17.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" ?>
2+
<templates xmlns="http://www.fixprotocol.org/ns/template-definition"
3+
templateNs="http://www.fixprotocol.org/ns/templates/sample"
4+
ns="http://www.fixprotocol.org/ns/fix">
5+
<template name="Test_1" id="1">
6+
<uInt32 name="field1" id="11"><copy/></uInt32>
7+
<timestamp name="TransactTime" unit="nanosecond" id="60" presence="optional"><copy/></timestamp>
8+
</template>
9+
<template name="Test_2" id="2">
10+
<uInt32 name="field4" id="21"><copy/></uInt32>
11+
<uInt32 name="field5" id="22"><copy/></uInt32>
12+
<uInt32 name="field6" id="23"><copy/></uInt32>
13+
</template>
14+
</templates>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include "catch.hpp"
2+
#include <mfast.h>
3+
4+
#include "fast_test_coding_case.hpp"
5+
#include "byte_stream.h"
6+
7+
#include "simple17.h"
8+
9+
using namespace test::coding;
10+
11+
TEST_CASE("timestamp test encoder/decoder","[timestamp_encoder_decoder]")
12+
{
13+
fast_test_coding_case<simple17::templates_description> test_case;
14+
simple17::Test_1 test_1;
15+
simple17::Test_1_mref test_1_mref = test_1.mref();
16+
test_1_mref.set_field1().as(1);
17+
test_1_mref.set_TransactTime().as(2);
18+
REQUIRE(test_case.encoding(test_1.cref(),"\xF0\x81\x81\x83",true));
19+
REQUIRE(test_case.decoding("\xF0\x81\x81\x83",test_1.cref(),true));
20+
}
21+
22+
23+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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 "simple17.h"
8+
9+
using namespace test::coding;
10+
11+
TEST_CASE("timestamp test encoder_V2/decoder_v2","[timestamp_encoder_v2_decoder_v2]")
12+
{
13+
fast_test_coding_case_v2<simple17::templates_description> test_case;
14+
simple17::Test_1 test_1;
15+
simple17::Test_1_mref test_1_mref = test_1.mref();
16+
test_1_mref.set_field1().as(1);
17+
test_1_mref.set_TransactTime().as(2);
18+
REQUIRE(test_case.encoding(test_1.cref(),"\xF0\x81\x81\x83",true));
19+
REQUIRE(test_case.decoding("\xF0\x81\x81\x83",test_1.cref(),true));
20+
}

0 commit comments

Comments
 (0)