Skip to content

Commit

Permalink
Added coder v2 test corresponding to pull request objectcomputing#67
Browse files Browse the repository at this point in the history
  • Loading branch information
huangminghuang committed Dec 27, 2016
1 parent f38b350 commit 756acf6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ FASTTYPEGEN_TARGET(simple_types5 simple5.xml)
FASTTYPEGEN_TARGET(simple_types6 simple6.xml)
FASTTYPEGEN_TARGET(simple_types7 simple7.xml)
FASTTYPEGEN_TARGET(simple_types8 simple8.xml)
FASTTYPEGEN_TARGET(simple_types9 simple9.xml)


FASTTYPEGEN_TARGET(test_types1 test1.xml test2.xml)
FASTTYPEGEN_TARGET(test_types3 test3.xml)
Expand Down Expand Up @@ -48,6 +50,7 @@ add_executable (mfast_test
${FASTTYPEGEN_simple_types6_OUTPUTS}
${FASTTYPEGEN_simple_types7_OUTPUTS}
${FASTTYPEGEN_simple_types8_OUTPUTS}
${FASTTYPEGEN_simple_types9_OUTPUTS}
fast_type_gen_test.cpp
dictionary_builder_test.cpp
json_test.cpp
Expand Down
11 changes: 11 additions & 0 deletions tests/simple9.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version=\" 1.0 \"?>
<templates xmlns="http://www.fixprotocol.org/ns/template-definition"
templateNs="http://www.fixprotocol.org/ns/templates/sample" ns="http://www.fixprotocol.org/ns/fix">
<template name="Test" id="1">
<uInt32 name="field1" id="11"><copy/></uInt32>
<sequence name="sequence1" presence="optional">
<uInt32 name="field2" id="12" presence="optional"></uInt32>
<uInt32 name="field3" id="13" presence="optional"></uInt32>
</sequence>
</template>
</templates>
20 changes: 20 additions & 0 deletions tests/simple_coder_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "simple6.h"
#include "simple7.h"
#include "simple8.h"
#include "simple9.h"

#include "byte_stream.h"
#include "debug_allocator.h"
Expand Down Expand Up @@ -274,3 +275,22 @@ TEST_CASE("test fast coder v2 for a template with zero segment size", "[segment_
REQUIRE(test_case.decoding("\x80\x81\x82", msg_ref));
}

TEST_CASE("test fast coder v2 for a simple template with absent optional fields in a sequence", "[absent_optional_fields_coder_test]")
{
fast_coding_test_case<simple9::templates_description> test_case;

debug_allocator alloc;
simple9::Test msg(&alloc);
simple9::Test_mref msg_ref = msg.mref();

msg_ref.set_field1().as(1);

auto sequence1 = msg_ref.set_sequence1();
sequence1.resize(2);
sequence1[0].set_field3().as(3);
sequence1[1].set_field2().as(1);

REQUIRE(test_case.encoding(msg_ref,"\xA0\x81\x83\x80\x84\x82\x80"));
REQUIRE(test_case.decoding("\xA0\x81\x83\x80\x84\x82\x80", msg_ref));
}

0 comments on commit 756acf6

Please sign in to comment.