# # # rename "unit_tests.cc" # to "unit_tester.cc" # # patch "Makefile.am" # from [b2891ae6208641d325a61977637aa21c80dd6842] # to [81a56e373094e7699b92df8782474f72c8a24029] # # patch "basic_io.cc" # from [80007ffb4e960712490eaf666f8c3f1869f080b0] # to [46f768f9ef1128082d777b4d22587886547c8313] # # patch "charset.cc" # from [befb5d4e7e8f0c446a125b6270de61ad74176ffd] # to [67817bc4c18bd72d923184a7298435da70fd4137] # # patch "commands.cc" # from [6d1d665d00d93e1195d9cbf8d87bb27f4effc8a0] # to [773fb3067c87f75d85b5b761cd7b6967e422e093] # # patch "crypto_tests.cc" # from [4d2f2ee1922c28164bd8376921f82d463b0bfc8e] # to [8e92a991f10baece1448c9fd93eb7018a9668b4a] # # patch "cset.cc" # from [42fbd475c9413b93d2df7c8acfe7e877b47467b0] # to [aa24d350aa81ff2d3d3e698196e4954efb380da6] # # patch "dates.cc" # from [577db99dea5e3d66d331d00dbf2ea1bffc0e8e72] # to [c94ad816f640a650405a5f1b30a0fe93ebf85187] # # patch "globish.cc" # from [d4ca5ed4bc475b8f3f06a7b028265817344120d7] # to [976477e3b93e34e16a1007559652f70e7bf2ce7d] # # patch "graph.cc" # from [f646bb79fb8f342fdba4f49475fb3329faba78a9] # to [f32fb2a9bb1eebe266cde7545e45fcaf5b99fabc] # # patch "merge_3way.cc" # from [ba4b9a47da2894bacbf6b624251d259a11483808] # to [9c95c7233ab9a64f21d0ad5d541b16b9fff7a4d5] # # patch "merge_roster.cc" # from [2d60c4d0fee6b0b962cab30aeed3838181c8ed08] # to [fd419a9c544a8bf6f910b7fc33abf21b5df6d214] # # patch "netcmd.cc" # from [6252b7c1fa1a3bcead8a75d6e881ad44ea95053e] # to [87b28f57ac2ce6b5472761c7073a2e5564390762] # # patch "netxx_pipe.cc" # from [9b0c7df48d0c9d3e4654c8f590460a419b8e70d3] # to [46cc21dea33495937a9b925ac1d9a0365c6e06da] # # patch "numeric_vocab.cc" # from [971633e9dff57e737e46513b41f43985cf86158e] # to [6d63804cd9dda76db22ecdfec9c6a9d6b89a69e4] # # patch "option.cc" # from [706f424f7b995dbc6db012e814b57adcc8f642a1] # to [eaadb9a7b2c7a651455d4d14170c488081bf8d9a] # # patch "outdated_indicator.cc" # from [ce466c0d56715e28dc365c25c1caf0afa0359587] # to [04b1e2c2b07e869e2a48f254fd7ff23e80dfb2c0] # # patch "packet.cc" # from [7764b9b5ba69d5cc2166ba8e3a06f5a6d28bfece] # to [32a4f7e15b0cd39ef1d5babebd9645ed2d1073f5] # # patch "paths.cc" # from [16eaea217a0b8669a15016d435e4807aef0016ad] # to [d49fd603357d585248692ce5a9255476abf21179] # # patch "refiner.cc" # from [19066745ddc95c080b14e0b3cc2edd44d2e9d5e6] # to [5d306b770b6a213d43b00806437bb6c757815d42] # # patch "restrictions.cc" # from [4a217d43fdc52b15a744818ecd3cb1b98401d73b] # to [0985e67425ab02e75cf175c525e42074aa15268b] # # patch "rev_height.cc" # from [7330d685fb6f60b4425d2e9f6be2211c2785eb71] # to [969598a29a3f000321f2f5f7ee2989659606f69e] # # patch "revision.cc" # from [5b5f6c11cf218a22285d6939f14a1d5d64d3e482] # to [a5aaa29e0e5aaff3f87ee342d20c360fc69f96f3] # # patch "roster.cc" # from [fdcabef3294b34d9816a3da0d2da8e2d90befdb2] # to [0269cfb8f735ac17f0d07f7c7685ba5d5e911f21] # # patch "simplestring_xform.cc" # from [9ee64085fd6badec5b1ff9a25bab8cee8b169f8f] # to [59186652c6b6835b7e2e6b113f3d976a9ed62e1d] # # patch "string_queue.cc" # from [39f987fc625eb0f43ba86c794b40ad008fc5114e] # to [429a21cfa853ab702bf10ceca34622c3e4f08525] # # patch "transforms.cc" # from [21d1f172b5413b4123358f3c44135b6cd44ae5d5] # to [bdc3fdae1172a62a2cbb6f1cfdb84826786762b9] # # patch "unit_tester.cc" # from [475fa100e0921123927e14b005c6d83735057980] # to [74c09bbe54bf1b4d94a68f6ee5b0e8ba23dff0cb] # # patch "unit_tests.hh" # from [bdedb58135c3943f535e60efeb81f93c79e4e153] # to [48d2f3e88792009a1f883da4e7d7926b802fd016] # # patch "uri.cc" # from [73f93c410b9e5dc395c15141b9f2fe8dbd73c3c0] # to [877def8f4bf7ae30a933c338aafdf1e8528c6660] # # patch "vocab.cc" # from [bb503a780573812673e29b185737947f2a189d95] # to [444f8540bc0b585cdbb6d592799febeba88c4978] # # patch "xdelta.cc" # from [3bfd03cf01ed8e07764ce268820407d13a583c22] # to [85f1764bd00be13dc46f9305b582ec975c08472e] # ============================================================ --- Makefile.am b2891ae6208641d325a61977637aa21c80dd6842 +++ Makefile.am 81a56e373094e7699b92df8782474f72c8a24029 @@ -11,7 +11,7 @@ SANITY_CORE_SOURCES = \ sanity.cc sanity.hh quick_alloc.hh vector.hh base.hh \ simplestring_xform.cc simplestring_xform.hh \ constants.cc constants.hh numeric_vocab.hh \ - platform.hh numeric_vocab.cc origin_type.hh + platform.hh origin_type.hh LUAEXT_SOURCES = \ vocab.hh vocab.cc vocab_terms.hh vocab_macros.hh vocab_cast.hh \ @@ -303,7 +303,7 @@ UNIT_TEST_SOURCES = \ outdated_indicator.cc packet.cc paths.cc refiner.cc \ restrictions.cc rev_height.cc revision.cc roster.cc \ simplestring_xform.cc string_queue.cc transforms.cc \ - unit_tests.cc uri.cc vocab.cc xdelta.cc + unit_tester.cc uri.cc vocab.cc xdelta.cc # these files do not contain unit tests, but are required for unit testing # and are not used by the main program ============================================================ --- basic_io.cc 80007ffb4e960712490eaf666f8c3f1869f080b0 +++ basic_io.cc 46f768f9ef1128082d777b4d22587886547c8313 @@ -220,7 +220,7 @@ string basic_io::parser::tt2str(token_ty #ifdef BUILD_UNIT_TESTS #include "unit_tests.hh" -UNIT_TEST(basic_io, binary_transparency) +UNIT_TEST(binary_transparency) { std::string testpattern; for (unsigned i=0; i<256; ++i) testpattern+=char(i); ============================================================ --- charset.cc befb5d4e7e8f0c446a125b6270de61ad74176ffd +++ charset.cc 67817bc4c18bd72d923184a7298435da70fd4137 @@ -582,7 +582,7 @@ idna IDNA_ACE_PREFIX "b1abfaaepdrnnbgefbadotcwatmq2g4l"}, }; -UNIT_TEST(charset, idna_encoding) +UNIT_TEST(idna_encoding) { // putenv takes a char*, not a const char*, there is nothing we can do. putenv(const_cast("CHARSET=UTF-8")); @@ -606,7 +606,7 @@ UNIT_TEST(charset, idna_encoding) } } -UNIT_TEST(charset, utf8_validation) +UNIT_TEST(utf8_validation) { // 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 ============================================================ --- commands.cc 6d1d665d00d93e1195d9cbf8d87bb27f4effc8a0 +++ commands.cc 773fb3067c87f75d85b5b761cd7b6967e422e093 @@ -545,7 +545,7 @@ mkargs(const char *words) return split_into_words(arg_type(words, origin::user)); } -UNIT_TEST(commands, make_command_id) +UNIT_TEST(make_command_id) { using commands::command_id; using commands::make_command_id; @@ -564,7 +564,7 @@ UNIT_TEST(commands, make_command_id) } } -UNIT_TEST(commands, complete_command) +UNIT_TEST(complete_command) { using commands::command_id; using commands::complete_command; @@ -601,7 +601,7 @@ UNIT_TEST(commands, complete_command) } } -UNIT_TEST(commands, command_complete_command) +UNIT_TEST(command_complete_command) { using commands::command_id; using commands::make_command_id; @@ -713,7 +713,7 @@ UNIT_TEST(commands, command_complete_com } } -UNIT_TEST(commands, command_find_command) +UNIT_TEST(command_find_command) { using commands::command; using commands::command_id; ============================================================ --- crypto_tests.cc 4d2f2ee1922c28164bd8376921f82d463b0bfc8e +++ crypto_tests.cc 8e92a991f10baece1448c9fd93eb7018a9668b4a @@ -45,7 +45,7 @@ namespace { extern char const * const pseudo_checkpoints[]; }; -UNIT_TEST(sha1, short_message) +UNIT_TEST(short_message) { int failures = 0; for (int i = 0; short_message_in[i]; i++) @@ -69,7 +69,7 @@ UNIT_TEST(sha1, short_message) FL("short message: %d failures") % failures); } -UNIT_TEST(sha1, long_message) +UNIT_TEST(long_message) { int failures = 0; for (int i = 0; long_message_in[i]; i++) @@ -93,7 +93,7 @@ UNIT_TEST(sha1, long_message) FL("long message: %d failures") % failures); } -UNIT_TEST(sha1, pseudo_message) +UNIT_TEST(pseudo_message) { std::string MD[1003]; int failures = 0; ============================================================ --- cset.cc 42fbd475c9413b93d2df7c8acfe7e877b47467b0 +++ cset.cc aa24d350aa81ff2d3d3e698196e4954efb380da6 @@ -503,7 +503,7 @@ setup_roster(roster_t & r, file_id const } } -UNIT_TEST(cset, cset_written) +UNIT_TEST(cset_written) { { L(FL("TEST: cset reading - operation misordering")); @@ -758,7 +758,7 @@ UNIT_TEST(cset, cset_written) } } -UNIT_TEST(cset, basic_csets) +UNIT_TEST(basic_csets) { temp_node_id_source nis; @@ -937,7 +937,7 @@ UNIT_TEST(cset, basic_csets) } } -UNIT_TEST(cset, invalid_csets) +UNIT_TEST(invalid_csets) { temp_node_id_source nis; roster_t r; @@ -1109,7 +1109,7 @@ UNIT_TEST(cset, invalid_csets) } } -UNIT_TEST(cset, root_dir) +UNIT_TEST(root_dir) { temp_node_id_source nis; roster_t r; ============================================================ --- dates.cc 577db99dea5e3d66d331d00dbf2ea1bffc0e8e72 +++ dates.cc c94ad816f640a650405a5f1b30a0fe93ebf85187 @@ -564,7 +564,7 @@ s64 const FOUR_HUNDRED_YEARS = 400 * YEA s64 const FOUR_HUNDRED_YEARS = 400 * YEAR + (100 - 4 + 1) * DAY; -UNIT_TEST(date, our_timegm) +UNIT_TEST(our_timegm) { #define OK(x) UNIT_TEST_CHECK(our_timegm(t) == MILLISEC(x)) @@ -614,7 +614,7 @@ UNIT_TEST(date, our_timegm) #undef OK } -UNIT_TEST(date, from_string) +UNIT_TEST(from_string) { #define OK(x,y) do { \ string s_ = date_t(x).as_iso_8601_extended(); \ @@ -737,7 +737,7 @@ UNIT_TEST(date, from_string) #undef NO } -UNIT_TEST(date, from_unix_epoch) +UNIT_TEST(from_unix_epoch) { #define OK_(x,y) do { \ string s_ = date_t(x).as_iso_8601_extended(); \ @@ -866,7 +866,7 @@ UNIT_TEST(date, from_unix_epoch) #undef OK } -UNIT_TEST(date, comparisons) +UNIT_TEST(comparisons) { date_t may = date_t("2000-05-01T00:00:00"), jun = date_t("2000-06-01T00:00:00"), @@ -974,7 +974,7 @@ roundtrip_1(s64 t) } } -UNIT_TEST(date, roundtrip_all_year_boundaries) +UNIT_TEST(roundtrip_all_year_boundaries) { s64 t = EARLIEST_SUPPORTED_DATE; u32 year = 1; ============================================================ --- globish.cc d4ca5ed4bc475b8f3f06a7b028265817344120d7 +++ globish.cc 976477e3b93e34e16a1007559652f70e7bf2ce7d @@ -523,7 +523,7 @@ bool globish::matches(string const & tar #ifdef BUILD_UNIT_TESTS #include "unit_tests.hh" -UNIT_TEST(globish, syntax) +UNIT_TEST(syntax) { struct tcase { @@ -623,7 +623,7 @@ UNIT_TEST(globish, syntax) } } -UNIT_TEST(globish, from_vector) +UNIT_TEST(from_vector) { vector v; v.push_back(arg_type("a", origin::internal)); @@ -635,7 +635,7 @@ UNIT_TEST(globish, from_vector) UNIT_TEST_CHECK(s == "{a,b,c}"); } -UNIT_TEST(globish, simple_matches) +UNIT_TEST(simple_matches) { UNIT_TEST_CHECK(globish("abc", origin::internal).matches("abc")); UNIT_TEST_CHECK(!globish("abc", origin::internal).matches("aac")); @@ -688,7 +688,7 @@ UNIT_TEST(globish, simple_matches) UNIT_TEST_CHECK(!globish("a*b*[cd]", origin::internal).matches("adb")); } -UNIT_TEST(globish, complex_matches) +UNIT_TEST(complex_matches) { { globish_matcher m(globish("{a,b}?*\\*|", origin::internal), globish("*c*", origin::internal)); @@ -724,7 +724,7 @@ UNIT_TEST(globish, complex_matches) } } -UNIT_TEST(globish, nested_matches) +UNIT_TEST(nested_matches) { globish g("a.{i.{x,y},j}", origin::internal); UNIT_TEST_CHECK(g.matches("a.i.x")); ============================================================ --- graph.cc f646bb79fb8f342fdba4f49475fb3329faba78a9 +++ graph.cc f32fb2a9bb1eebe266cde7545e45fcaf5b99fabc @@ -243,7 +243,7 @@ run_get_reconstruction_path_tests_on_ran } } -UNIT_TEST(graph, random_get_reconstruction_path) +UNIT_TEST(random_get_reconstruction_path) { randomizer rng; // Some arbitrary numbers. @@ -519,7 +519,7 @@ run_a_get_uncommon_ancestors_test(rev_an I(calculated_right_uncommon_ancestors == true_right_uncommon_ancestors); } -UNIT_TEST(graph, get_uncommon_ancestors_nasty_convexity_case) +UNIT_TEST(get_uncommon_ancestors_nasty_convexity_case) { // This tests the nasty case described in the giant comment above // get_uncommon_ancestors: @@ -676,7 +676,7 @@ run_a_get_uncommon_ancestors_random_test } } -UNIT_TEST(graph, get_uncommon_ancestors_randomly) +UNIT_TEST(get_uncommon_ancestors_randomly) { randomizer rng; run_a_get_uncommon_ancestors_random_test(100, 100, rng); ============================================================ --- merge_3way.cc ba4b9a47da2894bacbf6b624251d259a11483808 +++ merge_3way.cc 9c95c7233ab9a64f21d0ad5d541b16b9fff7a4d5 @@ -500,7 +500,7 @@ static void dump_incorrect_merge(vector< } // high tech randomizing test -UNIT_TEST(diff_patch, randomizing_merge) +UNIT_TEST(randomizing_merge) { randomizer rng; for (int i = 0; i < 30; ++i) @@ -523,7 +523,7 @@ UNIT_TEST(diff_patch, randomizing_merge) // old boring tests -UNIT_TEST(diff_patch, merge_prepend) +UNIT_TEST(merge_prepend) { UNIT_TEST_CHECKPOINT("prepend test"); vector anc, d1, d2, m1, m2, gm; @@ -553,7 +553,7 @@ UNIT_TEST(diff_patch, merge_prepend) UNIT_TEST_CHECK(gm == m2); } -UNIT_TEST(diff_patch, merge_append) +UNIT_TEST(merge_append) { UNIT_TEST_CHECKPOINT("append test"); vector anc, d1, d2, m1, m2, gm; @@ -583,7 +583,7 @@ UNIT_TEST(diff_patch, merge_append) } -UNIT_TEST(diff_patch, merge_additions) +UNIT_TEST(merge_additions) { UNIT_TEST_CHECKPOINT("additions test"); string ancestor("I like oatmeal\nI like orange juice\nI like toast"); @@ -612,7 +612,7 @@ UNIT_TEST(diff_patch, merge_additions) UNIT_TEST_CHECK(!merge3(anc, d1, cf, m1)); } -UNIT_TEST(diff_patch, merge_deletions) +UNIT_TEST(merge_deletions) { string ancestor("I like oatmeal\nI like orange juice\nI like toast"); string desc2("I like oatmeal\nI like toast"); ============================================================ --- merge_roster.cc 2d60c4d0fee6b0b962cab30aeed3838181c8ed08 +++ merge_roster.cc fd419a9c544a8bf6f910b7fc33abf21b5df6d214 @@ -1187,7 +1187,7 @@ test_a_scalar_merge(scalar_val left_val, expected_outcome); } -UNIT_TEST(roster_merge, scalar_merges) +UNIT_TEST(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 @@ -1353,7 +1353,7 @@ make_node_lifecycle_objs(roster_t & r, m make_file(r, markings, common1, common1, common1, name + "_dead_file", fid1, nis.next()); } -UNIT_TEST(roster_merge, node_lifecycle) +UNIT_TEST(node_lifecycle) { roster_t a_roster, b_roster; marking_map a_markings, b_markings; @@ -1405,7 +1405,7 @@ UNIT_TEST(roster_merge, node_lifecycle) b_roster.get_node(b_safe_file_nid), false)); } -UNIT_TEST(roster_merge, attr_lifecycle) +UNIT_TEST(attr_lifecycle) { roster_t left_roster, right_roster; marking_map left_markings, right_markings; @@ -1692,7 +1692,7 @@ struct simple_missing_root_dir : public } }; -UNIT_TEST(roster_merge, simple_structural_conflicts) +UNIT_TEST(simple_structural_conflicts) { { simple_duplicate_name_conflict t; @@ -1926,7 +1926,7 @@ struct duplicate_name_plus_missing_root } }; -UNIT_TEST(roster_merge, complex_structural_conflicts) +UNIT_TEST(complex_structural_conflicts) { { multiple_name_plus_duplicate_name t; ============================================================ --- netcmd.cc 6252b7c1fa1a3bcead8a75d6e881ad44ea95053e +++ netcmd.cc 87b28f57ac2ce6b5472761c7073a2e5564390762 @@ -564,7 +564,7 @@ netcmd::write_usher_reply_cmd(utf8 const #include "transforms.hh" #include "lexical_cast.hh" -UNIT_TEST(netcmd, mac) +UNIT_TEST(mac) { netcmd out_cmd, in_cmd; string buf; @@ -622,7 +622,7 @@ do_netcmd_roundtrip(netcmd const & out_c UNIT_TEST_CHECK(in_cmd == out_cmd); } -UNIT_TEST(netcmd, functions) +UNIT_TEST(functions) { try ============================================================ --- netxx_pipe.cc 9b0c7df48d0c9d3e4654c8f590460a419b8e70d3 +++ netxx_pipe.cc 46cc21dea33495937a9b925ac1d9a0365c6e06da @@ -554,7 +554,7 @@ Netxx::PipeCompatibleProbe::add(const St #ifndef WIN32 -UNIT_TEST(pipe, simple_pipe) +UNIT_TEST(simple_pipe) { try { Netxx::PipeStream pipe("cat",vector()); ============================================================ --- numeric_vocab.cc 971633e9dff57e737e46513b41f43985cf86158e +++ numeric_vocab.cc 6d63804cd9dda76db22ecdfec9c6a9d6b89a69e4 @@ -12,37 +12,36 @@ #ifdef BUILD_UNIT_TESTS #include "base.hh" +#include "numeric_vocab.hh" #include "unit_tests.hh" -#include "sanity.hh" -#include "numeric_vocab.hh" -UNIT_TEST(widen, widen) +UNIT_TEST(widen) { // These all have double-parens to stop the C preprocessor from becoming // confused by the commas in the template arguments. The static_cast's // are to shut up compiler warnings. // unsigned -> unsigned - I((widen(1) == 1)); - I((widen(255) == 255)); - I((widen(static_cast(-1)) == 255)); - I((widen(1) == 1)); - I((widen(255) == 255)); - I((widen(static_cast(-1)) == 255)); + UNIT_TEST_CHECK((widen(1) == 1)); + UNIT_TEST_CHECK((widen(255) == 255)); + UNIT_TEST_CHECK((widen(static_cast(-1)) == 255)); + UNIT_TEST_CHECK((widen(1) == 1)); + UNIT_TEST_CHECK((widen(255) == 255)); + UNIT_TEST_CHECK((widen(static_cast(-1)) == 255)); // unsigned -> signed - I((widen(1) == 1)); - I((widen(255) == 255)); - I((widen(static_cast(-1)) == 255)); + UNIT_TEST_CHECK((widen(1) == 1)); + UNIT_TEST_CHECK((widen(255) == 255)); + UNIT_TEST_CHECK((widen(static_cast(-1)) == 255)); // signed -> signed - I((widen(1) == 1)); - I((widen(255) == -1)); - I((widen(-1) == -1)); + UNIT_TEST_CHECK((widen(1) == 1)); + UNIT_TEST_CHECK((widen(255) == -1)); + UNIT_TEST_CHECK((widen(-1) == -1)); // signed -> unsigned ((critical case!)) - I((widen(1) == 1)); - I((widen(255) == 255)); - I((widen(-1) == 255)); + UNIT_TEST_CHECK((widen(1) == 1)); + UNIT_TEST_CHECK((widen(255) == 255)); + UNIT_TEST_CHECK((widen(-1) == 255)); // contrasts with: - I((static_cast(s8(-1)) == u32(4294967295u))); + UNIT_TEST_CHECK((static_cast(s8(-1)) == u32(4294967295u))); } #endif // BUILD_UNIT_TESTS ============================================================ --- option.cc 706f424f7b995dbc6db012e814b57adcc8f642a1 +++ option.cc eaadb9a7b2c7a651455d4d14170c488081bf8d9a @@ -462,7 +462,7 @@ concrete_option_set::get_usage_strings(v #ifdef BUILD_UNIT_TESTS #include "unit_tests.hh" -UNIT_TEST(option, concrete_options) +UNIT_TEST(concrete_options) { bool b = false; string s; ============================================================ --- outdated_indicator.cc ce466c0d56715e28dc365c25c1caf0afa0359587 +++ outdated_indicator.cc 04b1e2c2b07e869e2a48f254fd7ff23e80dfb2c0 @@ -88,7 +88,7 @@ outdated_indicator_factory::note_change( #ifdef BUILD_UNIT_TESTS #include "unit_tests.hh" -UNIT_TEST(outdated_indicator, ) +UNIT_TEST(basic) { outdated_indicator indicator; { ============================================================ --- packet.cc 7764b9b5ba69d5cc2166ba8e3a06f5a6d28bfece +++ packet.cc 32a4f7e15b0cd39ef1d5babebd9645ed2d1073f5 @@ -405,7 +405,7 @@ using std::ostringstream; using std::ostringstream; -UNIT_TEST(packet, validators) +UNIT_TEST(validators) { ostringstream oss; packet_writer pw(oss); @@ -473,7 +473,7 @@ UNIT_TEST(packet, validators) } } -UNIT_TEST(packet, roundabout) +UNIT_TEST(roundabout) { string tmp; ============================================================ --- paths.cc 16eaea217a0b8669a15016d435e4807aef0016ad +++ paths.cc d49fd603357d585248692ce5a9255476abf21179 @@ -1068,7 +1068,7 @@ using std::logic_error; using std::logic_error; -UNIT_TEST(paths, path_component) +UNIT_TEST(path_component) { char const * const baddies[] = {".", "..", @@ -1107,7 +1107,7 @@ UNIT_TEST(paths, path_component) } -UNIT_TEST(paths, file_path_internal) +UNIT_TEST(file_path_internal) { char const * const baddies[] = {"/foo", "foo//bar", @@ -1201,7 +1201,7 @@ static void check_fp_normalizes_to(char UNIT_TEST_CHECK(fp.as_external() == after); } -UNIT_TEST(paths, file_path_external_null_prefix) +UNIT_TEST(file_path_external_null_prefix) { initial_rel_path.unset(); initial_rel_path.set(string(), true); @@ -1268,7 +1268,7 @@ UNIT_TEST(paths, file_path_external_null initial_rel_path.unset(); } -UNIT_TEST(paths, file_path_external_prefix__MTN) +UNIT_TEST(file_path_external_prefix__MTN) { initial_rel_path.unset(); initial_rel_path.set(string("_MTN"), true); @@ -1280,7 +1280,7 @@ UNIT_TEST(paths, file_path_external_pref check_fp_normalizes_to("../foo", "foo"); } -UNIT_TEST(paths, file_path_external_prefix_a_b) +UNIT_TEST(file_path_external_prefix_a_b) { initial_rel_path.unset(); initial_rel_path.set(string("a/b"), true); @@ -1358,7 +1358,7 @@ UNIT_TEST(paths, file_path_external_pref initial_rel_path.unset(); } -UNIT_TEST(paths, basename) +UNIT_TEST(basename) { struct t { @@ -1474,7 +1474,7 @@ UNIT_TEST(paths, basename) initial_abs_path.unset(); } -UNIT_TEST(paths, dirname) +UNIT_TEST(dirname) { struct t { @@ -1569,7 +1569,7 @@ UNIT_TEST(paths, dirname) initial_abs_path.unset(); } -UNIT_TEST(paths, depth) +UNIT_TEST(depth) { char const * const cases[] = {"", "foo", "foo/bar", "foo/bar/baz", 0}; for (unsigned int i = 0; cases[i]; i++) @@ -1590,7 +1590,7 @@ static void check_bk_normalizes_to(char origin::internal).as_internal() == bp.as_internal()); } -UNIT_TEST(paths, bookkeeping) +UNIT_TEST(bookkeeping) { char const * const baddies[] = {"/foo", "foo//bar", @@ -1642,7 +1642,7 @@ static void check_system_normalizes_to(c origin::internal).as_internal() == sp.as_internal()); } -UNIT_TEST(paths, system) +UNIT_TEST(system) { initial_abs_path.unset(); initial_abs_path.set(system_path("/a/b"), true); @@ -1729,7 +1729,7 @@ UNIT_TEST(paths, system) initial_rel_path.unset(); } -UNIT_TEST(paths, access_tracker) +UNIT_TEST(access_tracker) { access_tracker a; UNIT_TEST_CHECK_THROW(a.get(), logic_error); @@ -1766,7 +1766,7 @@ static void test_path_equal(string const I(left_fp == right_fp); } -UNIT_TEST(paths, ordering) +UNIT_TEST(ordering) { // this ordering is very important: // -- it is used to determine the textual form of csets and manifests @@ -1794,7 +1794,7 @@ UNIT_TEST(paths, ordering) "fallanopic_not_otherwise_mentioned"); } -UNIT_TEST(paths, ordering_random) +UNIT_TEST(ordering_random) { char x[4] = {0,0,0,0}; char y[4] = {0,0,0,0}; @@ -1949,7 +1949,7 @@ UNIT_TEST(paths, ordering_random) } } -UNIT_TEST(paths, test_internal_string_is_bookkeeping_path) +UNIT_TEST(test_internal_string_is_bookkeeping_path) { char const * const yes[] = {"_MTN", "_MTN/foo", @@ -1968,7 +1968,7 @@ UNIT_TEST(paths, test_internal_string_is origin::internal))); } -UNIT_TEST(paths, test_external_string_is_bookkeeping_path_prefix_none) +UNIT_TEST(test_external_string_is_bookkeeping_path_prefix_none) { initial_rel_path.unset(); initial_rel_path.set(string(), true); @@ -1992,7 +1992,7 @@ UNIT_TEST(paths, test_external_string_is origin::internal))); } -UNIT_TEST(paths, test_external_string_is_bookkeeping_path_prefix_a_b) +UNIT_TEST(test_external_string_is_bookkeeping_path_prefix_a_b) { initial_rel_path.unset(); initial_rel_path.set(string("a/b"), true); @@ -2018,7 +2018,7 @@ UNIT_TEST(paths, test_external_string_is origin::internal))); } -UNIT_TEST(paths, test_external_string_is_bookkeeping_path_prefix__MTN) +UNIT_TEST(test_external_string_is_bookkeeping_path_prefix__MTN) { initial_rel_path.unset(); initial_rel_path.set(string("_MTN"), true); @@ -2048,7 +2048,7 @@ UNIT_TEST(paths, test_external_string_is origin::internal))); } -UNIT_TEST(paths, find_old_new_path_for) +UNIT_TEST(find_old_new_path_for) { map renames; file_path foo = file_path_internal("foo"); ============================================================ --- refiner.cc 19066745ddc95c080b14e0b3cc2edd44d2e9d5e6 +++ refiner.cc 5d306b770b6a213d43b00806437bb6c757815d42 @@ -707,7 +707,7 @@ check_with_count(size_t base_set_size, r } } -UNIT_TEST(refiner, various_counts) +UNIT_TEST(various_counts) { { // Once with zero-zero, for good measure. ============================================================ --- restrictions.cc 4a217d43fdc52b15a744818ecd3cb1b98401d73b +++ restrictions.cc 0985e67425ab02e75cf175c525e42074aa15268b @@ -504,7 +504,7 @@ static void setup(roster_t & roster) } -UNIT_TEST(restrictions, empty_restriction) +UNIT_TEST(empty_restriction) { roster_t roster; setup(roster); @@ -570,7 +570,7 @@ UNIT_TEST(restrictions, empty_restrictio UNIT_TEST_CHECK(pmask.includes(fp_yyg)); } -UNIT_TEST(restrictions, simple_include) +UNIT_TEST(simple_include) { roster_t roster; setup(roster); @@ -640,7 +640,7 @@ UNIT_TEST(restrictions, simple_include) UNIT_TEST_CHECK( pmask.includes(fp_yyg)); } -UNIT_TEST(restrictions, simple_exclude) +UNIT_TEST(simple_exclude) { roster_t roster; setup(roster); @@ -710,7 +710,7 @@ UNIT_TEST(restrictions, simple_exclude) UNIT_TEST_CHECK(!pmask.includes(fp_yyg)); } -UNIT_TEST(restrictions, include_exclude) +UNIT_TEST(include_exclude) { roster_t roster; setup(roster); @@ -782,7 +782,7 @@ UNIT_TEST(restrictions, include_exclude) UNIT_TEST_CHECK(!pmask.includes(fp_yyg)); } -UNIT_TEST(restrictions, exclude_include) +UNIT_TEST(exclude_include) { roster_t roster; setup(roster); @@ -857,7 +857,7 @@ UNIT_TEST(restrictions, exclude_include) UNIT_TEST_CHECK( pmask.includes(fp_yyg)); } -UNIT_TEST(restrictions, invalid_roster_paths) +UNIT_TEST(invalid_roster_paths) { roster_t roster; setup(roster); @@ -870,7 +870,7 @@ UNIT_TEST(restrictions, invalid_roster_p recoverable_failure); } -UNIT_TEST(restrictions, invalid_workspace_paths) +UNIT_TEST(invalid_workspace_paths) { roster_t roster; setup(roster); @@ -883,7 +883,7 @@ UNIT_TEST(restrictions, invalid_workspac recoverable_failure); } -UNIT_TEST(restrictions, ignored_invalid_workspace_paths) +UNIT_TEST(ignored_invalid_workspace_paths) { roster_t roster; setup(roster); @@ -899,7 +899,7 @@ UNIT_TEST(restrictions, ignored_invalid_ UNIT_TEST_CHECK(!pmask.includes(file_path_internal("bar"))); } -UNIT_TEST(restrictions, include_depth_0) +UNIT_TEST(include_depth_0) { roster_t roster; setup(roster); @@ -971,7 +971,7 @@ UNIT_TEST(restrictions, include_depth_0) UNIT_TEST_CHECK(!pmask.includes(fp_yyg)); } -UNIT_TEST(restrictions, include_depth_1) +UNIT_TEST(include_depth_1) { roster_t roster; setup(roster); @@ -1043,7 +1043,7 @@ UNIT_TEST(restrictions, include_depth_1) UNIT_TEST_CHECK(!pmask.includes(fp_yyg)); } -UNIT_TEST(restrictions, include_depth_1_empty_restriction) +UNIT_TEST(include_depth_1_empty_restriction) { roster_t roster; setup(roster); @@ -1113,7 +1113,7 @@ UNIT_TEST(restrictions, include_depth_1_ UNIT_TEST_CHECK(!pmask.includes(fp_yyg)); } -UNIT_TEST(restrictions, include_depth_2) +UNIT_TEST(include_depth_2) { roster_t roster; setup(roster); ============================================================ --- rev_height.cc 7330d685fb6f60b4425d2e9f6be2211c2785eb71 +++ rev_height.cc 969598a29a3f000321f2f5f7ee2989659606f69e @@ -120,7 +120,7 @@ void dump(rev_height const & h, string & #include "unit_tests.hh" #include "randomizer.hh" -UNIT_TEST(rev_height, count_up) +UNIT_TEST(count_up) { rev_height h = rev_height::root_height().child_height(1); @@ -139,7 +139,7 @@ UNIT_TEST(rev_height, count_up) } } -UNIT_TEST(rev_height, children) +UNIT_TEST(children) { rev_height h; I(!h.valid()); @@ -197,7 +197,7 @@ UNIT_TEST(rev_height, children) } } -UNIT_TEST(rev_height, comparisons) +UNIT_TEST(comparisons) { rev_height root(rev_height::root_height()); rev_height left(root.child_height(0)); ============================================================ --- revision.cc 5b5f6c11cf218a22285d6939f14a1d5d64d3e482 +++ revision.cc a5aaa29e0e5aaff3f87ee342d20c360fc69f96f3 @@ -458,7 +458,7 @@ void calculate_ident(revision_t const & #include "unit_tests.hh" #include "lexical_cast.hh" -UNIT_TEST(revision, from_network) +UNIT_TEST(from_network) { char const * bad_revisions[] = { "", ============================================================ --- roster.cc fdcabef3294b34d9816a3da0d2da8e2d90befdb2 +++ roster.cc 0269cfb8f735ac17f0d07f7c7685ba5d5e911f21 @@ -3184,7 +3184,7 @@ dump(int const & i, string & out) out = lexical_cast(i) + "\n"; } -UNIT_TEST(roster, random_actions) +UNIT_TEST(random_actions) { randomizer rng; roster_t r; @@ -3294,7 +3294,7 @@ check_sane_roster_do_tests(int to_run, i #undef MAYBE -UNIT_TEST(roster, check_sane_roster) +UNIT_TEST(check_sane_roster) { int total; check_sane_roster_do_tests(-1, total); @@ -3306,7 +3306,7 @@ UNIT_TEST(roster, check_sane_roster) } } -UNIT_TEST(roster, check_sane_roster_loop) +UNIT_TEST(check_sane_roster_loop) { testing_node_id_source nis; roster_t r; MM(r); @@ -3319,7 +3319,7 @@ UNIT_TEST(roster, check_sane_roster_loop UNIT_TEST_CHECK_THROW(r.check_sane(true), logic_error); } -UNIT_TEST(roster, check_sane_roster_screwy_dir_map) +UNIT_TEST(check_sane_roster_screwy_dir_map) { testing_node_id_source nis; roster_t r; MM(r); @@ -3344,7 +3344,7 @@ UNIT_TEST(roster, check_sane_roster_scre UNIT_TEST_CHECK_THROW(r.check_sane(), logic_error); } -UNIT_TEST(roster, bad_attr) +UNIT_TEST(bad_attr) { testing_node_id_source nis; roster_t r; MM(r); @@ -4051,7 +4051,7 @@ run_a_0_scalar_parent_mark_scenario() // These functions contain the actual list of *-merge cases that we would like // to test. -UNIT_TEST(roster, all_0_scalar_parent_mark_scenarios) +UNIT_TEST(all_0_scalar_parent_mark_scenarios) { L(FL("TEST: begin checking 0-parent marking")); // a* @@ -4059,7 +4059,7 @@ UNIT_TEST(roster, all_0_scalar_parent_ma L(FL("TEST: end checking 0-parent marking")); } -UNIT_TEST(roster, all_1_scalar_parent_mark_scenarios) +UNIT_TEST(all_1_scalar_parent_mark_scenarios) { L(FL("TEST: begin checking 1-parent marking")); // a @@ -4099,7 +4099,7 @@ UNIT_TEST(roster, all_1_scalar_parent_ma L(FL("TEST: end checking 1-parent marking")); } -UNIT_TEST(roster, all_2_scalar_parent_mark_scenarios) +UNIT_TEST(all_2_scalar_parent_mark_scenarios) { L(FL("TEST: begin checking 2-parent marking")); /////////////////////////////////////////////////////////////////// @@ -4273,7 +4273,7 @@ namespace }; } -UNIT_TEST(roster, residual_attr_mark_scenario) +UNIT_TEST(residual_attr_mark_scenario) { L(FL("TEST: begin checking residual attr marking case")); { @@ -4324,7 +4324,7 @@ UNIT_TEST(roster, residual_attr_mark_sce //////////////////////////////////////////////////////////////////////// // nodes can't survive dying on one side of a merge -UNIT_TEST(roster, die_die_die_merge) +UNIT_TEST(die_die_die_merge) { roster_t left_roster; MM(left_roster); marking_map left_markings; MM(left_markings); @@ -4383,7 +4383,7 @@ UNIT_TEST(roster, die_die_die_merge) // merging a file and a dir with the same nid and no mention of what should // happen to them fails -UNIT_TEST(roster, same_nid_diff_type) +UNIT_TEST(same_nid_diff_type) { randomizer rng; testing_node_id_source nis; @@ -4443,7 +4443,7 @@ UNIT_TEST(roster, same_nid_diff_type) } -UNIT_TEST(roster, write_roster) +UNIT_TEST(write_roster) { L(FL("TEST: write_roster_test")); roster_t r; MM(r); @@ -4594,7 +4594,7 @@ UNIT_TEST(roster, write_roster) } } -UNIT_TEST(roster, check_sane_against) +UNIT_TEST(check_sane_against) { testing_node_id_source nis; file_path root; @@ -4881,7 +4881,7 @@ unify_rosters_randomized_core(node_id_so } } -UNIT_TEST(roster, unify_rosters_randomized_trueids) +UNIT_TEST(unify_rosters_randomized_trueids) { L(FL("TEST: begin checking unification of rosters (randomly, true IDs)")); temp_node_id_source tmp_nis; @@ -4890,7 +4890,7 @@ UNIT_TEST(roster, unify_rosters_randomiz L(FL("TEST: end checking unification of rosters (randomly, true IDs)")); } -UNIT_TEST(roster, unify_rosters_randomized_tempids) +UNIT_TEST(unify_rosters_randomized_tempids) { L(FL("TEST: begin checking unification of rosters (randomly, temp IDs)")); temp_node_id_source tmp_nis; @@ -4898,7 +4898,7 @@ UNIT_TEST(roster, unify_rosters_randomiz L(FL("TEST: end checking unification of rosters (randomly, temp IDs)")); } -UNIT_TEST(roster, unify_rosters_end_to_end_ids) +UNIT_TEST(unify_rosters_end_to_end_ids) { L(FL("TEST: begin checking unification of rosters (end to end, ids)")); revision_id has_rid = left_rid; @@ -4978,7 +4978,7 @@ UNIT_TEST(roster, unify_rosters_end_to_e L(FL("TEST: end checking unification of rosters (end to end, ids)")); } -UNIT_TEST(roster, unify_rosters_end_to_end_attr_corpses) +UNIT_TEST(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; ============================================================ --- simplestring_xform.cc 9ee64085fd6badec5b1ff9a25bab8cee8b169f8f +++ simplestring_xform.cc 59186652c6b6835b7e2e6b113f3d976a9ed62e1d @@ -237,7 +237,7 @@ trim(string const & s, string const & ch #include "unit_tests.hh" #include "vocab.hh" -UNIT_TEST(simplestring_xform, caseconv) +UNIT_TEST(caseconv) { UNIT_TEST_CHECK(uppercase("hello") == "HELLO"); UNIT_TEST_CHECK(uppercase("heLlO") == "HELLO"); @@ -247,7 +247,7 @@ UNIT_TEST(simplestring_xform, caseconv) UNIT_TEST_CHECK(lowercase("address@hidden&*()") == "address@hidden&*()"); } -UNIT_TEST(simplestring_xform, join_lines) +UNIT_TEST(join_lines) { vector strs; string joined; @@ -269,7 +269,7 @@ UNIT_TEST(simplestring_xform, join_lines UNIT_TEST_CHECK(joined == "hi\nthere\nuser\n"); } -UNIT_TEST(simplestring_xform, join_words) +UNIT_TEST(join_words) { vector< utf8 > v; set< utf8 > s; @@ -314,7 +314,7 @@ UNIT_TEST(simplestring_xform, join_words UNIT_TEST_CHECK(join_words(s, ", ")() == "a, b, c"); } -UNIT_TEST(simplestring_xform, split_into_words) +UNIT_TEST(split_into_words) { vector< utf8 > words; @@ -339,7 +339,7 @@ UNIT_TEST(simplestring_xform, split_into UNIT_TEST_CHECK(words[2]() == "bar"); } -UNIT_TEST(simplestring_xform, trimming) +UNIT_TEST(trimming) { UNIT_TEST_CHECK(trim_right(":foobar:", ":") == ":foobar"); UNIT_TEST_CHECK(trim_left(":foobar:", ":") == "foobar:"); ============================================================ --- string_queue.cc 39f987fc625eb0f43ba86c794b40ad008fc5114e +++ string_queue.cc 429a21cfa853ab702bf10ceca34622c3e4f08525 @@ -10,7 +10,7 @@ using std::logic_error; using std::logic_error; -UNIT_TEST(string_queue, string_queue) +UNIT_TEST(string_queue) { string_queue sq1; ============================================================ --- transforms.cc 21d1f172b5413b4123358f3c44135b6cd44ae5d5 +++ transforms.cc bdc3fdae1172a62a2cbb6f1cfdb84826786762b9 @@ -295,7 +295,7 @@ calculate_ident(revision_data const & da #include "unit_tests.hh" #include -UNIT_TEST(transform, enc) +UNIT_TEST(enc) { data d2, d1("the rain in spain"); gzip gzd1, gzd2; @@ -308,7 +308,7 @@ UNIT_TEST(transform, enc) UNIT_TEST_CHECK(d2 == d1); } -UNIT_TEST(transform, calculate_ident) +UNIT_TEST(calculate_ident) { data input(string("the only blender which can be turned into the most powerful vaccum cleaner"), origin::internal); @@ -318,7 +318,7 @@ UNIT_TEST(transform, calculate_ident) UNIT_TEST_CHECK(output() == decode_hexenc(ident, origin::internal)); } -UNIT_TEST(transform, corruption_check) +UNIT_TEST(corruption_check) { data input(string("i'm so fragile, fragile when you're here"), origin::internal); gzip gzd; ============================================================ --- unit_tests.cc 475fa100e0921123927e14b005c6d83735057980 +++ unit_tester.cc 74c09bbe54bf1b4d94a68f6ee5b0e8ba23dff0cb @@ -37,7 +37,7 @@ typedef unit_test::unit_test_case test_t using std::exit; typedef unit_test::unit_test_case test_t; -typedef map test_list_t; +typedef map test_list_t; typedef map group_list_t; // This is used by other global constructors, so initialize on demand. @@ -47,18 +47,35 @@ static group_list_t & unit_tests() return tests; } -unit_test::unit_test_case::unit_test_case(char const * group, - char const * name, - void (*func)(), +// this is effectively basename(), but has no dependencies on +// e.g. system_path being usable yet. The special-case for 'fis' +// ensures that the unit tests of the unit tester itself will be +// run first (see below). +static string +extract_group(char const *filename, bool fis) +{ + string result(filename); + string::size_type last_slash = result.find_last_of("/\\"); + if (last_slash != string::npos) + result.erase(0, last_slash+1); + string::size_type first_dot = result.find_first_of('.'); + if (first_dot != string::npos) + result.erase(first_dot, string::npos); + if (fis) + result.insert(0, 1, '_'); + return result; +} + +unit_test::unit_test_case::unit_test_case(char const * g, + char const * n, + void (*f)(), bool fis) - : group(group), name(name), func(func), failure_is_success(fis) + : group(extract_group(g, fis)), name(n), func(f), failure_is_success(fis) { - unit_tests()[group][name] = *this; + // All unit_test_case objects are statically allocated so this is safe. + unit_tests()[group][name] = this; } -unit_test::unit_test_case::unit_test_case() -{} - // Test state. static bool this_test_failed = false; @@ -247,7 +264,7 @@ int main(int argc, char * argv[]) try { - t->second.func(); + t->second->func(); } catch(require_failed &) { @@ -264,7 +281,7 @@ int main(int argc, char * argv[]) this_test_failed = true; } - if (this_test_failed && !t->second.failure_is_success) + if (this_test_failed && !t->second->failure_is_success) { L(FL("Test %s:%s failed.\n") % group % test); return 1; @@ -302,51 +319,51 @@ sanity & global_sanity = real_sanity; // into a success. Since we don't want that mechanism used elsewhere, // the necessary definition macro is defined here and not in unit_test.hh. -#define NEGATIVE_UNIT_TEST(GROUP, TEST) \ - namespace unit_test { \ - static void t_##GROUP##_##TEST(); \ - static unit_test_case r_##GROUP##_##TEST \ - (#GROUP, #TEST, t_##GROUP##_##TEST, true); \ - } \ - static void unit_test::t_##GROUP##_##TEST() +#define NEGATIVE_UNIT_TEST(TEST) \ + namespace unit_test { \ + static void t_##TEST(); \ + static const unit_test_case r_##TEST \ + (__FILE__, #TEST, t_##TEST, true); \ + } \ + static void unit_test::t_##TEST() #include -NEGATIVE_UNIT_TEST(_unit_tester, fail_check) +NEGATIVE_UNIT_TEST(fail_check) { UNIT_TEST_CHECKPOINT("checkpoint"); UNIT_TEST_CHECK(false); UNIT_TEST_CHECK(false); } -NEGATIVE_UNIT_TEST(_unit_tester, fail_require) +NEGATIVE_UNIT_TEST(fail_require) { UNIT_TEST_CHECKPOINT("checkpoint"); UNIT_TEST_REQUIRE(false); UNIT_TEST_CHECK(false); } -NEGATIVE_UNIT_TEST(_unit_tester, fail_throw) +NEGATIVE_UNIT_TEST(fail_throw) { UNIT_TEST_CHECK_THROW(string().size(), int); } -NEGATIVE_UNIT_TEST(_unit_tester, fail_nothrow) +NEGATIVE_UNIT_TEST(fail_nothrow) { UNIT_TEST_CHECK_NOT_THROW(throw int(), int); } -NEGATIVE_UNIT_TEST(_unit_tester, uncaught) +NEGATIVE_UNIT_TEST(uncaught) { throw int(); } -NEGATIVE_UNIT_TEST(_unit_tester, uncaught_std) +NEGATIVE_UNIT_TEST(uncaught_std) { throw std::bad_exception(); } -NEGATIVE_UNIT_TEST(_unit_tester, uncaught_std_what) +NEGATIVE_UNIT_TEST(uncaught_std_what) { throw std::runtime_error("There is no spoon."); } ============================================================ --- unit_tests.hh bdedb58135c3943f535e60efeb81f93c79e4e153 +++ unit_tests.hh 48d2f3e88792009a1f883da4e7d7926b802fd016 @@ -10,6 +10,8 @@ // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. +#include + // Log a success/failure message, and set the test state to 'fail' if needed #define UNIT_TEST_CHECK(expression) \ unit_test::do_check(expression, __FILE__, __LINE__, #expression) @@ -70,17 +72,16 @@ namespace unit_test { // Declarative mechanism for specifying unit tests, similar to // auto_unit_test in boost, but more suited to our needs. - struct unit_test_case + struct unit_test_case : boost::noncopyable { - char const *group; - char const *name; - void (*func)(); - bool failure_is_success; + std::string const group; + std::string const name; + void (*const func)(); + bool const failure_is_success; unit_test_case(char const * group, char const * name, void (*func)(), bool fis); - unit_test_case(); }; } @@ -88,13 +89,13 @@ namespace unit_test { // 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, false); \ - } \ - static void unit_test::t_##GROUP##_##TEST() +#define UNIT_TEST(TEST) \ + namespace unit_test { \ + static void t_##TEST(); \ + static const unit_test_case r_##TEST \ + (__FILE__, #TEST, t_##TEST, false); \ + } \ + static void unit_test::t_##TEST() // Local Variables: // mode: C++ ============================================================ --- uri.cc 73f93c410b9e5dc395c15141b9f2fe8dbd73c3c0 +++ uri.cc 877def8f4bf7ae30a933c338aafdf1e8528c6660 @@ -294,7 +294,7 @@ test_one_uri(string scheme, UNIT_TEST_CHECK(u.fragment == fragment); } -UNIT_TEST(uri, basic) +UNIT_TEST(basic) { test_one_uri("ssh", "graydon", "", "venge.net", "22", "/tmp/foo.mtn", "", ""); test_one_uri("ssh", "graydon", "", "venge.net", "", "/tmp/foo.mtn", "", ""); @@ -308,7 +308,7 @@ UNIT_TEST(uri, basic) test_one_uri("http", "graydon", "fe:00:01::04:21", "", "8080", "/foo.cgi", "branch=foo", "tip"); } -UNIT_TEST(uri, bizarre) +UNIT_TEST(bizarre) { test_one_uri("", "graydon", "", "venge.net", "22", "/tmp/foo.mtn", "", ""); test_one_uri("", "", "", "", "", "/address@hidden:22/tmp/foo.mtn", "", ""); @@ -316,7 +316,7 @@ UNIT_TEST(uri, bizarre) test_one_uri("ssh", "", "", "", "", "/address@hidden:22/tmp/foo.mtn", "", ""); } -UNIT_TEST(uri, invalid) +UNIT_TEST(invalid) { uri u; @@ -325,7 +325,7 @@ UNIT_TEST(uri, invalid) UNIT_TEST_CHECK_THROW(parse_uri("http://example.com:1a4/foo/bar", u, origin::user), recoverable_failure); } -UNIT_TEST(uri, urldecode) +UNIT_TEST(urldecode) { UNIT_TEST_CHECK(urldecode("foo%20bar", origin::internal) == "foo bar"); UNIT_TEST_CHECK(urldecode("%61", origin::user) == "a"); ============================================================ --- vocab.cc bb503a780573812673e29b185737947f2a189d95 +++ vocab.cc 444f8540bc0b585cdbb6d592799febeba88c4978 @@ -222,7 +222,7 @@ void dump (id const & obj, std::string & #include "unit_tests.hh" -UNIT_TEST(vocab, verify_hexenc_id) +UNIT_TEST(verify_hexenc_id) { // -------- magic empty string and default constructor are okay: UNIT_TEST_CHECK(hexenc("")() == ""); ============================================================ --- xdelta.cc 3bfd03cf01ed8e07764ce268820407d13a583c22 +++ xdelta.cc 85f1764bd00be13dc46f9305b582ec975c08472e @@ -823,7 +823,7 @@ invert_xdelta(string const & old_str, #include "unit_tests.hh" -UNIT_TEST(xdelta, basic) +UNIT_TEST(basic) { data dat1(string("the first day of spring\nmakes me want to sing\n"), origin::internal); @@ -876,7 +876,7 @@ spin(string a, string b) UNIT_TEST_CHECK(b == apply_via_piecewise(a, ba_inverted)); } -UNIT_TEST(xdelta, simple_cases) +UNIT_TEST(simple_cases) { L(FL("empty/empty")); spin("", ""); @@ -971,7 +971,7 @@ xdelta_randomly_delete(string & str) } } -UNIT_TEST(xdelta, random_simple_delta) +UNIT_TEST(random_simple_delta) { for (int i = 0; i < 100; ++i) { @@ -985,7 +985,7 @@ UNIT_TEST(xdelta, random_simple_delta) } } -UNIT_TEST(xdelta, random_piecewise_delta) +UNIT_TEST(random_piecewise_delta) { for (int i = 0; i < 50; ++i) { @@ -1012,7 +1012,7 @@ UNIT_TEST(xdelta, random_piecewise_delta } } -UNIT_TEST(xdelta, rolling_sanity_check) +UNIT_TEST(rolling_sanity_check) { const unsigned testbufsize = 512; static const string::size_type blocksz = 64;