From 86aeaf478d7c4395e45e499cecac12022289ccc8 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Thu, 25 Oct 2007 17:08:27 +0000 Subject: [PATCH] Don't use boost.test for testing. [SVN r40463] --- test/Jamfile.v2 | 2 +- test/cmdline_test.cpp | 7 +++---- test/minitest.hpp | 25 +++++++++++++++++++++++++ test/options_description_test.cpp | 7 +++---- test/parsers_test.cpp | 7 +++---- test/positional_options_test.cpp | 5 +++-- test/test_convert.cpp | 4 ++-- test/unicode_test.cpp | 7 +++---- test/variable_map_test.cpp | 16 ++-------------- test/winmain.cpp | 4 ++-- 10 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 test/minitest.hpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index d84b994..342d29e 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -2,8 +2,8 @@ project : requirements ../build//boost_program_options - /boost/test//boost_test_exec_monitor/static static + debug # _GLIBCXX_CONCEPT_CHECKS # _GLIBCXX_DEBUG diff --git a/test/cmdline_test.cpp b/test/cmdline_test.cpp index b55a3d4..32385a2 100644 --- a/test/cmdline_test.cpp +++ b/test/cmdline_test.cpp @@ -9,15 +9,14 @@ using namespace boost::program_options; using boost::program_options::detail::cmdline; - -#include - #include #include #include #include using namespace std; +#include "minitest.hpp" + /* To facilitate testing, declare a number of error codes. Otherwise, we'd have to specify the type of exception that should be thrown. */ @@ -600,7 +599,7 @@ void test_unregistered() // It's not clear yet, so I'm leaving the decision till later. } -int test_main(int ac, char* av[]) +int main(int ac, char* av[]) { test_long_options(); test_short_options(); diff --git a/test/minitest.hpp b/test/minitest.hpp new file mode 100644 index 0000000..7d38efd --- /dev/null +++ b/test/minitest.hpp @@ -0,0 +1,25 @@ +#ifndef BOOST_PROGRAM_OPTIONS_MINITEST +#define BOOST_PROGRAM_OPTIONS_MINITEST + +#include +#include +#include + +#define BOOST_REQUIRE(b) assert(b) +#define BOOST_CHECK(b) assert(b) +#define BOOST_CHECK_EQUAL(a, b) assert(a == b) +#define BOOST_ERROR(description) std::cerr << description; std::cerr << "\n"; abort(); +#define BOOST_CHECK_THROW(expression, exception) \ + try \ + { \ + expression; \ + BOOST_ERROR("expected exception not thrown");\ + throw 10; \ + } \ + catch(exception &) \ + { \ + } + + + +#endif diff --git a/test/options_description_test.cpp b/test/options_description_test.cpp index 885e539..691182f 100644 --- a/test/options_description_test.cpp +++ b/test/options_description_test.cpp @@ -10,14 +10,13 @@ using namespace boost::program_options; #include using namespace boost; -#define BOOST_INCLUDE_MAIN // for testing, include rather than link -#include - #include #include #include using namespace std; +#include "minitest.hpp" + void test_type() { options_description desc; @@ -77,7 +76,7 @@ void test_formatting() ss << desc; } -int test_main(int, char* []) +int main(int, char* []) { test_type(); test_approximation(); diff --git a/test/parsers_test.cpp b/test/parsers_test.cpp index c585704..04880d5 100644 --- a/test/parsers_test.cpp +++ b/test/parsers_test.cpp @@ -14,9 +14,6 @@ namespace po = boost::program_options; #include using namespace boost; -#define BOOST_INCLUDE_MAIN // for testing, include rather than link -#include - #include #include using namespace std; @@ -27,6 +24,8 @@ using namespace std; #include // for putenv #endif +#include "minitest.hpp" + #define TEST_CHECK_THROW(expression, exception, description) \ try \ { \ @@ -259,7 +258,7 @@ void test_unregistered() check_value(a3[1], "m1.v1", "1"); } -int test_main(int, char* []) +int main(int, char* []) { test_command_line(); test_config_file(); diff --git a/test/positional_options_test.cpp b/test/positional_options_test.cpp index 230fb1e..2c1dfd6 100644 --- a/test/positional_options_test.cpp +++ b/test/positional_options_test.cpp @@ -12,7 +12,8 @@ namespace po = boost::program_options; #include -#include + +#include "minitest.hpp" #include using namespace std; @@ -81,7 +82,7 @@ void test_parsing() too_many_positional_options_error); } -int test_main(int, char* []) +int main(int, char* []) { test_positional_options(); test_parsing(); diff --git a/test/test_convert.cpp b/test/test_convert.cpp index 94e89e5..924bebf 100644 --- a/test/test_convert.cpp +++ b/test/test_convert.cpp @@ -15,7 +15,7 @@ #include #include -#include +#include "minitest.hpp" using namespace std; @@ -121,7 +121,7 @@ void test_convert(const std::string& input, BOOST_CHECK(ref == input); } -int test_main(int ac, char* av[]) +int main(int ac, char* av[]) { std::string input = file_content("utf8.txt"); std::string expected = file_content("ucs2.txt"); diff --git a/test/unicode_test.cpp b/test/unicode_test.cpp index 1e152e3..bb0cba1 100644 --- a/test/unicode_test.cpp +++ b/test/unicode_test.cpp @@ -15,12 +15,11 @@ namespace po = boost::program_options; #include using namespace boost; -#define BOOST_INCLUDE_MAIN // for testing, include rather than link -#include - #include using namespace std; +#include "minitest.hpp" + // Test that unicode input is forwarded to unicode option without // problems. void test_unicode_to_unicode() @@ -149,7 +148,7 @@ void test_config_file() BOOST_CHECK(vm["foo"].as() == "\xD1\x8F"); } -int test_main(int, char* []) +int main(int, char* []) { test_unicode_to_unicode(); test_unicode_to_native(); diff --git a/test/variable_map_test.cpp b/test/variable_map_test.cpp index 1b85b19..72ab83e 100644 --- a/test/variable_map_test.cpp +++ b/test/variable_map_test.cpp @@ -15,22 +15,10 @@ namespace po = boost::program_options; #include using namespace boost; -#define BOOST_INCLUDE_MAIN // for testing, include rather than link -#include - #include using namespace std; -#define TEST_CHECK_THROW(expression, exception, description) \ - try \ - { \ - expression; \ - BOOST_ERROR(description);\ - throw 10; \ - } \ - catch(exception &) \ - { \ - } +#include "minitest.hpp" vector sv(char* array[], unsigned size) { @@ -288,7 +276,7 @@ void test_multiple_assignments_with_different_option_description() } -int test_main(int, char* []) +int main(int, char* []) { test_variable_map(); test_semantic_values(); diff --git a/test/winmain.cpp b/test/winmain.cpp index 2bb91f6..2f0caab 100644 --- a/test/winmain.cpp +++ b/test/winmain.cpp @@ -45,13 +45,13 @@ void test_winmain() TEST("1\\\\1 ", {"1\\\\1"}); } -int test_main(int, char*[]) +int main(int, char*[]) { test_winmain(); return 0; } #else -int test_main(int, char*[]) +int main(int, char*[]) { return 0; }