From 29ba7388762b9650d1953e3fc82852259a2e7735 Mon Sep 17 00:00:00 2001 From: Steven Siloti Date: Mon, 10 Aug 2015 20:05:04 -0700 Subject: [PATCH 1/2] fix_dht mutable get test --- test/test_dht.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test_dht.cpp b/test/test_dht.cpp index f256bddcc..b1a438ce6 100644 --- a/test/test_dht.cpp +++ b/test/test_dht.cpp @@ -408,6 +408,8 @@ int g_put_count; bool get_item_cb(dht::item& i, bool a) { + // only count authoritative data + if (!a) return false; if (!i.empty()) g_got_items.push_back(i); if (!g_put_item.empty()) From 2d9cf0f8b3cabf2f7bdf1d1fc61d113d9a91537f Mon Sep 17 00:00:00 2001 From: Steven Siloti Date: Mon, 10 Aug 2015 20:05:16 -0700 Subject: [PATCH 2/2] use test_name rather than __LINE__ for hidden test structs When building tests from mutliple files together, the line number the test is declared on is not guaranteed to be unique. If two tests happen to be on the same line, one of them will not be run. You will then go crazy trying to figure out why seemingly unrelated changes make the problem go away. --- test/test.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test.hpp b/test/test.hpp index 5eb14e2df..f9751e918 100644 --- a/test/test.hpp +++ b/test/test.hpp @@ -88,8 +88,8 @@ extern int EXPORT _g_test_failures; #define TORRENT_TEST(test_name) \ static void BOOST_PP_CAT(unit_test_, test_name)(); \ - static struct BOOST_PP_CAT(register_class, __LINE__) { \ - BOOST_PP_CAT(register_class, __LINE__) () { \ + static struct BOOST_PP_CAT(register_class_, test_name) { \ + BOOST_PP_CAT(register_class_, test_name) () { \ unit_test_t& t = _g_unit_tests[_g_num_unit_tests]; \ t.fun = &BOOST_PP_CAT(unit_test_, test_name); \ t.name = __FILE__ "." #test_name; \ @@ -98,7 +98,7 @@ extern int EXPORT _g_test_failures; t.output = NULL; \ _g_num_unit_tests++; \ } \ - } BOOST_PP_CAT(_static_registrar, __LINE__); \ + } BOOST_PP_CAT(_static_registrar_, test_name); \ static void BOOST_PP_CAT(unit_test_, test_name)() #define TEST_REPORT_AUX(x, line, file) \