OpenTREP Logo  0.6.0
C++ Open Travel Request Parsing Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
22 namespace boost_utf = boost::unit_test;
23 
24 // (Boost) Unit Test XML Report
25 std::ofstream utfReportStream ("PartitionTestSuite_utfresults.xml");
26 
33  boost_utf::unit_test_log.set_stream (utfReportStream);
34  boost_utf::unit_test_log.set_format (boost_utf::XML);
35  boost_utf::unit_test_log.set_threshold_level (boost_utf::log_test_units);
36  //boost_utf::unit_test_log.set_threshold_level (boost_utf::log_successful_tests);
37  }
38 
41  }
42 };
43 
44 
45 // /////////////// Main: Unit Test Suite //////////////
46 
47 // Set the UTF configuration (re-direct the output to a specific file)
49 
50 // Start the test suite
51 BOOST_AUTO_TEST_SUITE (master_test_suite)
52 
53 
56 BOOST_AUTO_TEST_CASE (partition_small_string) {
57 
58  // Output log File
59  std::string lLogFilename ("PartitionTestSuite.log");
60 
61  // Set the log parameters
62  std::ofstream logOutputFile;
63  // Open and clean the log outputfile
64  logOutputFile.open (lLogFilename.c_str());
65  logOutputFile.clear();
66 
67  const std::string lLax1Str = "los angeles";
68  const std::string lLax2Str = "lso angeles";
69  const std::string lRio1Str = "rio de janeiro";
70  const std::string lRio2Str = "rio de janero";
71  const std::string lRek1Str = "reikjavik";
72  const std::string lRek2Str = "rekyavik";
73  const std::string lSfoRio1Str = "san francisco rio de janeiro";
74  const std::string lSfoRio2Str = "san francicso rio de janero";
75  const std::string lSfoRio3Str = "sna francicso rio de janero";
76  const std::string lChelseaStr = "chelsea municipal airport";
77 
78  //
79  OPENTREP::StringPartition lStringPartition (lSfoRio3Str);
80  logOutputFile << lStringPartition << std::endl;
81 
82  BOOST_CHECK_MESSAGE (lStringPartition.size() == 16,
83  "The partition, for '" << lRio2Str
84  << "', should contain a single list."
85  << " However, its size is " << lStringPartition.size()
86  << ".");
87 
88  //
89  OPENTREP::StringPartition lAnotherStringPartition (lChelseaStr);
90  logOutputFile << lAnotherStringPartition << std::endl;
91 
92  // Close the Log outputFile
93  logOutputFile.close();
94 }
95 
96 // End the test suite
97 BOOST_AUTO_TEST_SUITE_END()
98 
BOOST_GLOBAL_FIXTURE(UnitTestConfig)
BOOST_AUTO_TEST_CASE(partition_small_string)
std::ofstream utfReportStream("PartitionTestSuite_utfresults.xml")