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,159 @@
|
||||
#include "catch/catch.hpp"
|
||||
|
||||
#include "lib/jetfix/connection/AsyncReader.h"
|
||||
#include "lib/jetfix/common/InMsgBuffer.h"
|
||||
#include "lib/jetfix/gateway/ICoreGatewayEventSink.h"
|
||||
#include "lib/jetfix/connection/IConnection.h"
|
||||
#include "lib/jetfix/tests/sample_fix.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
namespace bts {
|
||||
namespace jetfix {
|
||||
|
||||
const static char *sample_logon =
|
||||
"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"
|
||||
"98=0" "\001"
|
||||
"108=30" "\001"
|
||||
"1603=O2" "\001"
|
||||
"1604=1.0" "\001"
|
||||
"1605=BTS" "\001"
|
||||
"10=046\001";
|
||||
|
||||
const static char *sample_mass_quote =
|
||||
"8=FIX.4.2\001"
|
||||
"9=304\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"
|
||||
|
||||
"10=046\001";
|
||||
|
||||
struct MyGWObserver : public ICoreGatewayEventSink
|
||||
{
|
||||
bool got_eof;
|
||||
std::vector<InMsgBuffer> msgs;
|
||||
|
||||
MyGWObserver () : got_eof (false), msgs () {}
|
||||
|
||||
void session_ready ()
|
||||
{REQUIRE(false);}
|
||||
|
||||
void session_terminated ()
|
||||
{REQUIRE(false);}
|
||||
|
||||
void reader_disconnected ()
|
||||
{got_eof = true;}
|
||||
|
||||
void in_msg_raw (InMsgBuffer const &msg)
|
||||
{msgs.emplace_back (msg);}
|
||||
|
||||
void in_msg_sequenced (InMsgBuffer const &)
|
||||
{REQUIRE(false);}
|
||||
};
|
||||
|
||||
struct Connection : public IConnection
|
||||
{
|
||||
Connection (std::istream &str) : str (str)
|
||||
{}
|
||||
|
||||
bool connect () {return true;}
|
||||
void shutdown () {}
|
||||
|
||||
int read (char* to_buffer,size_t read_count)
|
||||
{
|
||||
str.read (to_buffer,read_count);
|
||||
return str.gcount ();
|
||||
}
|
||||
|
||||
int write (WriteVec const&,size_t,size_t )
|
||||
{return -1;}
|
||||
|
||||
std::istream &str;
|
||||
};
|
||||
|
||||
TEST_CASE ("JetFIX AsyncReaderTests", "[jetfix]")
|
||||
{
|
||||
SECTION ("jeftix_smoke")
|
||||
{
|
||||
std::stringstream str;
|
||||
str << sample_logon << sample_mass_quote;
|
||||
Connection c (str);
|
||||
|
||||
MyGWObserver ob;
|
||||
|
||||
{
|
||||
AsyncReader r (c,"test",ob,10,5);
|
||||
r.start ();
|
||||
}
|
||||
|
||||
REQUIRE(ob.got_eof);
|
||||
REQUIRE(ob.msgs.size () == 2);
|
||||
}
|
||||
|
||||
SECTION ("jeftix_parse_big_file")
|
||||
{
|
||||
std::stringstream f(sample_fix());
|
||||
Connection c (f);
|
||||
|
||||
MyGWObserver ob;
|
||||
|
||||
{
|
||||
AsyncReader r (c,"test",ob,10,5);
|
||||
r.start ();
|
||||
}
|
||||
REQUIRE (ob.got_eof);
|
||||
REQUIRE (ob.msgs.size () == 1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user