9 #include <boost/test/unit_test.hpp> 11 #define BOOST_TEST_MODULE test_hikyuu_trade_sys_suite 12 #include <boost/test/unit_test.hpp> 17 #if HKU_SUPPORT_SERIALIZATION 20 #include <boost/archive/xml_oarchive.hpp> 21 #include <boost/archive/xml_iarchive.hpp> 22 #include <hikyuu/StockManager.h> 23 #include <hikyuu/trade_sys/system/build_in.h> 35 StockManager& sm = StockManager::instance();
36 string filename(sm.tmpdir());
37 filename +=
"/TradeRequest.xml";
41 tr1.business = BUSINESS_BUY;
42 tr1.datetime = Datetime(201001100000);
45 tr1.from = PART_SIGNAL;
48 std::ofstream ofs(filename);
49 boost::archive::xml_oarchive oa(ofs);
50 oa << BOOST_SERIALIZATION_NVP(tr1);
55 std::ifstream ifs(filename);
56 boost::archive::xml_iarchive ia(ifs);
57 ia >> BOOST_SERIALIZATION_NVP(tr2);
60 BOOST_CHECK(tr1.valid == tr2.valid);
61 BOOST_CHECK(tr1.business == tr2.business);
62 BOOST_CHECK(tr1.datetime == tr2.datetime);
63 BOOST_CHECK(tr1.stoploss == tr2.stoploss);
64 BOOST_CHECK(tr1.number == tr2.number);
65 BOOST_CHECK(tr1.from == tr2.from);
66 BOOST_CHECK(tr1.count == tr2.count);
72 StockManager& sm = StockManager::instance();
73 string filename(sm.tmpdir());
74 filename +=
"/SYS_Simple.xml";
76 SystemPtr sg1 = SYS_Simple();
78 std::ofstream ofs(filename);
79 boost::archive::xml_oarchive oa(ofs);
80 oa << BOOST_SERIALIZATION_NVP(sg1);
85 std::ifstream ifs(filename);
86 boost::archive::xml_iarchive ia(ifs);
87 ia >> BOOST_SERIALIZATION_NVP(sg2);
90 BOOST_CHECK(sg1->name() == sg2->name());
BOOST_AUTO_TEST_CASE(test_Datetime)