# # old_revision [448d4e9380d75c1aca3e62d0da9af1b6ba496392] # # patch "cert.cc" # from [38e686505d6ec765f8d466d6a7492492baa8e3c6] # to [c47c281ffd102fa6d050a698e7a089b111a638dc] # # patch "charset.cc" # from [f7b71f28c5f99965532a3fcac9580df7026d829c] # to [2d25d1702749a65510ea2e99bd1589b663d65417] # # patch "commands.cc" # from [79edb01e23e7bac3b6b0c8096687f6309e2d4ed9] # to [ab478de670f9b6190b9504075611882a5eba818d] # # patch "crypto_tests.cc" # from [9f994ac1bc3d367795a652002ee211fdb4a534e7] # to [2bcde5c12098bff0bb6a4ea7d906b4cd8d992140] # # patch "cset.cc" # from [9b43d9b448fc77d3fa7e4f8879a91cf084015475] # to [32d57144f8b23e78f35e35eef33f5ed0a4421fc1] # # patch "diff_patch.cc" # from [f8cbddf42a4f75a34eeaf53d9674562ef4185725] # to [b2465d5eb189e4d35d1d00fa2e1723b5006a79e4] # # patch "file_io.cc" # from [306248e3ca5444768760e9aea90a2aa5b22a2433] # to [c1a8f81e48421f44efef7c5cc3734f8d67509281] # # patch "globish.cc" # from [0899bd0e73c97181ff6cb8662fd6f658ff4c2d75] # to [85d971be4e285160674cbb8cd1ae6e948f433037] # # patch "keys.cc" # from [5b7c03118a6613b47cc5bd42cd8165f2db0ae91f] # to [f260aa814959a4fa391376475d7f57369278239b] # # patch "netcmd.cc" # from [74ff323247791770c8971cc50329b9c4a411a798] # to [caa78529e86c96bd1e158cf96fe7c0e119d2c7d6] # # patch "netxx_pipe.cc" # from [ed88de9d75bb1e6f234144a83e61468a92fdf67a] # to [66d4dcf236cc6c230626cec1ea10aa97b838543c] # # patch "packet.cc" # from [6521a2c8e8191d1916f24bae9e6d081d20ffaf5b] # to [a59b48af0d11f15f912c85e5cc53a04f7f17b5f9] # # patch "paths.cc" # from [1c4867e1b3d6651be58e0ab751b0dfefe0e76124] # to [962050b64d027599ecb898cb8b79ae1f6e8fe664] # # patch "refiner.cc" # from [dcb840fc67b92a9bbba3982c715ef11132f666a3] # to [90a43b983f364f6f7f48c6bdbf3a0f935ce59b1c] # # patch "restrictions.cc" # from [dcdb8ea7caf06c3333009bb9ca3b633570a60125] # to [f73292f94c92e918fc06f0614c109ebaf8db3733] # # patch "revision.cc" # from [46b019045a4ab1dc2be49fe4b9d33ed81f95fbb4] # to [d04356a1d75c7a392716438960b06256f913ac6d] # # patch "roster.cc" # from [d03806d489e8b30fc4564b9a4f025669770403d6] # to [7cdc40431db51c8d5e9ee965086d8b43001b1b29] # # patch "roster_merge.cc" # from [5cb34f31e03352190e8d8d4a39f18094bb3fe6c0] # to [4b10972124b78dc6e03125e620f455b379110110] # # patch "simplestring_xform.cc" # from [124885841fcd8e23ca00d28a3a646209986082b1] # to [437c50dd55ec155557f1e957c0abdcb8808bd992] # # patch "string_queue.cc" # from [2919771b22c547c35e0f7469655049dd5a7c7ba2] # to [9f9b2784d472e90307d3b249f1fc487911268373] # # patch "transforms.cc" # from [697265ad733bdbe6eab0149f803fd89219e85ea9] # to [a48c78d2e6afcc1222059a5707844380921913a1] # # patch "unit_tests.cc" # from [0681ea82bcb92ab13dba3cff4e8de17e2363e58a] # to [2ab21aca2410df583686a132b477f24d51174c62] # # patch "unit_tests.hh" # from [f725a5a24793b324839108e7dd18bebaf9cb9955] # to [7f27c21c1b8ca7a2652c4460b79e4143c54485ea] # # patch "uri.cc" # from [b269205c09ed72b520bc738aadf8ae79924f810b] # to [c64651637ad0540d6adfaaf4a17f48264700c260] # # patch "vocab.cc" # from [f63b97e15c4c31a108832bc5eac2cf04f8fe89f8] # to [45d358088bd8b5d169aa68af49a9adb8898cbc03] # # patch "xdelta.cc" # from [61c35b2d36b0c1d87a1f3e481c9cdc315c77a746] # to [40958b7219a9dccafe0b4a4dabe4ee7af77ac9ab] # ============================================================ --- cert.cc 38e686505d6ec765f8d466d6a7492492baa8e3c6 +++ cert.cc c47c281ffd102fa6d050a698e7a089b111a638dc @@ -680,12 +680,6 @@ cert_revision_testresult(revision_id con put_simple_revision_cert(r, testresult_cert_name, lexical_cast(passed), app, pc); } - -#ifdef BUILD_UNIT_TESTS -#include "unit_tests.hh" - -#endif // BUILD_UNIT_TESTS - // Local Variables: // mode: C++ // fill-column: 76 ============================================================ --- charset.cc f7b71f28c5f99965532a3fcac9580df7026d829c +++ charset.cc 2d25d1702749a65510ea2e99bd1589b663d65417 @@ -598,8 +598,7 @@ idna IDNA_SUCCESS, IDNA_SUCCESS}, }; -static void -check_idna_encoding() +UNIT_TEST(charset, idna_encoding) { putenv("CHARSET=UTF-8"); @@ -625,13 +624,8 @@ check_idna_encoding() } } -static void encode_test() +UNIT_TEST(charset, utf8_validation) { - check_idna_encoding(); -} - -static void utf8_validation_test() -{ // these tests are based on the tests from the file utf8-validate.c of the // GLib library, and also include sequences from Markus Kuhn's UTF-8 // example files. @@ -853,15 +847,6 @@ static void utf8_validation_test() BOOST_CHECK(utf8_validate(string(bad_strings[i])) == false); } - -void -add_charset_tests(test_suite * suite) -{ - I(suite); - suite->add(BOOST_TEST_CASE(&encode_test)); - suite->add(BOOST_TEST_CASE(&utf8_validation_test)); -} - #endif // BUILD_UNIT_TESTS // Local Variables: ============================================================ --- commands.cc 79edb01e23e7bac3b6b0c8096687f6309e2d4ed9 +++ commands.cc ab478de670f9b6190b9504075611882a5eba818d @@ -66,10 +66,8 @@ namespace commands : name(n), cmdgroup(g), params_(p), desc_(d), use_workspace_options(u), options(o) { - static bool first(true); - if (first) + if (cmds == NULL) cmds = new map; - first = false; (*cmds)[n] = this; } command::~command() {} ============================================================ --- crypto_tests.cc 9f994ac1bc3d367795a652002ee211fdb4a534e7 +++ crypto_tests.cc 2bcde5c12098bff0bb6a4ea7d906b4cd8d992140 @@ -1019,8 +1019,7 @@ static string expected_SHA_MCT[] = { "25f67e9875a90aee60bf1dc1b26c2750294aa7b7", "8fa552efdcb67d98b5e0189144e99607f5a807fe" }; -static void -calculate_ident_test() +UNIT_TEST(crypto, calculate_ident) { // NIST checks all SHA implementations using a test system // outlined in the SHA Verification System PDF obtained at @@ -1124,15 +1123,6 @@ calculate_ident_test() L(FL("SHA Monte Carlo Test: Passed\n\n")); } - -void -add_crypto_tests(test_suite * suite) -{ - I(suite); - suite->add(BOOST_TEST_CASE(&calculate_ident_test)); -} - - #endif // BUILD_UNIT_TESTS // Local Variables: ============================================================ --- cset.cc 9b43d9b448fc77d3fa7e4f8879a91cf084015475 +++ cset.cc 32d57144f8b23e78f35e35eef33f5ed0a4421fc1 @@ -503,8 +503,7 @@ setup_roster(roster_t & r, file_id const } } -static void -cset_written_test() +UNIT_TEST(cset, cset_written) { { L(FL("TEST: cset reading - operation misordering")); @@ -755,8 +754,7 @@ cset_written_test() } } -static void -basic_csets_test() +UNIT_TEST(cset, basic_csets) { temp_node_id_source nis; @@ -937,8 +935,7 @@ basic_csets_test() } } -static void -invalid_csets_test() +UNIT_TEST(cset, invalid_csets) { temp_node_id_source nis; roster_t r; @@ -1112,8 +1109,7 @@ invalid_csets_test() } } -void -root_dir_test() +UNIT_TEST(cset, root_dir) { temp_node_id_source nis; roster_t r; @@ -1158,16 +1154,6 @@ root_dir_test() } } -void -add_cset_tests(test_suite * suite) -{ - I(suite); - suite->add(BOOST_TEST_CASE(&basic_csets_test)); - suite->add(BOOST_TEST_CASE(&invalid_csets_test)); - suite->add(BOOST_TEST_CASE(&cset_written_test)); - suite->add(BOOST_TEST_CASE(&root_dir_test)); -} - #endif // BUILD_UNIT_TESTS ============================================================ --- diff_patch.cc f8cbddf42a4f75a34eeaf53d9674562ef4185725 +++ diff_patch.cc b2465d5eb189e4d35d1d00fa2e1723b5006a79e4 @@ -1372,8 +1372,7 @@ static void dump_incorrect_merge(vector< } // high tech randomizing test - -static void randomizing_merge_test() +UNIT_TEST(diff_patch, randomizing_merge) { for (int i = 0; i < 30; ++i) { @@ -1395,8 +1394,7 @@ static void randomizing_merge_test() // old boring tests - -static void merge_prepend_test() +UNIT_TEST(diff_patch, merge_prepend) { BOOST_CHECKPOINT("prepend test"); vector anc, d1, d2, m1, m2, gm; @@ -1426,8 +1424,7 @@ static void merge_prepend_test() BOOST_CHECK(gm == m2); } - -static void merge_append_test() +UNIT_TEST(diff_patch, merge_append) { BOOST_CHECKPOINT("append test"); vector anc, d1, d2, m1, m2, gm; @@ -1457,7 +1454,7 @@ static void merge_append_test() } -static void merge_additions_test() +UNIT_TEST(diff_patch, merge_additions) { BOOST_CHECKPOINT("additions test"); string ancestor("I like oatmeal\nI like orange juice\nI like toast"); @@ -1486,7 +1483,7 @@ static void merge_additions_test() BOOST_CHECK(!merge3(anc, d1, cf, m1)); } -static void merge_deletions_test() +UNIT_TEST(diff_patch, merge_deletions) { string ancestor("I like oatmeal\nI like orange juice\nI like toast"); string desc2("I like oatmeal\nI like toast"); @@ -1509,18 +1506,6 @@ static void merge_deletions_test() BOOST_CHECK(gm == m2); } - -void add_diff_patch_tests(test_suite * suite) -{ - I(suite); - suite->add(BOOST_TEST_CASE(&merge_prepend_test)); - suite->add(BOOST_TEST_CASE(&merge_append_test)); - suite->add(BOOST_TEST_CASE(&merge_additions_test)); - suite->add(BOOST_TEST_CASE(&merge_deletions_test)); - suite->add(BOOST_TEST_CASE(&randomizing_merge_test)); -} - - #endif // BUILD_UNIT_TESTS // Local Variables: ============================================================ --- file_io.cc 306248e3ca5444768760e9aea90a2aa5b22a2433 +++ file_io.cc c1a8f81e48421f44efef7c5cc3734f8d67509281 @@ -542,18 +542,6 @@ walk_tree(file_path const & path, } } -#ifdef BUILD_UNIT_TESTS -#include "unit_tests.hh" - -void -add_file_io_tests(test_suite * suite) -{ - I(suite); - // none, ATM. -} - -#endif // BUILD_UNIT_TESTS - // Local Variables: // mode: C++ // fill-column: 76 ============================================================ --- globish.cc 0899bd0e73c97181ff6cb8662fd6f658ff4c2d75 +++ globish.cc 85d971be4e285160674cbb8cd1ae6e948f433037 @@ -157,8 +157,7 @@ globish_matcher::operator()(string const #ifdef BUILD_UNIT_TESTS #include "unit_tests.hh" -static void -checked_globish_to_regex_test() +UNIT_TEST(globish, checked_globish_to_regex) { string pat; @@ -189,8 +188,7 @@ checked_globish_to_regex_test() BOOST_CHECK_THROW(checked_globish_to_regex("{{{{{{{{{{a,b},c},d},e},f},g},h},i},j},k}", pat), informative_failure); } -static void -combine_and_check_globish_test() +UNIT_TEST(globish, combine_and_check_globish) { vector s; s.push_back(utf8("a")); @@ -201,8 +199,7 @@ combine_and_check_globish_test() BOOST_CHECK(combined() == "{a,b,c}"); } -static void -globish_matcher_test() +UNIT_TEST(globish, globish_matcher) { { globish_matcher m(utf8("{a,b}?*\\*|"), utf8("*c*")); @@ -235,15 +232,6 @@ globish_matcher_test() } } - -void add_globish_tests(test_suite * suite) -{ - I(suite); - suite->add(BOOST_TEST_CASE(&checked_globish_to_regex_test)); - suite->add(BOOST_TEST_CASE(&combine_and_check_globish_test)); - suite->add(BOOST_TEST_CASE(&globish_matcher_test)); -} - #endif // BUILD_UNIT_TESTS // Local Variables: ============================================================ --- keys.cc 5b7c03118a6613b47cc5bd42cd8165f2db0ae91f +++ keys.cc f260aa814959a4fa391376475d7f57369278239b @@ -574,8 +574,7 @@ require_password(rsa_keypair_id const & #ifdef BUILD_UNIT_TESTS #include "unit_tests.hh" -static void -arc4_test() +UNIT_TEST(key, arc4) { string pt("new fascist tidiness regime in place"); @@ -601,8 +600,7 @@ arc4_test() } -static void -signature_round_trip_test() +UNIT_TEST(key, signature_round_trip) { app_state app; app.lua.add_std_hooks(); @@ -627,14 +625,6 @@ signature_round_trip_test() BOOST_CHECK(!check_signature(app, key, kp.pub, broken_plaintext, sig)); } -void -add_key_tests(test_suite * suite) -{ - I(suite); - suite->add(BOOST_TEST_CASE(&arc4_test)); - suite->add(BOOST_TEST_CASE(&signature_round_trip_test)); -} - #endif // BUILD_UNIT_TESTS // Local Variables: ============================================================ --- netcmd.cc 74ff323247791770c8971cc50329b9c4a411a798 +++ netcmd.cc caa78529e86c96bd1e158cf96fe7c0e119d2c7d6 @@ -556,8 +556,7 @@ netcmd::write_usher_reply_cmd(utf8 const #include "transforms.hh" #include -void -test_netcmd_mac() +UNIT_TEST(netcmd, mac) { netcmd out_cmd, in_cmd; string buf; @@ -615,8 +614,7 @@ do_netcmd_roundtrip(netcmd const & out_c BOOST_CHECK(in_cmd == out_cmd); } -void -test_netcmd_functions() +UNIT_TEST(netcmd, functions) { try @@ -814,13 +812,6 @@ test_netcmd_functions() } } -void -add_netcmd_tests(test_suite * suite) -{ - suite->add(BOOST_TEST_CASE(&test_netcmd_functions)); - suite->add(BOOST_TEST_CASE(&test_netcmd_mac)); -} - #endif // BUILD_UNIT_TESTS // Local Variables: ============================================================ --- netxx_pipe.cc ed88de9d75bb1e6f234144a83e61468a92fdf67a +++ netxx_pipe.cc 66d4dcf236cc6c230626cec1ea10aa97b838543c @@ -541,8 +541,7 @@ Netxx::PipeCompatibleProbe::add(const St #ifdef BUILD_UNIT_TESTS #include "unit_tests.hh" -static void -simple_pipe_test() +UNIT_TEST(pipe, simple_pipe) { try { Netxx::PipeStream pipe("cat",vector()); @@ -607,13 +606,6 @@ catch (informative_failure &e) throw; } } - -void -add_pipe_tests(test_suite * suite) -{ - I(suite); - suite->add(BOOST_TEST_CASE(&simple_pipe_test)); -} #endif // Local Variables: ============================================================ --- packet.cc 6521a2c8e8191d1916f24bae9e6d081d20ffaf5b +++ packet.cc a59b48af0d11f15f912c85e5cc53a04f7f17b5f9 @@ -505,8 +505,7 @@ using std::ostringstream; using std::istringstream; using std::ostringstream; -static void -packet_roundabout_test() +UNIT_TEST(packet, roundabout) { string tmp; @@ -584,13 +583,6 @@ packet_roundabout_test() } } -void -add_packet_tests(test_suite * suite) -{ - I(suite); - suite->add(BOOST_TEST_CASE(&packet_roundabout_test)); -} - #endif // BUILD_UNIT_TESTS // Local Variables: ============================================================ --- paths.cc 1c4867e1b3d6651be58e0ab751b0dfefe0e76124 +++ paths.cc 962050b64d027599ecb898cb8b79ae1f6e8fe664 @@ -683,12 +683,12 @@ using std::logic_error; using std::logic_error; -static void test_null_name() +UNIT_TEST(paths, null_name) { BOOST_CHECK(null_name(the_null_component)); } -static void test_file_path_internal() +UNIT_TEST(paths, file_path_internal) { char const * baddies[] = {"/foo", "foo//bar", @@ -798,7 +798,7 @@ static void check_fp_normalizes_to(char BOOST_CHECK(!null_name(*i)); } -static void test_file_path_external_null_prefix() +UNIT_TEST(paths, file_path_external_null_prefix) { initial_rel_path.unset(); initial_rel_path.set(fs::path(), true); @@ -865,7 +865,7 @@ static void test_file_path_external_null initial_rel_path.unset(); } -static void test_file_path_external_prefix__MTN() +UNIT_TEST(paths, file_path_external_prefix__MTN) { initial_rel_path.unset(); initial_rel_path.set(fs::path("_MTN"), true); @@ -877,7 +877,7 @@ static void test_file_path_external_pref check_fp_normalizes_to("../foo", "foo"); } -static void test_file_path_external_prefix_a_b() +UNIT_TEST(paths, file_path_external_prefix_a_b) { initial_rel_path.unset(); initial_rel_path.set(fs::path("a/b"), true); @@ -955,7 +955,7 @@ static void test_file_path_external_pref initial_rel_path.unset(); } -static void test_split_join() +UNIT_TEST(paths, split_join) { file_path fp1 = file_path_internal("foo/bar/baz"); file_path fp2 = file_path_internal("bar/baz/foo"); @@ -1051,7 +1051,7 @@ static void check_bk_normalizes_to(char BOOST_CHECK(bookkeeping_path(bp.as_internal()).as_internal() == bp.as_internal()); } -static void test_bookkeeping_path() +UNIT_TEST(paths, bookkeeping) { char const * baddies[] = {"/foo", "foo//bar", @@ -1093,7 +1093,7 @@ static void check_system_normalizes_to(c BOOST_CHECK(system_path(sp.as_internal()).as_internal() == sp.as_internal()); } -static void test_system_path() +UNIT_TEST(paths, system) { initial_abs_path.unset(); initial_abs_path.set(system_path("/a/b"), true); @@ -1179,7 +1179,7 @@ static void test_system_path() initial_rel_path.unset(); } -static void test_access_tracker() +UNIT_TEST(paths, access_tracker) { access_tracker a; BOOST_CHECK_THROW(a.get(), logic_error); @@ -1208,7 +1208,7 @@ static void test_a_path_ordering(string I(left_sp < right_sp); } -static void test_path_ordering() +UNIT_TEST(paths, ordering) { // this ordering is very important: // -- it is used to determine the textual form of csets and manifests @@ -1235,22 +1235,6 @@ static void test_path_ordering() test_a_path_ordering("fallanoooo_not_otherwise_mentioned_and_smaller", "fallanopic_not_otherwise_mentioned"); } - -void add_paths_tests(test_suite * suite) -{ - I(suite); - suite->add(BOOST_TEST_CASE(&test_path_ordering)); - suite->add(BOOST_TEST_CASE(&test_null_name)); - suite->add(BOOST_TEST_CASE(&test_file_path_internal)); - suite->add(BOOST_TEST_CASE(&test_file_path_external_null_prefix)); - suite->add(BOOST_TEST_CASE(&test_file_path_external_prefix__MTN)); - suite->add(BOOST_TEST_CASE(&test_file_path_external_prefix_a_b)); - suite->add(BOOST_TEST_CASE(&test_split_join)); - suite->add(BOOST_TEST_CASE(&test_bookkeeping_path)); - suite->add(BOOST_TEST_CASE(&test_system_path)); - suite->add(BOOST_TEST_CASE(&test_access_tracker)); -} - #endif // BUILD_UNIT_TESTS // Local Variables: ============================================================ --- refiner.cc dcb840fc67b92a9bbba3982c715ef11132f666a3 +++ refiner.cc 90a43b983f364f6f7f48c6bdbf3a0f935ce59b1c @@ -715,8 +715,7 @@ check_with_count(size_t base_set_size) } } -void -check_various_counts() +UNIT_TEST(refiner, various_counts) { { // Once with zero-zero, for good measure. @@ -733,12 +732,6 @@ check_various_counts() check_with_count(1024); } -void -add_refiner_tests(test_suite * suite) -{ - suite->add(BOOST_TEST_CASE(&check_various_counts)); -} - #endif // Local Variables: ============================================================ --- restrictions.cc dcdb8ea7caf06c3333009bb9ca3b633570a60125 +++ restrictions.cc f73292f94c92e918fc06f0614c109ebaf8db3733 @@ -537,8 +537,7 @@ static void setup(roster_t & roster) } -static void -test_empty_restriction() +UNIT_TEST(restrictions, empty_restriction) { roster_t roster; setup(roster); @@ -606,8 +605,7 @@ test_empty_restriction() BOOST_CHECK(pmask.includes(sp_yyg)); } -static void -test_simple_include() +UNIT_TEST(restrictions, simple_include) { roster_t roster; setup(roster); @@ -679,8 +677,7 @@ test_simple_include() BOOST_CHECK( pmask.includes(sp_yyg)); } -static void -test_simple_exclude() +UNIT_TEST(restrictions, simple_exclude) { roster_t roster; setup(roster); @@ -752,8 +749,7 @@ test_simple_exclude() BOOST_CHECK(!pmask.includes(sp_yyg)); } -static void -test_include_exclude() +UNIT_TEST(restrictions, include_exclude) { roster_t roster; setup(roster); @@ -827,8 +823,7 @@ test_include_exclude() BOOST_CHECK(!pmask.includes(sp_yyg)); } -static void -test_exclude_include() +UNIT_TEST(restrictions, exclude_include) { roster_t roster; setup(roster); @@ -905,8 +900,7 @@ test_exclude_include() BOOST_CHECK( pmask.includes(sp_yyg)); } -static void -test_invalid_roster_paths() +UNIT_TEST(restrictions, invalid_roster_paths) { roster_t roster; setup(roster); @@ -920,8 +914,7 @@ test_invalid_roster_paths() informative_failure); } -static void -test_invalid_workspace_paths() +UNIT_TEST(restrictions, invalid_workspace_paths) { roster_t roster; setup(roster); @@ -935,8 +928,7 @@ test_invalid_workspace_paths() informative_failure); } -static void -test_include_depth_0() +UNIT_TEST(restrictions, include_depth_0) { roster_t roster; setup(roster); @@ -1012,8 +1004,7 @@ test_include_depth_0() BOOST_CHECK(!pmask.includes(sp_yyg)); } -static void -test_include_depth_0_empty_restriction() +UNIT_TEST(restrictions, include_depth_0_empty_restriction) { roster_t roster; setup(roster); @@ -1087,8 +1078,7 @@ test_include_depth_0_empty_restriction() BOOST_CHECK(!pmask.includes(sp_yyg)); } -static void -test_include_depth_1() +UNIT_TEST(restrictions, include_depth_1) { roster_t roster; setup(roster); @@ -1164,22 +1154,6 @@ test_include_depth_1() BOOST_CHECK( pmask.includes(sp_yyg)); } -void -add_restrictions_tests(test_suite * suite) -{ - I(suite); - suite->add(BOOST_TEST_CASE(&test_empty_restriction)); - suite->add(BOOST_TEST_CASE(&test_simple_include)); - suite->add(BOOST_TEST_CASE(&test_simple_exclude)); - suite->add(BOOST_TEST_CASE(&test_include_exclude)); - suite->add(BOOST_TEST_CASE(&test_exclude_include)); - suite->add(BOOST_TEST_CASE(&test_invalid_roster_paths)); - suite->add(BOOST_TEST_CASE(&test_invalid_workspace_paths)); - suite->add(BOOST_TEST_CASE(&test_include_depth_0)); - suite->add(BOOST_TEST_CASE(&test_include_depth_0_empty_restriction)); - suite->add(BOOST_TEST_CASE(&test_include_depth_1)); - -} #endif // BUILD_UNIT_TESTS // Local Variables: ============================================================ --- revision.cc 46b019045a4ab1dc2be49fe4b9d33ed81f95fbb4 +++ revision.cc d04356a1d75c7a392716438960b06256f913ac6d @@ -1664,8 +1664,7 @@ void calculate_ident(revision_t const & #include "unit_tests.hh" #include "sanity.hh" -static void -test_find_old_new_path_for() +UNIT_TEST(revision, find_old_new_path_for) { map renames; split_path foo, foo_bar, foo_baz, quux, quux_baz; @@ -1690,14 +1689,6 @@ test_find_old_new_path_for() I(foo_bar == find_new_path_for(renames, foo_baz)); } -void -add_revision_tests(test_suite * suite) -{ - I(suite); - suite->add(BOOST_TEST_CASE(&test_find_old_new_path_for)); -} - - #endif // BUILD_UNIT_TESTS // Local Variables: ============================================================ --- roster.cc d03806d489e8b30fc4564b9a4f025669770403d6 +++ roster.cc 7cdc40431db51c8d5e9ee965086d8b43001b1b29 @@ -3120,8 +3120,7 @@ dump(int const & i, string & out) out = lexical_cast(i) + "\n"; } -static void -automaton_roster_test() +UNIT_TEST(roster, random_actions) { roster_t r; change_automaton aut; @@ -3222,8 +3221,7 @@ check_sane_roster_do_tests(int to_run, i #undef MAYBE -static void -check_sane_roster_test() +UNIT_TEST(roster, check_sane_roster) { int total; check_sane_roster_do_tests(-1, total); @@ -3235,8 +3233,7 @@ check_sane_roster_test() } } -static void -check_sane_roster_loop_test() +UNIT_TEST(roster, check_sane_roster_loop) { testing_node_id_source nis; roster_t r; MM(r); @@ -3251,8 +3248,7 @@ check_sane_roster_loop_test() BOOST_CHECK_THROW(r.check_sane(true), logic_error); } -static void -check_sane_roster_screwy_dir_map() +UNIT_TEST(roster, check_sane_roster_screwy_dir_map) { testing_node_id_source nis; roster_t r; MM(r); @@ -3278,8 +3274,7 @@ check_sane_roster_screwy_dir_map() BOOST_CHECK_THROW(r.check_sane(), logic_error); } -static void -bad_attr_test() +UNIT_TEST(roster, bad_attr) { testing_node_id_source nis; roster_t r; MM(r); @@ -3989,8 +3984,7 @@ run_a_0_scalar_parent_mark_scenario() // These functions contain the actual list of *-merge cases that we would like // to test. -static void -test_all_0_scalar_parent_mark_scenarios() +UNIT_TEST(roster, all_0_scalar_parent_mark_scenarios) { L(FL("TEST: begin checking 0-parent marking")); // a* @@ -3998,8 +3992,7 @@ test_all_0_scalar_parent_mark_scenarios( L(FL("TEST: end checking 0-parent marking")); } -static void -test_all_1_scalar_parent_mark_scenarios() +UNIT_TEST(roster, all_1_scalar_parent_mark_scenarios) { L(FL("TEST: begin checking 1-parent marking")); // a @@ -4039,8 +4032,7 @@ test_all_1_scalar_parent_mark_scenarios( L(FL("TEST: end checking 1-parent marking")); } -static void -test_all_2_scalar_parent_mark_scenarios() +UNIT_TEST(roster, all_2_scalar_parent_mark_scenarios) { L(FL("TEST: begin checking 2-parent marking")); /////////////////////////////////////////////////////////////////// @@ -4214,8 +4206,7 @@ namespace }; } -static void -test_residual_attr_mark_scenario() +UNIT_TEST(roster, residual_attr_mark_scenario) { L(FL("TEST: begin checking residual attr marking case")); { @@ -4257,15 +4248,6 @@ test_residual_attr_mark_scenario() L(FL("TEST: end checking residual attr marking case")); } -static void -test_all_mark_scenarios() -{ - test_all_0_scalar_parent_mark_scenarios(); - test_all_1_scalar_parent_mark_scenarios(); - test_all_2_scalar_parent_mark_scenarios(); - test_residual_attr_mark_scenario(); -} - //////////////////////////////////////////////////////////////////////// // end of exhaustive tests //////////////////////////////////////////////////////////////////////// @@ -4275,8 +4257,7 @@ test_all_mark_scenarios() //////////////////////////////////////////////////////////////////////// // nodes can't survive dying on one side of a merge -static void -test_die_die_die_merge() +UNIT_TEST(roster, die_die_die_merge) { roster_t left_roster; MM(left_roster); marking_map left_markings; MM(left_markings); @@ -4334,8 +4315,7 @@ test_die_die_die_merge() // merging a file and a dir with the same nid and no mention of what should // happen to them fails -static void -test_same_nid_diff_type() +UNIT_TEST(roster, same_nid_diff_type) { testing_node_id_source nis; @@ -4394,9 +4374,7 @@ test_same_nid_diff_type() } - -static void -write_roster_test() +UNIT_TEST(roster, write_roster) { L(FL("TEST: write_roster_test")); roster_t r; MM(r); @@ -4547,8 +4525,7 @@ write_roster_test() } } -static void -check_sane_against_test() +UNIT_TEST(roster, check_sane_against) { testing_node_id_source nis; split_path root, foo, bar; @@ -4805,8 +4782,7 @@ create_some_new_temp_nodes(temp_node_id_ } } -static void -test_unify_rosters_randomized() +UNIT_TEST(roster, unify_rosters_randomized) { L(FL("TEST: begin checking unification of rosters (randomly)")); temp_node_id_source tmp_nis; @@ -4823,8 +4799,7 @@ test_unify_rosters_randomized() L(FL("TEST: end checking unification of rosters (randomly)")); } -static void -test_unify_rosters_end_to_end_ids() +UNIT_TEST(roster, unify_rosters_end_to_end_ids) { L(FL("TEST: begin checking unification of rosters (end to end, ids)")); revision_id has_rid = left_rid; @@ -4902,8 +4877,7 @@ test_unify_rosters_end_to_end_ids() L(FL("TEST: end checking unification of rosters (end to end, ids)")); } -static void -test_unify_rosters_end_to_end_attr_corpses() +UNIT_TEST(roster, unify_rosters_end_to_end_attr_corpses) { L(FL("TEST: begin checking unification of rosters (end to end, attr corpses)")); revision_id first_rid = left_rid; @@ -4997,26 +4971,6 @@ test_unify_rosters_end_to_end_attr_corps L(FL("TEST: end checking unification of rosters (end to end, attr corpses)")); } -void -add_roster_tests(test_suite * suite) -{ - I(suite); - suite->add(BOOST_TEST_CASE(&check_sane_roster_screwy_dir_map)); - suite->add(BOOST_TEST_CASE(&test_die_die_die_merge)); - suite->add(BOOST_TEST_CASE(&test_same_nid_diff_type)); - suite->add(BOOST_TEST_CASE(&test_unify_rosters_end_to_end_ids)); - suite->add(BOOST_TEST_CASE(&test_unify_rosters_end_to_end_attr_corpses)); - suite->add(BOOST_TEST_CASE(&test_unify_rosters_randomized)); - suite->add(BOOST_TEST_CASE(&test_all_mark_scenarios)); - suite->add(BOOST_TEST_CASE(&bad_attr_test)); - suite->add(BOOST_TEST_CASE(&check_sane_roster_loop_test)); - suite->add(BOOST_TEST_CASE(&check_sane_roster_test)); - suite->add(BOOST_TEST_CASE(&write_roster_test)); - suite->add(BOOST_TEST_CASE(&check_sane_against_test)); - suite->add(BOOST_TEST_CASE(&automaton_roster_test)); -} - - #endif // BUILD_UNIT_TESTS // Local Variables: ============================================================ --- roster_merge.cc 5cb34f31e03352190e8d8d4a39f18094bb3fe6c0 +++ roster_merge.cc 4b10972124b78dc6e03125e620f455b379110110 @@ -1075,9 +1075,7 @@ test_a_scalar_merge(scalar_val left_val, expected_outcome); } - -void -test_scalar_merges() +UNIT_TEST(roster_merge, scalar_merges) { // Notation: a1* means, "value is a, this is node 1 in the graph, it is // marked". ".2" means, "value is unimportant and different from either a @@ -1244,9 +1242,7 @@ make_node_lifecycle_objs(roster_t & r, m make_file(r, markings, common1, common1, common1, name + "_dead_file", fid1, nis.next()); } - -static void -test_roster_merge_node_lifecycle() +UNIT_TEST(roster_merge, node_lifecycle) { roster_t a_roster, b_roster; marking_map a_markings, b_markings; @@ -1296,8 +1292,7 @@ test_roster_merge_node_lifecycle() b_roster.get_node(b_safe_file_nid), false)); } -static void -test_roster_merge_attr_lifecycle() +UNIT_TEST(roster_merge, attr_lifecycle) { roster_t left_roster, right_roster; marking_map left_markings, right_markings; @@ -1581,9 +1576,7 @@ struct simple_missing_root_dir : public } }; - -static void -test_simple_structural_conflicts() +UNIT_TEST(roster_merge, simple_structural_conflicts) { { simple_rename_target_conflict t; @@ -1815,8 +1808,7 @@ struct rename_target_plus_missing_root : } }; -static void -test_complex_structural_conflicts() +UNIT_TEST(roster_merge, complex_structural_conflicts) { { node_name_plus_rename_target t; @@ -1844,17 +1836,6 @@ test_complex_structural_conflicts() } } -void -add_roster_merge_tests(test_suite * suite) -{ - I(suite); - suite->add(BOOST_TEST_CASE(&test_roster_merge_node_lifecycle)); - suite->add(BOOST_TEST_CASE(&test_roster_merge_attr_lifecycle)); - suite->add(BOOST_TEST_CASE(&test_scalar_merges)); - suite->add(BOOST_TEST_CASE(&test_simple_structural_conflicts)); - suite->add(BOOST_TEST_CASE(&test_complex_structural_conflicts)); -} - #endif // BUILD_UNIT_TESTS // Local Variables: ============================================================ --- simplestring_xform.cc 124885841fcd8e23ca00d28a3a646209986082b1 +++ simplestring_xform.cc 437c50dd55ec155557f1e957c0abdcb8808bd992 @@ -201,8 +201,7 @@ line_end_convert(string const & linesep, #include "unit_tests.hh" #include -static void -caseconv_test() +UNIT_TEST(simplestring_xform, caseconv) { BOOST_CHECK(uppercase("hello") == "HELLO"); BOOST_CHECK(uppercase("heLlO") == "HELLO"); @@ -212,8 +211,7 @@ caseconv_test() BOOST_CHECK(lowercase("address@hidden&*()") == "address@hidden&*()"); } -static void -join_lines_test() +UNIT_TEST(simplestring_xform, join_lines) { vector strs; string joined; @@ -235,8 +233,7 @@ join_lines_test() BOOST_CHECK(joined == "hi\nthere\nuser\n"); } -static void -strip_ws_test() +UNIT_TEST(simplestring_xform, strip_ws) { BOOST_CHECK(trim_ws("\n leading space") == "leading space"); BOOST_CHECK(trim_ws("trailing space \n") == "trailing space"); @@ -245,15 +242,6 @@ strip_ws_test() == "Ilikegoingforwalks"); } -void -add_simplestring_xform_tests(test_suite * suite) -{ - I(suite); - suite->add(BOOST_TEST_CASE(&caseconv_test)); - suite->add(BOOST_TEST_CASE(&join_lines_test)); - suite->add(BOOST_TEST_CASE(&strip_ws_test)); -} - #endif // BUILD_UNIT_TESTS // Local Variables: ============================================================ --- string_queue.cc 2919771b22c547c35e0f7469655049dd5a7c7ba2 +++ string_queue.cc 9f9b2784d472e90307d3b249f1fc487911268373 @@ -11,8 +11,7 @@ using std::logic_error; using std::logic_error; -void -test_string_queue() +UNIT_TEST(string_queue, string_queue) { string_queue sq1; @@ -69,12 +68,6 @@ test_string_queue() BOOST_CHECK( sq1.size() == 0 ); } -void -add_string_queue_tests(test_suite * suite) -{ - suite->add(BOOST_TEST_CASE(&test_string_queue)); -} - #endif // BUILD_UNIT_TESTS // Local Variables: ============================================================ --- transforms.cc 697265ad733bdbe6eab0149f803fd89219e85ea9 +++ transforms.cc a48c78d2e6afcc1222059a5707844380921913a1 @@ -270,8 +270,7 @@ canonical_base64(string const & s) #include "unit_tests.hh" #include -static void -enc_test() +UNIT_TEST(transform, enc) { data d2, d1("the rain in spain"); gzip gzd1, gzd2; @@ -284,8 +283,7 @@ enc_test() BOOST_CHECK(d2 == d1); } -static void -rdiff_test() +UNIT_TEST(transform, rdiff) { data dat1(string("the first day of spring\nmakes me want to sing\n")); data dat2(string("the first day of summer\nis a major bummer\n")); @@ -297,8 +295,7 @@ rdiff_test() BOOST_CHECK(dat3 == dat2); } -static void -calculate_ident_test() +UNIT_TEST(transform, calculate_ident) { data input(string("the only blender which can be turned into the most powerful vaccum cleaner")); hexenc output; @@ -307,15 +304,6 @@ calculate_ident_test() BOOST_CHECK(output() == ident); } -void -add_transform_tests(test_suite * suite) -{ - I(suite); - suite->add(BOOST_TEST_CASE(&enc_test)); - suite->add(BOOST_TEST_CASE(&rdiff_test)); - suite->add(BOOST_TEST_CASE(&calculate_ident_test)); -} - #endif // BUILD_UNIT_TESTS // Local Variables: ============================================================ --- unit_tests.cc 0681ea82bcb92ab13dba3cff4e8de17e2363e58a +++ unit_tests.cc 2ab21aca2410df583686a132b477f24d51174c62 @@ -7,18 +7,34 @@ // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. -#include +#include +#include +#include +#include +#include +#include +#include +#include #include "botan/botan.h" - #include "unit_tests.hh" #include "sanity.hh" +#include "ui.hh" -#include -#include - -using std::set; +using std::multimap; +using std::pair; +using std::make_pair; +using std::vector; using std::string; +using std::cout; +using std::cerr; +using std::clog; +using std::endl; +using std::exit; +using std::atexit; +using boost::unit_test::test_suite; +typedef boost::unit_test::test_case boost_unit_test_case; +namespace po = boost::program_options; static bool clean_shutdown; void dumper() @@ -33,92 +49,206 @@ void clean_shutdown_dummy_test() clean_shutdown = true; } -test_suite * init_unit_test_suite(int argc, char * argv[]) -{ - Botan::Init::initialize(); +// This must be a pointer. It is used by the constructor below, which is +// used to construct file-scope objects in different files; if it were the +// actual object there would be no way to guarantee that this gets +// constructed first. Instead, we initialize it ourselves the first time we +// use it. +typedef multimap unit_test_list_t; - clean_shutdown = false; - atexit(&dumper); - global_sanity.set_debug(); +static unit_test_list_t * unit_tests; - test_suite * suite = BOOST_TEST_SUITE("monotone unit tests"); - I(suite); +unit_test::unit_test_case::unit_test_case(char const * group, + char const * test, + void (*func)()) +{ + if (unit_tests == NULL) + unit_tests = new unit_test_list_t; - set t; - if (argc > 1) - t = set(argv+1, argv+argc); + boost_unit_test_case * tcase = BOOST_TEST_CASE(func); + tcase->p_name.set(string(test)); + unit_tests->insert(make_pair(string(group), tcase)); +} - // call all the adders here +// This appears to be the sanest way to get progress notifications on a +// per-test-group level. +static void notifier(string const & group) +{ + clog << group << "..." << endl; +} - if (t.empty() || t.find("file_io") != t.end()) - add_file_io_tests(suite); +test_suite * init_unit_test_suite(int argc, char * argv[]) +{ + po::variables_map vm; + try + { + po::options_description od((FL("Usage: %s [options] [tests]\nOptions") + % argv[0]).str()); + od.add_options() + ("help,h", "display help message") + ("list-groups,l", "list all test groups") + ("list-tests,L", "list all test cases") + ("debug,d", "enable verbose debug logging"); - if (t.empty() || t.find("key") != t.end()) - add_key_tests(suite); + // we have to do this silly thing to get positional arguments to work + // without an extra entry appearing in --help output. even this does + // not prevent the use of --tests= on the command line. bug in library. + po::options_description odx(""); + odx.add(od); + odx.add_options()("tests", po::value< vector >()); + po::positional_options_description pd; + pd.add("tests", -1); - if (t.empty() || t.find("transform") != t.end()) - add_transform_tests(suite); + po::store(po::command_line_parser(argc, argv). + options(odx).positional(pd).run(), vm); + po::notify(vm); + if (vm.count("help")) + { + cout << od << endl; + exit(0); + } + } + catch (po::ambiguous_option const & e) + { + cerr << argv[0] << ": " << e.what() << endl; + vector::const_iterator it = e.alternatives.begin(); + for (; it != e.alternatives.end(); ++it) + cerr << *it << endl; + exit(2); + } + catch (po::error const & e) + { + cerr << argv[0] << ": " << e.what() << endl; + exit(2); + } + if (vm.count("list-groups") && vm.count("list-tests")) + { + cerr << argv[0] + << ": only one of --list-groups and --list-tests at a time" + << endl; + exit(2); + } - if (t.empty() || t.find("charset") != t.end()) - add_charset_tests(suite); + if (vm.count("list-groups")) + { + string last; + for (unit_test_list_t::const_iterator i = unit_tests->begin(); + i != unit_tests->end(); + i++) + if (last != (*i).first) + { + cout << (*i).first << endl; + last = (*i).first; + } + exit(0); + } - if (t.empty() || t.find("simplestring_xform") != t.end()) - add_simplestring_xform_tests(suite); + if (vm.count("list-tests")) + { + for (unit_test_list_t::const_iterator i = unit_tests->begin(); + i != unit_tests->end(); + i++) + cout << (*i).first << ':' << (*i).second->p_name.get() << endl; + exit(0); + } - if (t.empty() || t.find("vocab") != t.end()) - add_vocab_tests(suite); + // If we get here, we are really running the test suite. + test_suite * suite = BOOST_TEST_SUITE("monotone unit tests"); - if (t.empty() || t.find("revision") != t.end()) - add_revision_tests(suite); + if (vm.count("tests") == 0) // run all tests + { + string last; + for (unit_test_list_t::const_iterator i = unit_tests->begin(); + i != unit_tests->end(); + i++) + { + if (last != (*i).first) + { + suite->add(BOOST_PARAM_TEST_CASE(notifier, + &((*i).first), + &((*i).first)+1)); + last = (*i).first; + } + suite->add((*i).second); + } + } + else + { + vector tests = vm["tests"].as< vector >(); + bool unrecognized = false; - if (t.empty() || t.find("cset") != t.end()) - add_cset_tests(suite); + for(vector::const_iterator i = tests.begin(); + i != tests.end(); + i++) + { + string group, test; + string::size_type sep = (*i).find(":"); - if (t.empty() || t.find("diff_patch") != t.end()) - add_diff_patch_tests(suite); + if (sep >= (*i).length()) // it's a group name + group = *i; + else + { + group = (*i).substr(0, sep); + test = (*i).substr(sep+1, string::npos); + } + + pair + range = unit_tests->equal_range(group); - if (t.empty() || t.find("xdelta") != t.end()) - add_xdelta_tests(suite); + if (range.first == range.second) + { + unrecognized = true; + cerr << argv[0] << ": unrecognized test group: " << group << endl; + continue; + } - if (t.empty() || t.find("packet") != t.end()) - add_packet_tests(suite); + suite->add(BOOST_PARAM_TEST_CASE(notifier, + &(*i), &(*i)+1)); - if (t.empty() || t.find("netcmd") != t.end()) - add_netcmd_tests(suite); + bool found = false; + for (unit_test_list_t::const_iterator j = range.first; + j != range.second; + j++) + if (test == "" || test == (*j).second->p_name.get()) + { + suite->add((*j).second); + found = true; + } + if (!found) + { + unrecognized = true; + cerr << argv[0] << ": unrecognized test: " + << group << ':' << test << endl; + } + } - if (t.empty() || t.find("globish") != t.end()) - add_globish_tests(suite); + if (unrecognized) + exit(1); + } - if (t.empty() || t.find("crypto") != t.end()) - add_crypto_tests(suite); + // at the end, add our clean-shutdown-indicator + suite->add(BOOST_TEST_CASE(&clean_shutdown_dummy_test)); - if (t.empty() || t.find("pipe") != t.end()) - add_pipe_tests(suite); + // set up some global state before running the tests + ui.initialize(); + ui.set_prog_name(argv[0]); + global_sanity.initialize(argc, argv, "C"); // we didn't call setlocale + Botan::Init::initialize(); - if (t.empty() || t.find("string_queue") != t.end()) - add_string_queue_tests(suite); + clean_shutdown = false; + atexit(&dumper); - if (t.empty() || t.find("paths") != t.end()) - add_paths_tests(suite); + if (vm.count("debug")) + global_sanity.set_debug(); - if (t.empty() || t.find("roster") != t.end()) - add_roster_tests(suite); + // work around an irritating bug in boost_unit_test_framework where + // the initial "Running tests" message goes to cout but everything + // else goes to cerr and thus appears first. + cerr.rdbuf(cout.rdbuf()); + clog.rdbuf(cout.rdbuf()); - if (t.empty() || t.find("roster_merge") != t.end()) - add_roster_merge_tests(suite); - - if (t.empty() || t.find("restrictions") != t.end()) - add_restrictions_tests(suite); - - if (t.empty() || t.find("uri") != t.end()) - add_uri_tests(suite); - - if (t.empty() || t.find("refiner") != t.end()) - add_refiner_tests(suite); - - // all done, add our clean-shutdown-indicator - suite->add(BOOST_TEST_CASE(&clean_shutdown_dummy_test)); - return suite; } ============================================================ --- unit_tests.hh f725a5a24793b324839108e7dd18bebaf9cb9955 +++ unit_tests.hh 7f27c21c1b8ca7a2652c4460b79e4143c54485ea @@ -10,43 +10,49 @@ // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. -#include +#include #include // strangely this was left out. perhaps it'll arrive later? #ifndef BOOST_CHECK_NOT_THROW -#define BOOST_CHECK_NOT_THROW( statement, exception ) \ - try { statement; BOOST_CHECK_MESSAGE(true, "exception "#exception" did not occur" ); } \ - catch( exception const& ) { \ - BOOST_ERROR( "exception "#exception" occurred" ); \ - } +#define BOOST_CHECK_NOT_THROW(statement, exception) \ + do \ + { \ + try \ + { \ + statement; \ + BOOST_CHECK_MESSAGE(true, "exception "#exception" did not occur"); \ + } \ + catch(exception const &) \ + { \ + BOOST_ERROR("exception "#exception" occurred"); \ + } \ + } while (0) #endif -using boost::unit_test_framework::test_suite; +// Declarative mechanism for specifying unit tests, similar to +// auto_unit_test in boost, but more suited to our needs. +namespace unit_test { + struct unit_test_case + { + unit_test_case(char const * group, + char const *test, + void (*func)()); + + }; +} -// list the various add-tests-to-the-testsuite functions here -void add_diff_patch_tests(test_suite * suite); -void add_file_io_tests(test_suite * suite); -void add_key_tests(test_suite * suite); -void add_transform_tests(test_suite * suite); -void add_charset_tests(test_suite * suite); -void add_simplestring_xform_tests(test_suite * suite); -void add_vocab_tests(test_suite * suite); -void add_cset_tests(test_suite * suite); -void add_revision_tests(test_suite * suite); -void add_xdelta_tests(test_suite * suite); -void add_packet_tests(test_suite * suite); -void add_netcmd_tests(test_suite * suite); -void add_globish_tests(test_suite * suite); -void add_crypto_tests(test_suite * suite); -void add_string_queue_tests(test_suite * suite); -void add_pipe_tests(test_suite * suite); -void add_paths_tests(test_suite * suite); -void add_roster_tests(test_suite * suite); -void add_roster_merge_tests(test_suite * suite); -void add_restrictions_tests(test_suite * suite); -void add_uri_tests(test_suite * suite); -void add_refiner_tests(test_suite * suite); +// The names of the test functions must not collide with each other or with +// names of symbols in the code being tested, despite their being in a +// separate namespace, so that references _from_ the test functions _to_ the +// code under test resolve correctly. +#define UNIT_TEST(GROUP, TEST) \ + namespace unit_test { \ + static void t_##GROUP##_##TEST(); \ + static unit_test_case r_##GROUP##_##TEST \ + (#GROUP, #TEST, t_##GROUP##_##TEST); \ + } \ + static void unit_test::t_##GROUP##_##TEST() // Local Variables: // mode: C++ ============================================================ --- uri.cc b269205c09ed72b520bc738aadf8ae79924f810b +++ uri.cc c64651637ad0540d6adfaaf4a17f48264700c260 @@ -168,9 +168,7 @@ test_one_uri(string scheme, BOOST_CHECK(u.fragment == fragment); } - -static void -uri_test() +UNIT_TEST(uri, uri) { test_one_uri("ssh", "graydon", "", "venge.net", "22", "/tmp/foo.mtn", "", ""); test_one_uri("ssh", "graydon", "", "venge.net", "", "/tmp/foo.mtn", "", ""); @@ -181,14 +179,6 @@ uri_test() test_one_uri("http", "graydon", "", "venge.net", "8080", "/foo.cgi", "branch=foo", "tip"); } - -void -add_uri_tests(test_suite * suite) -{ - I(suite); - suite->add(BOOST_TEST_CASE(&uri_test)); -} - #endif // BUILD_UNIT_TESTS // Local Variables: ============================================================ --- vocab.cc f63b97e15c4c31a108832bc5eac2cf04f8fe89f8 +++ vocab.cc 45d358088bd8b5d169aa68af49a9adb8898cbc03 @@ -239,19 +239,6 @@ void dump(roster_data const & d, string template void dump(roster_data const & d, string &); -// the rest is unit tests - -#ifdef BUILD_UNIT_TESTS -#include "unit_tests.hh" - -void add_vocab_tests(test_suite * suite) -{ - I(suite); - // None, ATM. -} - -#endif // BUILD_UNIT_TESTS - // Local Variables: // mode: C++ // fill-column: 76 ============================================================ --- xdelta.cc 61c35b2d36b0c1d87a1f3e481c9cdc315c77a746 +++ xdelta.cc 40958b7219a9dccafe0b4a4dabe4ee7af77ac9ab @@ -802,8 +802,7 @@ spin(string a, string b) BOOST_CHECK(b == apply_via_piecewise(a, ba_inverted)); } -void -xdelta_simple_cases() +UNIT_TEST(xdelta, simple_cases) { L(FL("empty/empty")); spin("", ""); @@ -898,8 +897,7 @@ xdelta_randomly_delete(string & str) } } -void -xdelta_random_simple_delta_test() +UNIT_TEST(xdelta, random_simple_delta) { for (int i = 0; i < 100; ++i) { @@ -913,8 +911,7 @@ xdelta_random_simple_delta_test() } } -void -xdelta_random_piecewise_delta_test() +UNIT_TEST(xdelta, random_piecewise_delta) { for (int i = 0; i < 50; ++i) { @@ -941,15 +938,6 @@ xdelta_random_piecewise_delta_test() } } -void -add_xdelta_tests(test_suite * suite) -{ - I(suite); - suite->add(BOOST_TEST_CASE(&xdelta_simple_cases)); - suite->add(BOOST_TEST_CASE(&xdelta_random_simple_delta_test)); - suite->add(BOOST_TEST_CASE(&xdelta_random_piecewise_delta_test)); -} - #endif // BUILD_UNIT_TESTS // Local Variables: