test_doc
test_SystemPart.cpp
浏览该文件的文档.
1 /*
2  * test_SystemPart.cpp
3  *
4  * Created on: 2013-4-29
5  * Author: fasiondog
6  */
7 
8 
9 #ifdef TEST_ALL_IN_ONE
10  #include <boost/test/unit_test.hpp>
11 #else
12  #define BOOST_TEST_MODULE test_hikyuu_trade_sys_suite
13  #include <boost/test/unit_test.hpp>
14 #endif
15 
16 #include <hikyuu/trade_sys/system/SystemPart.h>
17 
18 using namespace hku;
19 
27 BOOST_AUTO_TEST_CASE( test_getSystemPartName) {
28  SystemPart part = PART_ENVIRONMENT;
29  BOOST_CHECK(getSystemPartName(part) == "EV");
30 
31  part = PART_CONDITION;
32  BOOST_CHECK(getSystemPartName(part) == "CN");
33 
34  part = PART_SIGNAL;
35  BOOST_CHECK(getSystemPartName(part) == "SG");
36 
37  part = PART_STOPLOSS;
38  BOOST_CHECK(getSystemPartName(part) == "ST");
39 
40  part = PART_MONEYMANAGER;
41  BOOST_CHECK(getSystemPartName(part) == "MM");
42 
43  part = PART_PROFITGOAL;
44  BOOST_CHECK(getSystemPartName(part) == "PG");
45 
46  part = PART_SLIPPAGE;
47  BOOST_CHECK(getSystemPartName(part) == "SP");
48 
49  part = PART_INVALID;
50  BOOST_CHECK(getSystemPartName(part) == "--");
51  BOOST_CHECK(getSystemPartName(part + 1) == "--");
52 }
53 
54 
56 BOOST_AUTO_TEST_CASE( test_getSystemPartEnum) {
57  string part;
58  part = "EV";
59  BOOST_CHECK(getSystemPartEnum(part) == PART_ENVIRONMENT);
60 
61  part = "CN";
62  BOOST_CHECK(getSystemPartEnum(part) == PART_CONDITION);
63 
64  part = "SG";
65  BOOST_CHECK(getSystemPartEnum(part) == PART_SIGNAL);
66 
67  part = "ST";
68  BOOST_CHECK(getSystemPartEnum(part) == PART_STOPLOSS);
69 
70  part = "TP";
71  BOOST_CHECK(getSystemPartEnum(part) == PART_TAKEPROFIT);
72 
73  part = "MM";
74  BOOST_CHECK(getSystemPartEnum(part) == PART_MONEYMANAGER);
75 
76  part = "PG";
77  BOOST_CHECK(getSystemPartEnum(part) == PART_PROFITGOAL);
78 
79  part = "SP";
80  BOOST_CHECK(getSystemPartEnum(part) == PART_SLIPPAGE);
81 
82  part = "E";
83  BOOST_CHECK(getSystemPartEnum(part) == PART_INVALID);
84 
85  part = "--";
86  BOOST_CHECK(getSystemPartEnum(part) == PART_INVALID);
87 }
88 
BOOST_AUTO_TEST_CASE(test_getSystemPartName)