*/
#include <sstream>
#include <fstream>
#include <string>
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MAIN
#define BOOST_TEST_MODULE YieldTestSuite
#include <boost/test/unit_test.hpp>
#include <stdair/basic/BasLogParams.hpp>
#include <stdair/basic/BasDBParams.hpp>
#include <stdair/basic/BasFileMgr.hpp>
#include <stdair/bom/TravelSolutionStruct.hpp>
#include <stdair/service/Logger.hpp>
#include <airrac/config/airrac-paths.hpp>
namespace boost_utf = boost::unit_test;
std::ofstream utfReportStream ("YieldTestSuite_utfresults.xml");
struct UnitTestConfig {
UnitTestConfig() {
boost_utf::unit_test_log.set_stream (utfReportStream);
boost_utf::unit_test_log.set_format (boost_utf::XML);
boost_utf::unit_test_log.set_threshold_level (boost_utf::log_test_units);
}
~UnitTestConfig() {
}
};
void testYieldQuoterHelper (const unsigned short iTestFlag,
const stdair::Filename_T iYieldInputFilename,
const bool isBuiltin) {
std::ostringstream oStr;
oStr << "FQTTestSuite_" << iTestFlag << ".log";
const stdair::Filename_T lLogFilename (oStr.str());
std::ofstream logOutputFile;
logOutputFile.open (lLogFilename.c_str());
logOutputFile.clear();
const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG,
logOutputFile);
stdair::TravelSolutionList_T lTravelSolutionList;
airracService.buildSampleTravelSolutions (lTravelSolutionList);
if (isBuiltin == true) {
airracService.buildSampleBom();
} else {
airracService.parseAndLoad (lYieldFilePath);
}
airracService.calculateYields (lTravelSolutionList);
logOutputFile.close();
}
BOOST_GLOBAL_FIXTURE (UnitTestConfig);
BOOST_AUTO_TEST_SUITE (master_test_suite)
BOOST_AUTO_TEST_CASE (airrac_simple_yield) {
const stdair::Filename_T lYieldInputFilename (STDAIR_SAMPLE_DIR "/yieldstore01.csv");
const bool isBuiltin = false;
BOOST_CHECK_NO_THROW (testYieldQuoterHelper (0, lYieldInputFilename, isBuiltin));
}
BOOST_AUTO_TEST_CASE (airrac_error_parsing_input_file) {
const stdair::Filename_T lYieldInputFilename (STDAIR_SAMPLE_DIR "/yieldstoreError01.csv");
const bool isBuiltin = false;
BOOST_CHECK_THROW (testYieldQuoterHelper (1, lYieldInputFilename, isBuiltin),
}
BOOST_AUTO_TEST_CASE (airrac_error_missing_input_file) {
const stdair::Filename_T lYieldInputFilename (STDAIR_SAMPLE_DIR "/missingFile.csv");
const bool isBuiltin = false;
BOOST_CHECK_THROW (testYieldQuoterHelper (2, lYieldInputFilename, isBuiltin),
}
BOOST_AUTO_TEST_CASE (airrac_simple_yield_built_in) {
const bool isBuiltin = true;
BOOST_CHECK_NO_THROW (testYieldQuoterHelper (3, " ", isBuiltin));
}
BOOST_AUTO_TEST_SUITE_END()