6 #define BOOST_TEST_DYN_LINK
7 #define BOOST_TEST_MAIN
9 #include <boost/test/unit_test.hpp>
12 #include "../src/calc.hpp"
14 using namespace boost;
15 using boost::unit_test::test_suite;
17 BOOST_AUTO_TEST_SUITE( calc_test )
19 BOOST_AUTO_TEST_CASE( TestGetNumber )
21 BOOST_CHECK_EQUAL( getNumber(), 1234 );
24 BOOST_AUTO_TEST_CASE( CommandMgrTest )
26 mt4cpp::CommandID id1 = CommandManager::getInstance().runTickCommand();
27 mt4cpp::CommandID id2 = CommandManager::getInstance().runTickCommand();
28 mt4cpp::CommandID id3 = CommandManager::getInstance().runTickCommand();
30 std::vector<mt4cpp::CommandID> keys = CommandManager::getInstance().commandKeys();
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 );
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 );
41 boost::this_thread::sleep(boost::posix_time::millisec(500));
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 );
47 BOOST_CHECK_EQUAL( CommandManager::getInstance().commandKeys().size(), 3U );
48 CommandManager::getInstance().clearHistory();
49 BOOST_CHECK_EQUAL( CommandManager::getInstance().commandKeys().size(), 0U );
52 BOOST_AUTO_TEST_SUITE_END()