OpenTREP Logo  0.07.18
C++ Open Travel Request Parsing Library
Loading...
Searching...
No Matches
Command-Line Test to Demonstrate How To Test the OpenTREP Project
boost_utf::unit_test_log.set_stream (utfReportStream);
#if defined(BOOST_VERSION) && BOOST_VERSION >= 105900
boost_utf::unit_test_log.set_format (boost_utf::OF_XML);
#else // BOOST_VERSION
boost_utf::unit_test_log.set_format (boost_utf::XML);
#endif // BOOST_VERSION
boost_utf::unit_test_log.set_threshold_level (boost_utf::log_test_units);
//boost_utf::unit_test_log.set_threshold_level (boost_utf::log_successful_tests);
}
}
};
// //////////// Constants for the tests ///////////////
const std::string X_XAPIAN_DB_FP ("/tmp/opentrep/test_traveldb");
const std::string X_SQL_DB_STR ("");
/*
* Deployment number/version.
*/
// /////////////// Main: Unit Test Suite //////////////
// Set the UTF configuration (re-direct the output to a specific file)
// Start the test suite
BOOST_AUTO_TEST_SUITE (master_test_suite)
BOOST_AUTO_TEST_CASE (opentrep_simple_search) {
// Output log File
std::string lLogFilename ("SearchingTestSuite.log");
// Travel query
std::string lTravelQuery ("nce");
// Set the log parameters
std::ofstream logOutputFile;
// Open and clean the log outputfile
logOutputFile.open (lLogFilename.c_str());
logOutputFile.clear();
// Initialise the context
const OPENTREP::TravelDBFilePath_T lTravelDBFilePath (X_XAPIAN_DB_FP);
OPENTREP::OPENTREP_Service opentrepService (logOutputFile, lTravelDBFilePath,
lDBType, lSQLDBConnStr,
lDeploymentNumber);
// Query the Xapian database (index)
OPENTREP::WordList_T lNonMatchedWordList;
OPENTREP::LocationList_T lLocationList;
const OPENTREP::NbOfMatches_T nbOfMatches =
opentrepService.interpretTravelRequest (lTravelQuery, lLocationList,
lNonMatchedWordList);
BOOST_CHECK_MESSAGE (nbOfMatches == 1,
"The travel query ('" << lTravelQuery
<< "') matches with " << nbOfMatches
<< " key-words, whereas 1 is expected.");
// Close the Log outputFile
logOutputFile.close();
}
// End the test suite
BOOST_AUTO_TEST_SUITE_END()