forked from objectcomputing/mFAST
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset_encoder_decoder.cpp
More file actions
51 lines (42 loc) · 1.76 KB
/
set_encoder_decoder.cpp
File metadata and controls
51 lines (42 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "catch.hpp"
#include <mfast.h>
#include "fast_test_coding_case.hpp"
#include "byte_stream.h"
#include "simple19.h"
using namespace test::coding;
TEST_CASE("set encoder/decoder","[set_encoder_decoder]")
{
fast_test_coding_case<simple19::templates_description> test_case;
simple19::Test_1 test_1;
simple19::Test_1_mref test_1_mref = test_1.mref();
test_1_mref.set_field1().as(10);
auto TradeCondition = test_1_mref.set_TradeCondition();
TradeCondition.set_OpeningPrice();
TradeCondition.set_OfficialClosingPrice();
REQUIRE(test_case.encoding(test_1.cref(),"\xF0\x81\x8A\x94",true));
REQUIRE(test_case.decoding("\xF0\x81\x8A\x94",test_1.cref(),true));
}
TEST_CASE("set optional field encoder/decoder","[set_optional_encoder_decoder]")
{
SECTION("optional field present")
{
fast_test_coding_case<simple19::templates_description> test_case;
simple19::Test_3 test_3;
simple19::Test_3_mref test_3_mref = test_3.mref();
test_3_mref.set_field3().as(10);
test_3_mref.set_TradeCondition().set_VolumeOnly();
REQUIRE(test_3.cref().get_TradeCondition().present());
REQUIRE(test_case.encoding(test_3.cref(), "\xF0\x83\x8A\x02\x81", true));
REQUIRE(test_case.decoding("\xF0\x83\x8A\x02\x81", test_3.cref(), true));
}
SECTION("optional field not present")
{
fast_test_coding_case<simple19::templates_description> test_case;
simple19::Test_3 test_3;
simple19::Test_3_mref test_3_mref = test_3.mref();
test_3_mref.set_field3().as(10);
REQUIRE(!test_3.cref().get_TradeCondition().present());
REQUIRE(test_case.encoding(test_3.cref(), "\xE0\x83\x8A", true));
REQUIRE(test_case.decoding("\xE0\x83\x8A", test_3.cref(), true));
}
}