This is an automated email from the ASF dual-hosted git repository. bneradt pushed a commit to branch SolidWallOfCode-patch-1 in repository https://gitbox.apache.org/repos/asf/trafficserver-libswoc.git
commit f1d58d0ea9cec9e8ab44779061d156b56f58e705 Author: Alan M. Carroll <[email protected]> AuthorDate: Fri Sep 25 16:04:25 2020 -0500 Fix testing build errors in Errata. --- code/include/swoc/DiscreteRange.h | 2 +- code/include/swoc/Errata.h | 4 ++++ unit_tests/ex_Lexicon.cc | 1 + unit_tests/test_Errata.cc | 7 +++++-- unit_tests/test_Lexicon.cc | 4 +++- unit_tests/test_ip.cc | 12 ++++++++++++ 6 files changed, 26 insertions(+), 4 deletions(-) diff --git a/code/include/swoc/DiscreteRange.h b/code/include/swoc/DiscreteRange.h index 6e2494d..2835154 100644 --- a/code/include/swoc/DiscreteRange.h +++ b/code/include/swoc/DiscreteRange.h @@ -1267,7 +1267,7 @@ DiscreteSpace<METRIC, PAYLOAD>::blend(DiscreteSpace::range_type const& range, U , F&& blender) -> self_type& { // Do a base check for the color to use on unmapped values. If self blending on @a color // is @c false, then do not color currently unmapped values. - PAYLOAD plain_color; // color to paint uncolored metrics. + [[maybe_unused]] PAYLOAD plain_color{}; // color to paint uncolored metrics. bool plain_color_p = blender(plain_color, color); // start with default and blend in @a color. auto node_cleaner = [&](Node *ptr) -> void { _fa.destroy(ptr); }; diff --git a/code/include/swoc/Errata.h b/code/include/swoc/Errata.h index 95fe32e..334c254 100644 --- a/code/include/swoc/Errata.h +++ b/code/include/swoc/Errata.h @@ -955,3 +955,7 @@ get(swoc::Rv<R> const& rv) { } }} // namespace swoc + +namespace std { + using swoc::get; // Import specialized overloads to standard namespace. +} diff --git a/unit_tests/ex_Lexicon.cc b/unit_tests/ex_Lexicon.cc index 34281a7..25c319f 100644 --- a/unit_tests/ex_Lexicon.cc +++ b/unit_tests/ex_Lexicon.cc @@ -88,6 +88,7 @@ TEST_CASE("Lexicon Example", "[libts][Lexicon]") { // doc.lookup.begin auto && [ range, flags ] = *space.find(addr); // doc.lookup.end + static_cast<void>(range); REQUIRE(flags == bits); } // doc.lookup.end diff --git a/unit_tests/test_Errata.cc b/unit_tests/test_Errata.cc index 088f93a..28bd22b 100644 --- a/unit_tests/test_Errata.cc +++ b/unit_tests/test_Errata.cc @@ -102,6 +102,7 @@ TEST_CASE("Rv", "[libswoc][Errata]") REQUIRE(result == 17); // Local copy binding, no update. auto &[r_result, r_erratum] = zret; + REQUIRE(r_erratum.is_ok() == false); REQUIRE(r_result == 38); zret = 56; @@ -109,10 +110,11 @@ TEST_CASE("Rv", "[libswoc][Errata]") auto const &[cr_result, cr_erratum] = zret; REQUIRE(cr_result == 56); + REQUIRE(cr_erratum.is_ok() == false); auto test = [](Rv<int> const &rvc) { - auto const &[cv_result, cv_erratum] = rvc; - REQUIRE(cv_result == 56); + auto n = std::get<0>(rvc); + REQUIRE(n == 56); }; test(zret); // invoke it. @@ -142,4 +144,5 @@ TEST_CASE("Rv", "[libswoc][Errata]") auto &&[tr2, te2]{maker()}; REQUIRE(tr2->s == "made"sv); + REQUIRE(te2.is_ok() == true); }; diff --git a/unit_tests/test_Lexicon.cc b/unit_tests/test_Lexicon.cc index a72bd72..95aaeed 100644 --- a/unit_tests/test_Lexicon.cc +++ b/unit_tests/test_Lexicon.cc @@ -72,7 +72,9 @@ TEST_CASE("Lexicon", "[libts][Lexicon]") {Radio::DELTA, {"Delta"}}}); // test structured binding for iteration. - for ([[maybe_unused]] auto const &[key, name] : lex) { + for (auto const &[key, name] : lex) { + static_cast<void>(key); + static_cast<void>(name); } }; diff --git a/unit_tests/test_ip.cc b/unit_tests/test_ip.cc index ba81bc6..2195a61 100644 --- a/unit_tests/test_ip.cc +++ b/unit_tests/test_ip.cc @@ -756,6 +756,7 @@ TEST_CASE("IP Space Int", "[libswoc][ip][ipspace]") { // Verify that earlier ranges are still valid after the double blend. for (auto &&[text, value] : r2) { IPRange range{text}; + static_cast<void>(value); REQUIRE(space.end() != space.find(range.min())); REQUIRE(space.end() != space.find(range.max())); } @@ -765,6 +766,7 @@ TEST_CASE("IP Space Int", "[libswoc][ip][ipspace]") { // Verify all the data is in the ranges. for (auto &&[text, value] : r2) { IPRange range{text}; + static_cast<void>(value); REQUIRE(space.end() != space.find(range.min())); REQUIRE(space.end() != space.find(range.max())); } @@ -777,6 +779,7 @@ TEST_CASE("IP Space Int", "[libswoc][ip][ipspace]") { } { auto && [ r, p ] = *space.find(IPAddr{"2001:4997:58:400::1E"}); + static_cast<void>(p); REQUIRE(true == r.empty()); } } @@ -808,8 +811,10 @@ TEST_CASE("IPSpace bitset", "[libswoc][ipspace][bitset]") { // Check that if an IPv4 lookup misses, it doesn't pass on to the first IPv6 auto && [ r1, p1 ] = *(space.find(IP4Addr{"172.28.56.100"})); + static_cast<void>(p1); REQUIRE(true == r1.empty()); auto && [ r2, p2 ] = *(space.find(IPAddr{"172.28.56.100"})); + static_cast<void>(p2); REQUIRE(true == r2.empty()); } @@ -864,6 +869,7 @@ TEST_CASE("IPSpace docJJ", "[libswoc][ipspace][docJJ]") { idx = 0; for (auto const&[range, bits] : space) { + static_cast<void>(range); REQUIRE(idx < results.size()); CHECK(bits == make_bits(results[idx])); ++idx; @@ -872,6 +878,7 @@ TEST_CASE("IPSpace docJJ", "[libswoc][ipspace][docJJ]") { idx = results.size(); for (auto spot = space.end(); spot != space.begin();) { auto const&[range, bits]{*--spot}; + static_cast<void>(range); REQUIRE(idx > 0); --idx; CHECK(bits == make_bits(results[idx])); @@ -885,6 +892,7 @@ TEST_CASE("IPSpace docJJ", "[libswoc][ipspace][docJJ]") { for (auto spot = space.begin(); spot != space.end() ; ++spot) { iter = spot; std::tie(range, bits) = *iter; + static_cast<void>(range); REQUIRE(idx < results.size()); CHECK(bits == make_bits(results[idx])); ++idx; @@ -1500,10 +1508,14 @@ TEST_CASE("IPSpace Uthira", "[libswoc][ipspace][uthira]") { auto spot = space.begin(); auto [ r1, p1 ] = *++spot; auto [ r2, p2 ] = *++spot; + static_cast<void>(p1); + static_cast<void>(p2); REQUIRE(r1.max() < r2.min()); // This is supposed to be an invariant! Make sure. auto back = space.end(); auto [ br1, bp1 ] = *--back; auto [ br2, bp2 ] = *--back; + static_cast<void>(bp1); + static_cast<void>(bp2); REQUIRE(br2.max() < br1.min()); // This is supposed to be an invariant! Make sure. } }
