0.08.01
C++ Open Travel Request Parsing Library
Toggle main menu visibility
Loading...
Searching...
No Matches
PartitionTestSuite.cpp
Go to the documentation of this file.
1
// /////////////////////////////////////////////////////////////////////////
2
//
3
// String partition algorithm
4
//
5
// Author: Denis Arnaud
6
// Date: April 2012
7
//
8
// /////////////////////////////////////////////////////////////////////////
9
// STL
10
#include <sstream>
11
#include <fstream>
12
#include <string>
13
#include <list>
14
// Boost Unit Test Framework (UTF)
15
#define BOOST_TEST_DYN_LINK
16
#define BOOST_TEST_MAIN
17
#define BOOST_TEST_MODULE PartitionTestSuite
18
#include <boost/test/unit_test.hpp>
19
// OpenTrep
20
#include <
opentrep/bom/StringPartition.hpp
>
21
22
namespace
boost_utf = boost::unit_test;
23
24
// (Boost) Unit Test XML Report
25
std::ofstream
utfReportStream
(
"PartitionTestSuite_utfresults.xml"
);
26
30
struct
UnitTestConfig
{
32
UnitTestConfig
() {
33
boost_utf::unit_test_log.set_stream (
utfReportStream
);
34
#if defined(BOOST_VERSION) && BOOST_VERSION >= 105900
35
boost_utf::unit_test_log.set_format (boost_utf::OF_XML);
36
#else
// BOOST_VERSION
37
boost_utf::unit_test_log.set_format (boost_utf::XML);
38
#endif
// BOOST_VERSION
39
boost_utf::unit_test_log.set_threshold_level (boost_utf::log_test_units);
40
//boost_utf::unit_test_log.set_threshold_level (boost_utf::log_successful_tests);
41
}
42
44
~UnitTestConfig
() {
45
}
46
};
47
48
49
// /////////////// Main: Unit Test Suite //////////////
50
51
// Set the UTF configuration (re-direct the output to a specific file)
52
BOOST_GLOBAL_FIXTURE
(
UnitTestConfig
);
53
54
// Start the test suite
55
BOOST_AUTO_TEST_SUITE (master_test_suite)
56
57
60
BOOST_AUTO_TEST_CASE
(partition_small_string) {
61
62
// Output log File
63
std::string lLogFilename (
"PartitionTestSuite.log"
);
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
const
std::string lLax1Str =
"los angeles"
;
72
const
std::string lLax2Str =
"lso angeles"
;
73
const
std::string lRio1Str =
"rio de janeiro"
;
74
const
std::string lRio2Str =
"rio de janero"
;
75
const
std::string lRek1Str =
"reikjavik"
;
76
const
std::string lRek2Str =
"rekyavik"
;
77
const
std::string lSfoRio1Str =
"san francisco rio de janeiro"
;
78
const
std::string lSfoRio2Str =
"san francicso rio de janero"
;
79
const
std::string lSfoRio3Str =
"sna francicso rio de janero"
;
80
const
std::string lChelseaStr =
"chelsea municipal airport"
;
81
82
//
83
OPENTREP::StringPartition
lStringPartition (lSfoRio3Str);
84
logOutputFile << lStringPartition << std::endl;
85
86
BOOST_CHECK_MESSAGE (lStringPartition.
size
() == 16,
87
"The partition, for '"
<< lRio2Str
88
<<
"', should contain a single list."
89
<<
" However, its size is "
<< lStringPartition.
size
()
90
<<
"."
);
91
92
//
93
OPENTREP::StringPartition
lAnotherStringPartition (lChelseaStr);
94
logOutputFile << lAnotherStringPartition << std::endl;
95
96
// Close the Log outputFile
97
logOutputFile.close();
98
}
99
100
// End the test suite
101
BOOST_AUTO_TEST_SUITE_END()
102
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)
StringPartition.hpp
utfReportStream
std::ofstream utfReportStream("UnicodeTestSuite_utfresults.xml")
OPENTREP::StringPartition
Definition
StringPartition.hpp:35
OPENTREP::StringPartition::size
size_t size() const
Definition
StringPartition.cpp:35
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