SEvMgr Logo  0.2.0
C++ Simulation-Oriented Discrete Event Management Library
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
EventQueueManagementTestSuite.cpp
Go to the documentation of this file.
1 
5 // //////////////////////////////////////////////////////////////////////
6 // Import section
7 // //////////////////////////////////////////////////////////////////////
8 // STL
9 #include <sstream>
10 #include <fstream>
11 #include <map>
12 #include <cmath>
13 // Boost Unit Test Framework (UTF)
14 #define BOOST_TEST_DYN_LINK
15 #define BOOST_TEST_MAIN
16 #define BOOST_TEST_MODULE EventQueueManagementTest
17 #include <boost/test/unit_test.hpp>
18 // StdAir
19 #include <stdair/stdair_basic_types.hpp>
20 #include <stdair/basic/BasLogParams.hpp>
21 #include <stdair/basic/BasDBParams.hpp>
22 #include <stdair/basic/BasFileMgr.hpp>
23 #include <stdair/basic/ProgressStatusSet.hpp>
24 #include <stdair/bom/EventStruct.hpp>
25 #include <stdair/bom/EventQueue.hpp>
26 #include <stdair/bom/BookingRequestStruct.hpp>
27 #include <stdair/service/Logger.hpp>
28 // SEvMgr
31 
32 namespace boost_utf = boost::unit_test;
33 
34 // (Boost) Unit Test XML Report
35 std::ofstream utfReportStream ("EventQueueManagementTestSuite_utfresults.xml");
36 
40 struct UnitTestConfig {
42  UnitTestConfig() {
43  boost_utf::unit_test_log.set_stream (utfReportStream);
44  boost_utf::unit_test_log.set_format (boost_utf::XML);
45  boost_utf::unit_test_log.set_threshold_level (boost_utf::log_test_units);
46  //boost_utf::unit_test_log.set_threshold_level (boost_utf::log_successful_tests);
47  }
48 
50  ~UnitTestConfig() {
51  }
52 };
53 
54 // Specific type definitions
55 typedef std::pair<stdair::Count_T, stdair::Count_T> NbOfEventsPair_T;
56 typedef std::map<const stdair::DemandStreamKeyStr_T,
57  NbOfEventsPair_T> NbOfEventsByDemandStreamMap_T;
58 
59 
60 // /////////////// Main: Unit Test Suite //////////////
61 
62 // Set the UTF configuration (re-direct the output to a specific file)
63 BOOST_GLOBAL_FIXTURE (UnitTestConfig);
64 
65 // Start the test suite
66 BOOST_AUTO_TEST_SUITE (master_test_suite)
67 
68 
71 BOOST_AUTO_TEST_CASE (sevmgr_simple_simulation_test) {
72 
73  // Input file name
74  const stdair::Filename_T lInputFilename (STDAIR_SAMPLE_DIR "/demand01.csv");
75 
76  // Check that the file path given as input corresponds to an actual file
77  const bool doesExistAndIsReadable =
78  stdair::BasFileMgr::doesExistAndIsReadable (lInputFilename);
79  BOOST_CHECK_MESSAGE (doesExistAndIsReadable == true,
80  "The '" << lInputFilename
81  << "' input file can not be open and read");
82 
83  // Output log File
84  const stdair::Filename_T lLogFilename ("EventQueueManagementTestSuite.log");
85 
86  // Set the log parameters
87  std::ofstream logOutputFile;
88  // open and clean the log outputfile
89  logOutputFile.open (lLogFilename.c_str());
90  logOutputFile.clear();
91 
92  // Initialise the Sevmgr service object
93  const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile);
94  SEVMGR::SEVMGR_Service sevmgrService (lLogParams);
95 
97  sevmgrService.buildSampleBom();
98 
101  sevmgrService.reset();
102 
103  // DEBUG
104  STDAIR_LOG_DEBUG ("End of the simulation");
105 
106  // Close the log file
107  logOutputFile.close();
108 }
109 
110 // End the test suite
111 BOOST_AUTO_TEST_SUITE_END()
112 
113