OpenTREP Logo  0.07.18
C++ Open Travel Request Parsing Library
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
21
22namespace boost_utf = boost::unit_test;
23
24// (Boost) Unit Test XML Report
25std::ofstream utfReportStream ("PartitionTestSuite_utfresults.xml");
26
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
46};
47
48
49// /////////////// Main: Unit Test Suite //////////////
50
51// Set the UTF configuration (re-direct the output to a specific file)
53
54// Start the test suite
55BOOST_AUTO_TEST_SUITE (master_test_suite)
56
57
60BOOST_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
101BOOST_AUTO_TEST_SUITE_END()
102
std::ofstream utfReportStream("PartitionTestSuite_utfresults.xml")
BOOST_AUTO_TEST_CASE(partition_small_string)
BOOST_GLOBAL_FIXTURE(UnitTestConfig)
std::ofstream utfReportStream("UnicodeTestSuite_utfresults.xml")