13 #define BOOST_TEST_DYN_LINK
14 #define BOOST_TEST_MAIN
15 #define BOOST_TEST_MODULE YieldTestSuite
16 #include <boost/test/unit_test.hpp>
18 #include <stdair/basic/BasLogParams.hpp>
19 #include <stdair/basic/BasDBParams.hpp>
20 #include <stdair/basic/BasFileMgr.hpp>
21 #include <stdair/bom/TravelSolutionStruct.hpp>
22 #include <stdair/service/Logger.hpp>
25 #include <airrac/config/airrac-paths.hpp>
27 namespace boost_utf = boost::unit_test;
30 std::ofstream utfReportStream (
"YieldTestSuite_utfresults.xml");
35 struct UnitTestConfig {
38 boost_utf::unit_test_log.set_stream (utfReportStream);
39 boost_utf::unit_test_log.set_format (boost_utf::XML);
40 boost_utf::unit_test_log.set_threshold_level (boost_utf::log_test_units);
54 void testYieldQuoterHelper (
const unsigned short iTestFlag,
55 const stdair::Filename_T iYieldInputFilename,
56 const bool isBuiltin) {
59 std::ostringstream oStr;
60 oStr <<
"FQTTestSuite_" << iTestFlag <<
".log";
61 const stdair::Filename_T lLogFilename (oStr.str());
64 std::ofstream logOutputFile;
66 logOutputFile.open (lLogFilename.c_str());
67 logOutputFile.clear();
70 const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG,
77 stdair::TravelSolutionList_T lTravelSolutionList;
78 airracService.buildSampleTravelSolutions (lTravelSolutionList);
81 if (isBuiltin ==
true) {
84 airracService.buildSampleBom();
90 airracService.parseAndLoad (lYieldFilePath);
94 airracService.calculateYields (lTravelSolutionList);
97 logOutputFile.close();
105 BOOST_GLOBAL_FIXTURE (UnitTestConfig);
108 BOOST_AUTO_TEST_SUITE (master_test_suite)
113 BOOST_AUTO_TEST_CASE (airrac_simple_yield) {
116 const stdair::Filename_T lYieldInputFilename (STDAIR_SAMPLE_DIR
"/yieldstore01.csv");
119 const bool isBuiltin =
false;
122 BOOST_CHECK_NO_THROW (testYieldQuoterHelper (0, lYieldInputFilename, isBuiltin));
130 BOOST_AUTO_TEST_CASE (airrac_error_parsing_input_file) {
133 const stdair::Filename_T lYieldInputFilename (STDAIR_SAMPLE_DIR
"/yieldstoreError01.csv");
136 const bool isBuiltin =
false;
139 BOOST_CHECK_THROW (testYieldQuoterHelper (1, lYieldInputFilename, isBuiltin),
147 BOOST_AUTO_TEST_CASE (airrac_error_missing_input_file) {
150 const stdair::Filename_T lYieldInputFilename (STDAIR_SAMPLE_DIR
"/missingFile.csv");
153 const bool isBuiltin =
false;
156 BOOST_CHECK_THROW (testYieldQuoterHelper (2, lYieldInputFilename, isBuiltin),
163 BOOST_AUTO_TEST_CASE (airrac_simple_yield_built_in) {
166 const bool isBuiltin =
true;
169 BOOST_CHECK_NO_THROW (testYieldQuoterHelper (3,
" ", isBuiltin));
174 BOOST_AUTO_TEST_SUITE_END()