test_doc
test_export.cpp
浏览该文件的文档.
1 /*
2  * test_export.cpp
3  *
4  * Created on: 2013-4-30
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/moneymanager/build_in.h>
24 
25 using namespace hku;
26 
34 BOOST_AUTO_TEST_CASE( test_MM_FixedCount_export ) {
35  StockManager& sm = StockManager::instance();
36  string filename(sm.tmpdir());
37  filename += "/Fixed_MM.xml";
38 
39  MoneyManagerPtr mm1 = MM_FixedCount(100);
40  {
41  std::ofstream ofs(filename);
42  boost::archive::xml_oarchive oa(ofs);
43  oa << BOOST_SERIALIZATION_NVP(mm1);
44  }
45 
46  MoneyManagerPtr mm2;
47  {
48  std::ifstream ifs(filename);
49  boost::archive::xml_iarchive ia(ifs);
50  ia >> BOOST_SERIALIZATION_NVP(mm2);
51  }
52 
53  BOOST_CHECK(mm1->name() == mm2->name());
54 }
55 
56 
59 #endif /* HKU_SUPPORT_SERIALIZATION */
60 
61 
62 
63 
BOOST_AUTO_TEST_CASE(test_Datetime)