FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpp_fix_codec/fix_parser_test.cpp at main · robaho/cpp_fix_codec · GitHub
robaho
/
cpp_fix_codec
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
2
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cpp_fix_codec
/
fix_parser_test.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
68 lines (58 loc) · 2.25 KB
Breadcrumbs
cpp_fix_codec
/
fix_parser_test.cpp
Copy path
File metadata and controls
68 lines (58 loc) · 2.25 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#
define
BOOST_TEST_MODULE
fix
#
include
<
boost/test/included/unit_test.hpp
>
#
include
<
sstream
>
#
include
"
fix.h
"
#
include
"
fix_parser.h
"
#
include
"
samples.h
"
BOOST_AUTO_TEST_CASE
( basic_parsing ) {
GroupDefs defs;
char
buffer[
4096
];
FixMessage msg;
decodeFixToBuffer
(
SAMPLE_NEW_ORDER_SINGLE
,buffer);
FixMessage::parse
(buffer,msg, defs);
BOOST_TEST
(msg.
getString
(
49
)==
"
ABC_DEFG01
"
);
decodeFixToBuffer
(
SAMPLE_CANCEL_REPLACE_QTY_CHANGE
,buffer);
FixMessage::parse
(buffer,msg, defs);
BOOST_TEST
(msg.
getFixed
(
44
)==
"
25.47
"
);
decodeFixToBuffer
(
SAMPLE_LIMIT_ORDER
,buffer);
FixMessage::parse
(buffer,msg, defs);
BOOST_TEST
(msg.
getFixed
(Tag::
PRICE
)==
"
0.01
"
);
BOOST_TEST
(msg.
getFixed
(Tag::
ORDER_QTY
)==
170
);
BOOST_TEST
(msg.
getChar
(
40
)==
'
1
'
);
}
//
test parsing a message where the group_end_tag but it is not in a group because the group count was not seen
BOOST_AUTO_TEST_CASE
( group_end_tag ) {
GroupDefs defs;
defs.
add
(
NEW_ORDER_SINGLE
,{
100
,
54
});
char
buffer[
4096
];
FixMessage msg;
decodeFixToBuffer
(
SAMPLE_NEW_ORDER_SINGLE
,buffer);
FixMessage::parse
(buffer,msg, defs);
BOOST_TEST
(msg.
getString
(Tag::
MSG_TYPE
)==
NEW_ORDER_SINGLE
);
}
BOOST_AUTO_TEST_CASE
( group_parsing ) {
GroupDefs defs;
defs.
add
(
NEW_ORDER_SINGLE
,{
100
,
54
});
char
buffer[
4096
];
FixMessage msg;
decodeFixToBuffer
(
SAMPLE_NEW_ORDER_SINGLE_WITH_GROUP
,buffer);
FixMessage::parse
(buffer,msg,defs);
BOOST_TEST
(msg.
getString
(Tag::
MSG_TYPE
)==
NEW_ORDER_SINGLE
);
BOOST_TEST
(msg.
getString
(
100
,
0
,
55
)==
"
AAPL
"
);
BOOST_TEST
(msg.
getString
(
100
,
1
,
55
)==
"
MSFT
"
);
}
//
test parsing of a stream of messages simulating a fix tcp connection
BOOST_AUTO_TEST_CASE
( stream_parsing ) {
GroupDefs defs;
defs.
add
(
NEW_ORDER_SINGLE
,{
100
,
54
});
char
buffer[
4096
];
decodeFixToBuffer
(
SAMPLE_NEW_ORDER_SINGLE
+
SAMPLE_CANCEL_REPLACE_QTY_CHANGE
+
SAMPLE_NEW_ORDER_SINGLE
,buffer);
std::istringstream
ss
(buffer);
FixMessage msg;
FixMessage::parse
(ss,msg,defs);
BOOST_TEST
(msg.
getString
(Tag::
MSG_TYPE
)==
NEW_ORDER_SINGLE
);
FixMessage::parse
(ss,msg,defs);
BOOST_TEST
(msg.
getString
(Tag::
MSG_TYPE
)==
ORDER_CANCEL_REPLACE_REQUEST
);
FixMessage::parse
(ss,msg,defs);
BOOST_TEST
(msg.
getString
(Tag::
MSG_TYPE
)==
NEW_ORDER_SINGLE
);
}
Back
|
FazBrowse Home
|
New Git URL