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/signal/build_in.h>
24 #include <hikyuu/indicator/crt/AMA.h>
25 
26 using namespace hku;
27 
35 BOOST_AUTO_TEST_CASE( test_SG_AMA_export ) {
36  StockManager& sm = StockManager::instance();
37  string filename(sm.tmpdir());
38  filename += "/SG_AMA.xml";
39 
40  SignalPtr sg1 = SG_Single(AMA());
41  {
42  std::ofstream ofs(filename);
43  boost::archive::xml_oarchive oa(ofs);
44  oa << BOOST_SERIALIZATION_NVP(sg1);
45  }
46 
47  SignalPtr sg2;
48  {
49  std::ifstream ifs(filename);
50  boost::archive::xml_iarchive ia(ifs);
51  ia >> BOOST_SERIALIZATION_NVP(sg2);
52  }
53 
54  BOOST_CHECK(sg1->name() == sg2->name());
55 }
56 
57 
60 #endif /* HKU_SUPPORT_SERIALIZATION */
61 
62 
63 
64 
BOOST_AUTO_TEST_CASE(test_Datetime)