SimFQT Logo  1.00.9
C++ Simulated Fare Quote System Library
Loading...
Searching...
No Matches
FQTTestSuite.cpp
Go to the documentation of this file.
1
5// //////////////////////////////////////////////////////////////////////
6// Import section
7// //////////////////////////////////////////////////////////////////////
8// STL
9#include <sstream>
10#include <fstream>
11#include <string>
12// Boost Unit Test Framework (UTF)
13#define BOOST_TEST_DYN_LINK
14#define BOOST_TEST_MAIN
15#define BOOST_TEST_MODULE FQTTestSuite
16#include <boost/test/unit_test.hpp>
17// StdAir
18#include <stdair/basic/BasLogParams.hpp>
19#include <stdair/basic/BasDBParams.hpp>
20#include <stdair/basic/BasFileMgr.hpp>
21#include <stdair/service/Logger.hpp>
22#include <stdair/bom/TravelSolutionStruct.hpp>
23#include <stdair/bom/BookingRequestStruct.hpp>
24// SimFQT
26#include <simfqt/config/simfqt-paths.hpp>
27
28namespace boost_utf = boost::unit_test;
29
33struct UnitTestConfig {
35 UnitTestConfig() {
36 static std::ofstream _test_log ("FQTTestSuite_utfresults.xml");
37 boost_utf::unit_test_log.set_stream (_test_log);
38#if BOOST_VERSION_MACRO >= 105900
39 boost_utf::unit_test_log.set_format (boost_utf::OF_XML);
40#else // BOOST_VERSION_MACRO
41 boost_utf::unit_test_log.set_format (boost_utf::XML);
42#endif // BOOST_VERSION_MACRO
43 boost_utf::unit_test_log.set_threshold_level (boost_utf::log_test_units);
44 //boost_utf::unit_test_log.set_threshold_level (boost_utf::log_successful_tests);
45 }
46
48 ~UnitTestConfig() {
49 }
50};
51
52// //////////////////////////////////////////////////////////////////////
56void testFareQuoterHelper (const unsigned short iTestFlag,
57 const stdair::Filename_T iFareInputFilename,
58 const bool isBuiltin) {
59
60 // Output log File
61 std::ostringstream oStr;
62 oStr << "FQTTestSuite_" << iTestFlag << ".log";
63 const stdair::Filename_T lLogFilename (oStr.str());
64
65 // Set the log parameters
66 std::ofstream logOutputFile;
67 // Open and clean the log outputfile
68 logOutputFile.open (lLogFilename.c_str());
69 logOutputFile.clear();
70
71 // Initialise the SimFQT service object
72 const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG,
73 logOutputFile);
74
75 // Initialise the Simfqt service object
76 SIMFQT::SIMFQT_Service simfqtService (lLogParams);
77
78 // Check wether or not a (CSV) input file should be read
79 if (isBuiltin == true) {
80
81 // Build the default sample BOM tree (filled with fares) for Simfqt
82 simfqtService.buildSampleBom();
83
84 } else {
85
86 // Build the BOM tree from parsing the fare input file
87 SIMFQT::FareFilePath lFareFilePath (iFareInputFilename);
88 simfqtService.parseAndLoad (lFareFilePath);
89 }
90
91 // Build a sample list of travel solutions and a booking request.
92 stdair::TravelSolutionList_T lTravelSolutionList;
93 simfqtService.buildSampleTravelSolutions (lTravelSolutionList);
94 stdair::BookingRequestStruct lBookingRequest =
95 simfqtService.buildBookingRequest();
96
97 // Try to fareQuote the sample list of travel solutions
98 simfqtService.quotePrices (lBookingRequest, lTravelSolutionList);
99
100 // Close the log file
101 logOutputFile.close();
102
103}
104
105// /////////////// Main: Unit Test Suite //////////////
106
107// Set the UTF configuration (re-direct the output to a specific file)
108BOOST_GLOBAL_FIXTURE (UnitTestConfig);
109
110// Start the test suite
111BOOST_AUTO_TEST_SUITE (master_test_suite)
112
113
116BOOST_AUTO_TEST_CASE (simfqt_simple_pricing_test) {
117
118 // Input file name
119 const stdair::Filename_T lFareInputFilename (STDAIR_SAMPLE_DIR "/fare01.csv");
120
121 // State whether the BOM tree should be built-in or parsed from an input file
122 const bool isBuiltin = false;
123
124 // Try to fareQuote the sample default list of travel solutions
125 BOOST_CHECK_NO_THROW (testFareQuoterHelper (0, lFareInputFilename, isBuiltin));
126
127}
128
133BOOST_AUTO_TEST_CASE (simfqt_error_pricing_test_01) {
134
135 // Input file name
136 const stdair::Filename_T lFareInputFilename (STDAIR_SAMPLE_DIR "/fareError01.csv");
137
138 // State whether the BOM tree should be built-in or parsed from an input file
139 const bool isBuiltin = false;
140
141 // Try to fareQuote the sample default list of travel solutions
142 BOOST_CHECK_THROW (testFareQuoterHelper (1, lFareInputFilename, isBuiltin),
144}
145
150BOOST_AUTO_TEST_CASE (simfqt_error_pricing_test_02) {
151
152 // Input file name
153 const stdair::Filename_T lFareInputFilename (STDAIR_SAMPLE_DIR "/fareError02.csv");
154
155 // State whether the BOM tree should be built-in or parsed from an input file
156 const bool isBuiltin = false;
157
158 // Try to fareQuote the sample default list of travel solutions
159 BOOST_CHECK_THROW (testFareQuoterHelper (2, lFareInputFilename, isBuiltin),
161}
162
167BOOST_AUTO_TEST_CASE (simfqt_error_pricing_test_03) {
168
169 // Input file name
170 const stdair::Filename_T lFareInputFilename (STDAIR_SAMPLE_DIR "/fareError03.csv");
171
172 // State whether the BOM tree should be built-in or parsed from an input file
173 const bool isBuiltin = false;
174
175 // Try to fareQuote the sample default list of travel solutions
176 BOOST_CHECK_THROW (testFareQuoterHelper (3, lFareInputFilename, isBuiltin),
178}
179
184BOOST_AUTO_TEST_CASE (simfqt_error_pricing_test_04) {
185
186 // Input file name
187 const stdair::Filename_T lFareInputFilename (STDAIR_SAMPLE_DIR "/fareError04.csv");
188
189 // State whether the BOM tree should be built-in or parsed from an input file
190 const bool isBuiltin = false;
191
192 // Try to fareQuote the sample default list of travel solutions
193 BOOST_CHECK_THROW (testFareQuoterHelper (4, lFareInputFilename, isBuiltin),
195}
196
201BOOST_AUTO_TEST_CASE (simfqt_error_pricing_test_05) {
202
203 // Input file name
204 const stdair::Filename_T lFareInputFilename (STDAIR_SAMPLE_DIR "/fareError05.csv");
205
206 // State whether the BOM tree should be built-in or parsed from an input file
207 const bool isBuiltin = false;
208
209 // Try to fareQuote the sample default list of travel solutions
210 BOOST_CHECK_THROW (testFareQuoterHelper (5, lFareInputFilename, isBuiltin),
212}
213
218BOOST_AUTO_TEST_CASE (simfqt_error_pricing_test_06) {
219
220 // Input file name
221 const stdair::Filename_T lFareInputFilename (STDAIR_SAMPLE_DIR "/fareError06.csv");
222
223 // State whether the BOM tree should be built-in or parsed from an input file
224 const bool isBuiltin = false;
225
226 // Try to fareQuote the sample default list of travel solutions
227 BOOST_CHECK_THROW (testFareQuoterHelper (6, lFareInputFilename, isBuiltin),
229}
230
235BOOST_AUTO_TEST_CASE (simfqt_error_pricing_test_07) {
236
237 // Input file name
238 const stdair::Filename_T lFareInputFilename (STDAIR_SAMPLE_DIR "/fareError07.csv");
239
240 // State whether the BOM tree should be built-in or parsed from an input file
241 const bool isBuiltin = false;
242
243 // Try to fareQuote the sample default list of travel solutions
244 BOOST_CHECK_THROW (testFareQuoterHelper (7, lFareInputFilename, isBuiltin),
246}
247
252BOOST_AUTO_TEST_CASE (simfqt_error_pricing_test_08) {
253
254 // Input file name
255 const stdair::Filename_T lFareInputFilename (STDAIR_SAMPLE_DIR "/missingFile.csv");
256
257 // State whether the BOM tree should be built-in or parsed from an input file
258 const bool isBuiltin = false;
259
260 // Try to fareQuote the sample default list of travel solutions
261 BOOST_CHECK_THROW (testFareQuoterHelper (8, lFareInputFilename, isBuiltin),
263}
264
269BOOST_AUTO_TEST_CASE (simfqt_error_pricing_test_09) {
270
271 // Input file name
272 const stdair::Filename_T lEmptyInputFilename (STDAIR_SAMPLE_DIR "/ ");
273
274 // State whether the BOM tree should be built-in or parsed from an input file
275 const bool isBuiltin = true;
276
277 // Try to fareQuote the sample default list of travel solutions
278 BOOST_CHECK_NO_THROW(testFareQuoterHelper (9, lEmptyInputFilename, isBuiltin));
279}
280
281
282// End the test suite
283BOOST_AUTO_TEST_SUITE_END()
284
285
Interface for the SIMFQT Services.