test_doc
test_export.cpp
浏览该文件的文档.
1 /*
2  * test_export.cpp
3  *
4  * Created on: 2018-2-10
5  * Author: fasiondog
6  */
7 
8 #ifdef TEST_ALL_IN_ONE
9  #include <boost/test/unit_test.hpp>
10 #else
11  #define BOOST_TEST_MODULE test_hikyuu_trade_sys_suite
12  #include <boost/test/unit_test.hpp>
13 #endif
14 
15 #include <hikyuu/config.h>
16 
17 #if HKU_SUPPORT_SERIALIZATION
18 
19 #include <fstream>
20 #include <boost/archive/xml_oarchive.hpp>
21 #include <boost/archive/xml_iarchive.hpp>
22 #include <hikyuu/StockManager.h>
23 #include <hikyuu/trade_sys/selector/crt/SE_Fixed.h>
24 #include <hikyuu/trade_sys/system/crt/SYS_Simple.h>
25 
26 using namespace hku;
27 
35 BOOST_AUTO_TEST_CASE( test_SE_FIXED_export ) {
36  StockManager& sm = StockManager::instance();
37  string filename(sm.tmpdir());
38  filename += "/SE_FIXED.xml";
39 
40  SYSPtr sys = SYS_Simple();
41  StockList stkList;
42  stkList.push_back(sm["sh600000"]);
43  stkList.push_back(sm["sz000001"]);
44 
45  SEPtr se1 = SE_Fixed(stkList, sys);
46  {
47  std::ofstream ofs(filename);
48  boost::archive::xml_oarchive oa(ofs);
49  oa << BOOST_SERIALIZATION_NVP(se1);
50  }
51 
52  SEPtr se2;
53  {
54  std::ifstream ifs(filename);
55  boost::archive::xml_iarchive ia(ifs);
56  ia >> BOOST_SERIALIZATION_NVP(se2);
57  }
58 
59  BOOST_CHECK(se1->name() == se2->name());
60 }
61 
62 
65 #endif /* HKU_SUPPORT_SERIALIZATION */
66 
67 
68 
69 
BOOST_AUTO_TEST_CASE(test_Datetime)