bioweb  0.09.92
C++/Python(django)/JavaScript(angularJS) framework
calc_test.cpp
1 
6 #define BOOST_TEST_DYN_LINK
7 #define BOOST_TEST_MAIN
8 
9 #include <boost/test/unit_test.hpp>
10 
11 
12 #include "../src/calc.hpp"
13 
14 using namespace boost;
15 using boost::unit_test::test_suite;
16 
17 BOOST_AUTO_TEST_SUITE( calc_test )
18 
19 BOOST_AUTO_TEST_CASE( TestGetNumber )
20 {
21  BOOST_CHECK_EQUAL( getNumber(), 1234 );
22 }
23 
24 BOOST_AUTO_TEST_CASE( CommandMgrTest )
25 {
26  mt4cpp::CommandID id1 = CommandManager::getInstance().runTickCommand();
27  mt4cpp::CommandID id2 = CommandManager::getInstance().runTickCommand();
28  mt4cpp::CommandID id3 = CommandManager::getInstance().runTickCommand();
29 
30  std::vector<mt4cpp::CommandID> keys = CommandManager::getInstance().commandKeys();
31 
32  BOOST_CHECK_EQUAL( keys.size(), 3U );
33  BOOST_CHECK_EQUAL( keys[0], id1 );
34  BOOST_CHECK_EQUAL( keys[1], id2 );
35  BOOST_CHECK_EQUAL( keys[2], id3 );
36 
37  BOOST_CHECK( CommandManager::getInstance().findCommandDesc(id1).state_ != mt4cpp::CommandDesc::DONE );
38  BOOST_CHECK( CommandManager::getInstance().findCommandDesc(id2).state_ != mt4cpp::CommandDesc::DONE );
39  BOOST_CHECK( CommandManager::getInstance().findCommandDesc(id3).state_ != mt4cpp::CommandDesc::DONE );
40 
41  boost::this_thread::sleep(boost::posix_time::millisec(500)); //po 0.5 sec need to be finished (command executes 0.2s)
42 
43  BOOST_CHECK( CommandManager::getInstance().findCommandDesc(id1).state_ == mt4cpp::CommandDesc::DONE );
44  BOOST_CHECK( CommandManager::getInstance().findCommandDesc(id2).state_ == mt4cpp::CommandDesc::DONE );
45  BOOST_CHECK( CommandManager::getInstance().findCommandDesc(id3).state_ == mt4cpp::CommandDesc::DONE );
46 
47  BOOST_CHECK_EQUAL( CommandManager::getInstance().commandKeys().size(), 3U );
48  CommandManager::getInstance().clearHistory();
49  BOOST_CHECK_EQUAL( CommandManager::getInstance().commandKeys().size(), 0U );
50 }
51 
52 BOOST_AUTO_TEST_SUITE_END()