Moved code to lib.
This commit is contained in:
1 parent
b982c7462c
commit
7e28a2192a
303 files changed
+594
-594
No files matched your search
@@ -0,0 +1,161 @@
|
||||
#include "catch/catch.hpp"
|
||||
|
||||
#include "lib/jetfix/codec/Fields.h"
|
||||
#include "lib/jetfix/codec/Group.h"
|
||||
#include "lib/jetfix/codec/FIXMsg.h"
|
||||
#include "lib/jetfix/codec/FieldDefinitions.h"
|
||||
#include "lib/jetfix/connection/IConnectionObserver.h"
|
||||
#include "lib/jetfix/common/InMsgBuffer.h"
|
||||
#include "lib/jetfix/codec/FIXParser.h"
|
||||
#include "lib/jetfix/codec/FIXFragment.h"
|
||||
#include "lib/utils/TimeStamp.h"
|
||||
|
||||
namespace bts {
|
||||
namespace jetfix {
|
||||
|
||||
const static char *sample_logon_header =
|
||||
"8=FIX.4.2" "\001"
|
||||
"9=127" "\001"
|
||||
"35=A" "\001"
|
||||
"34=25" "\001"
|
||||
"369=1" "\001"
|
||||
"52=20150427-19:05:18.922" "\001"
|
||||
"49=CME" "\001"
|
||||
"50=G" "\001"
|
||||
"56=1U7001N" "\001"
|
||||
"57=BLUESTREAM" "\001"
|
||||
"143=US,NC" "\001";
|
||||
|
||||
const static char *sample_mass_quote =
|
||||
"8=FIX.4.2\001"
|
||||
"9=234\001"
|
||||
"35=i\001"
|
||||
"34=61\001"
|
||||
"49=1U7001N\001"
|
||||
"50=bluestream\001"
|
||||
"52=20150427-19:29:40.610\001"
|
||||
"56=CME\001"
|
||||
"57=G\001"
|
||||
"142=US,NC\001"
|
||||
"117=58\001"
|
||||
"204=1\001"
|
||||
|
||||
"1028=N\001"
|
||||
"7928=bluestream\001"
|
||||
"9702=1\001"
|
||||
"9771=TESTACC\001"
|
||||
|
||||
"296=1\001"
|
||||
"302=1\001"
|
||||
"304=2\001"
|
||||
"295=2\001"
|
||||
|
||||
"299=10857\001"
|
||||
"55=EZ\001"
|
||||
"167=OPT\001"
|
||||
"107=ESK5 C1855\001"
|
||||
"132=25200\001"
|
||||
"133=25350\001"
|
||||
"134=1\001"
|
||||
"135=1\001"
|
||||
|
||||
"299=10856\001"
|
||||
"55=EZ\001"
|
||||
"167=OPT\001"
|
||||
"107=ESK5 C1890\001"
|
||||
"132=25201\001"
|
||||
"133=25351\001"
|
||||
"134=2\001"
|
||||
"135=2\001";
|
||||
|
||||
TEST_CASE ("Jetfix InMsgTests" ,"[jetfix]")
|
||||
{
|
||||
SECTION ("basic_parsing_works")
|
||||
{
|
||||
InMsgBuffer msg (sample_logon_header,strlen(sample_logon_header)-1,std::shared_ptr<std::string>());
|
||||
REQUIRE (msg.type ()==MessageTypes::Logon);
|
||||
REQUIRE (msg.get_seq_num ()==25);
|
||||
REQUIRE (msg.get_last_seq_num_processed ()==1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("Jeftix ParserTests","[jetfix]")
|
||||
{
|
||||
SECTION("parse_logon")
|
||||
{
|
||||
using namespace fix;
|
||||
typedef FIXMsg<MessageTypes::Logon,
|
||||
BeginString,
|
||||
BodyLength,
|
||||
MsgType,
|
||||
MsgSeqNum,
|
||||
LastSeqNumProcessed,
|
||||
SendingTime,
|
||||
SenderCompID,
|
||||
SenderSubID,
|
||||
TargetCompId,
|
||||
TargetSubID,
|
||||
TargetLocationID>
|
||||
LogonMsg;
|
||||
|
||||
LogonMsg m;
|
||||
m.read (sample_logon_header);
|
||||
REQUIRE (m.get<BeginString>()=="FIX.4.2");
|
||||
REQUIRE (m.get<BodyLength>()== 127);
|
||||
REQUIRE (m.get<MsgType>()=="A");
|
||||
REQUIRE (m.get<MsgSeqNum>()==25);
|
||||
REQUIRE (m.get<LastSeqNumProcessed>()==1);
|
||||
REQUIRE (m.get<SendingTime>()==datetime::make_ptime (2015,4,27,19,5,18,922));
|
||||
REQUIRE (m.get<SenderCompID>()=="CME");
|
||||
REQUIRE (m.get<SenderSubID>()=="G");
|
||||
REQUIRE (m.get<TargetCompId>()=="1U7001N");
|
||||
REQUIRE (m.get<TargetSubID>()=="BLUESTREAM");
|
||||
REQUIRE (m.get<TargetLocationID>()=="US,NC");
|
||||
}
|
||||
|
||||
SECTION("parse_group")
|
||||
{
|
||||
using namespace fix;
|
||||
typedef FIXMsg<MessageTypes::MassQuote,
|
||||
QuoteID,
|
||||
CustomerOrFirm,
|
||||
QuoteSets,
|
||||
ManualOrderIndicator> MassQuote;
|
||||
|
||||
MassQuote m;
|
||||
m.read (sample_mass_quote);
|
||||
REQUIRE (m.get<QuoteID>()=="58");
|
||||
REQUIRE (m.get<CustomerOrFirm>()==1);
|
||||
REQUIRE (m.get<ManualOrderIndicator>()==false);
|
||||
|
||||
auto &qs = m.get<QuoteSets> ();
|
||||
REQUIRE (qs.size ()==1);
|
||||
REQUIRE (qs[0].get<QuoteSetID>()=="1");
|
||||
REQUIRE (qs[0].get<TotQuoteEntries>()==2);
|
||||
|
||||
auto &qe = qs[0].get<QuoteEntries> ();
|
||||
REQUIRE (qe.size ()==2);
|
||||
REQUIRE (qe[0].get<QuoteEntryID>()=="10857");
|
||||
REQUIRE (qe[0].get<Symbol>()=="EZ");
|
||||
REQUIRE (qe[0].get<SecurityType>()=="OPT");
|
||||
REQUIRE (qe[0].get<SecurityDesc>()=="ESK5 C1855");
|
||||
REQUIRE (qe[0].get<BidPx>()==25200);
|
||||
REQUIRE (qe[0].get<OfferPx>()==25350);
|
||||
REQUIRE (qe[0].get<BidSize>()==1);
|
||||
REQUIRE (qe[0].get<OfferSize>()==1);
|
||||
|
||||
REQUIRE (qe[1].get<QuoteEntryID>()=="10856");
|
||||
REQUIRE (qe[1].get<Symbol>()=="EZ");
|
||||
REQUIRE (qe[1].get<SecurityType>()=="OPT");
|
||||
REQUIRE (qe[1].get<SecurityDesc>()=="ESK5 C1890");
|
||||
REQUIRE (qe[1].get<BidPx>()==25201);
|
||||
REQUIRE (qe[1].get<OfferPx>()==25351);
|
||||
REQUIRE (qe[1].get<BidSize>()==2);
|
||||
REQUIRE (qe[1].get<OfferSize>()==2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}}
|
||||
|
||||
Reference in new issue
Block a user