0.08.01
C++ Open Travel Request Parsing Library
Toggle main menu visibility
Loading...
Searching...
No Matches
SearchingTestSuite.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 SearchingTestSuite
16
#include <boost/test/unit_test.hpp>
17
// OpenTrep
18
#include <
opentrep/OPENTREP_Service.hpp
>
19
#include <
opentrep/basic/BasConst_OPENTREP_Service.hpp
>
20
#include <
opentrep/Location.hpp
>
21
#include <
opentrep/CityDetails.hpp
>
22
23
namespace
boost_utf = boost::unit_test;
24
25
// (Boost) Unit Test XML Report
26
std::ofstream
utfReportStream
(
"SearchingTestSuite_utfresults.xml"
);
27
31
struct
UnitTestConfig
{
33
UnitTestConfig
() {
34
boost_utf::unit_test_log.set_stream (
utfReportStream
);
35
#if defined(BOOST_VERSION) && BOOST_VERSION >= 105900
36
boost_utf::unit_test_log.set_format (boost_utf::OF_XML);
37
#else
// BOOST_VERSION
38
boost_utf::unit_test_log.set_format (boost_utf::XML);
39
#endif
// BOOST_VERSION
40
boost_utf::unit_test_log.set_threshold_level (boost_utf::log_test_units);
41
//boost_utf::unit_test_log.set_threshold_level (boost_utf::log_successful_tests);
42
}
43
45
~UnitTestConfig
() {
46
}
47
};
48
49
50
// //////////// Constants for the tests ///////////////
54
const
std::string
X_XAPIAN_DB_FP
(
"/tmp/opentrep/test_traveldb"
);
55
59
const
std::string
X_SQL_DB_STR
(
""
);
60
61
/*
62
* Deployment number/version.
63
*/
64
const
OPENTREP::DeploymentNumber_T
X_DEPLOYMENT_NUMBER
(0);
65
66
// /////////////// Main: Unit Test Suite //////////////
67
68
// Set the UTF configuration (re-direct the output to a specific file)
69
BOOST_GLOBAL_FIXTURE
(
UnitTestConfig
);
70
71
// Start the test suite
72
BOOST_AUTO_TEST_SUITE (master_test_suite)
73
74
77
BOOST_AUTO_TEST_CASE
(opentrep_simple_search) {
78
79
// Output log File
80
std::string lLogFilename (
"SearchingTestSuite.log"
);
81
82
// Travel query
83
std::string lTravelQuery (
"nce"
);
84
85
// Set the log parameters
86
std::ofstream logOutputFile;
87
// Open and clean the log outputfile
88
logOutputFile.open (lLogFilename.c_str());
89
logOutputFile.clear();
90
91
// Initialise the context
92
const
OPENTREP::TravelDBFilePath_T
lTravelDBFilePath (
X_XAPIAN_DB_FP
);
93
const
OPENTREP::DBType
lDBType (
OPENTREP::DBType::NODB
);
94
const
OPENTREP::SQLDBConnectionString_T
lSQLDBConnStr (
X_SQL_DB_STR
);
95
const
OPENTREP::DeploymentNumber_T
lDeploymentNumber (
X_DEPLOYMENT_NUMBER
);
96
OPENTREP::OPENTREP_Service
opentrepService (logOutputFile, lTravelDBFilePath,
97
lDBType, lSQLDBConnStr,
98
lDeploymentNumber);
99
100
// Query the Xapian database (index)
101
OPENTREP::WordList_T
lNonMatchedWordList;
102
OPENTREP::LocationList_T
lLocationList;
103
const
OPENTREP::NbOfMatches_T
nbOfMatches =
104
opentrepService.interpretTravelRequest (lTravelQuery, lLocationList,
105
lNonMatchedWordList);
106
BOOST_CHECK_MESSAGE (nbOfMatches == 1,
107
"The travel query ('"
<< lTravelQuery
108
<<
"') matches with "
<< nbOfMatches
109
<<
" key-words, whereas 1 is expected."
);
110
111
// Close the Log outputFile
112
logOutputFile.close();
113
}
114
115
// End the test suite
116
BOOST_AUTO_TEST_SUITE_END()
117
118
121
BasConst_OPENTREP_Service.hpp
CityDetails.hpp
Location.hpp
OPENTREP_Service.hpp
utfReportStream
std::ofstream utfReportStream("PartitionTestSuite_utfresults.xml")
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(partition_small_string)
Definition
PartitionTestSuite.cpp:60
BOOST_GLOBAL_FIXTURE
BOOST_GLOBAL_FIXTURE(UnitTestConfig)
X_XAPIAN_DB_FP
const std::string X_XAPIAN_DB_FP("/tmp/opentrep/test_traveldb")
X_SQL_DB_STR
const std::string X_SQL_DB_STR("")
X_DEPLOYMENT_NUMBER
const OPENTREP::DeploymentNumber_T X_DEPLOYMENT_NUMBER(0)
utfReportStream
std::ofstream utfReportStream("UnicodeTestSuite_utfresults.xml")
OPENTREP::OPENTREP_Service
Interface for the OPENTREP Services.
Definition
OPENTREP_Service.hpp:25
OPENTREP::WordList_T
std::list< Word_T > WordList_T
Definition
OPENTREP_Types.hpp:690
OPENTREP::LocationList_T
std::list< Location > LocationList_T
Definition
LocationList.hpp:18
OPENTREP::DeploymentNumber_T
unsigned short DeploymentNumber_T
Definition
OPENTREP_Types.hpp:108
OPENTREP::NbOfMatches_T
unsigned short NbOfMatches_T
Definition
OPENTREP_Types.hpp:715
OPENTREP::DBType
Enumeration of database types.
Definition
DBType.hpp:17
OPENTREP::DBType::NODB
@ NODB
Definition
DBType.hpp:20
OPENTREP::SQLDBConnectionString_T
Definition
OPENTREP_Types.hpp:56
OPENTREP::TravelDBFilePath_T
Definition
OPENTREP_Types.hpp:46
UnitTestConfig
Definition
PartitionTestSuite.cpp:30
UnitTestConfig::UnitTestConfig
UnitTestConfig()
Definition
PartitionTestSuite.cpp:32
UnitTestConfig::~UnitTestConfig
~UnitTestConfig()
Definition
PartitionTestSuite.cpp:44
Generated on
for OpenTREP by
1.17.0