Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/mfast/coder/decoder/fast_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ message_type *fast_decoder_impl::decode_segment(fast_istreambuf &sb) {
for (auto &&field : message->ref()) {
apply_mutator(*this, field);
}
this->current_ = nullptr;
return message;
}

Expand Down
10 changes: 10 additions & 0 deletions src/mfast/enum_ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ class MFAST_EXPORT enum_cref : public field_cref {
}
bool is_boolean() const;

protected:
friend class mfast::detail::codec_helper;

void save_to(value_storage &v) const {
v.of_uint64.content_ = this->storage()->of_uint64.content_;
v.defined(true);
v.present(this->present());
}

private:
enum_cref &operator=(const enum_cref &);
};
Expand All @@ -70,6 +79,7 @@ class enum_mref : public make_field_mref<enum_cref> {

enum_mref(const enum_mref &) = default;

explicit enum_mref(const field_mref_base &other) : base_type(other) {}
void as(const enum_cref &cref) const {
if (cref.absent()) {
this->omit();
Expand Down
2 changes: 0 additions & 2 deletions src/mfast/ext_ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,10 @@ class ext_mref : public ext_ref_properties<OpType, Properties> {
storage->present(true);
}
return mref_type(base_);
;
}

cref_type get() const {
return cref_type(base_);
;
}

bool present() const { return !this->optional() || base_.present(); }
Expand Down
5 changes: 4 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ FASTTYPEGEN_TARGET(simple_types12 simple12.xml)
FASTTYPEGEN_TARGET(simple_types13 simple13.xml)
FASTTYPEGEN_TARGET(simple_types14 simple14.xml)
FASTTYPEGEN_TARGET(simple_types15 simple15.xml)

FASTTYPEGEN_TARGET(simple_types16 simple16.xml)

FASTTYPEGEN_TARGET(test_types1 test1.xml test2.xml)
FASTTYPEGEN_TARGET(test_types3 test3.xml)
Expand Down Expand Up @@ -70,6 +70,7 @@ add_executable (mfast_test
${FASTTYPEGEN_simple_types13_OUTPUTS}
${FASTTYPEGEN_simple_types14_OUTPUTS}
${FASTTYPEGEN_simple_types15_OUTPUTS}
${FASTTYPEGEN_simple_types16_OUTPUTS}
fast_type_gen_test.cpp
dictionary_builder_test.cpp
json_test.cpp
Expand All @@ -82,6 +83,8 @@ add_executable (mfast_test
scp_reset_test.cpp
template_repo_base.cpp
message_pmap_test.cpp
enum_encoder_decoder_v2.cpp
enum_encoder_decoder.cpp
)

target_link_libraries (mfast_test
Expand Down
19 changes: 19 additions & 0 deletions tests/enum_encoder_decoder.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "catch.hpp"
#include <mfast.h>

#include "fast_test_coding_case.hpp"
#include "byte_stream.h"

#include "simple16.h"

using namespace test::coding;

TEST_CASE("enum test encoder/decoder","[enum_encoder_decoder]")
{
fast_test_coding_case<simple16::templates_description> test_case;
simple16::Test_1 test_1;
simple16::Test_1_mref test_1_mref = test_1.mref();
test_1_mref.set_discrete().as_Three();
REQUIRE(test_case.encoding(test_1.cref(),"\xC0\x81\x83",true));
REQUIRE(test_case.decoding("\xC0\x81\x83",test_1.cref(),true));
}
19 changes: 19 additions & 0 deletions tests/enum_encoder_decoder_v2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "catch.hpp"
#include <mfast.h>

#include "fast_test_coding_case_v2.hpp"
#include "byte_stream.h"

#include "simple16.h"

using namespace test::coding;

TEST_CASE("enum test encoder_V2/decoder_v2","[enum_encoder_v2_decoder_v2]")
{
fast_test_coding_case_v2<simple16::templates_description> test_case;
simple16::Test_1 test_1;
simple16::Test_1_mref test_1_mref = test_1.mref();
test_1_mref.set_discrete().as_Three();
REQUIRE(test_case.encoding(test_1.cref(),"\xC0\x81\x83",true));
REQUIRE(test_case.decoding("\xC0\x81\x83",test_1.cref(),true));
}
2 changes: 1 addition & 1 deletion tests/fast_test_coding_case.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class fast_test_coding_case
if (result == byte_stream(buffer, encoded_size))
return true;

INFO( "Got \"" << byte_stream(buffer, encoded_size) << "\" instead." );
INFO( "Got \"" << byte_stream(buffer, encoded_size) << "\" instead." );
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/fast_test_coding_case_v2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class fast_test_coding_case_v2
if (result == byte_stream(buffer, encoded_size))
return true;

INFO( "Got \"" << byte_stream(buffer, encoded_size) << "\" instead." );
INFO( "Got \"" << byte_stream(buffer, encoded_size) << "\" instead." );
return false;
}

Expand Down
21 changes: 21 additions & 0 deletions tests/simple16.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates
xmlns="http://www.fixprotocol.org/ns/fast/td/1.2"
xmlns:scp="http://www.fixprotocol.org/ns/fast/scp/1.2"
templateNs="https://www.deutsche-boerse.com/rta">
<define name="DiscreteEnum">
<enum>
<element name="One" value="1"/>
<element name="Three" value="3"/>
<element name="Five" value="5"/>
</enum>
</define>
<!-- Define templates-->
<template name="Test_1" id="1">
<string name="MsgType" id="35"><constant value="DP"/></string>
<field name="discrete" id="2477"><type name="DiscreteEnum"></type></field>
</template>
<template name="Test_2" id="2">
<string name="MsgType" id="36"><constant value="DQ"/></string>
</template>
</templates>