From c148f52a4864da94e2b11c3b201b00fca3cc3c8a Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Sun, 2 Jan 2022 13:39:45 -0500 Subject: [PATCH 1/3] Fix a couple of `-Wreturn-type` warnings in tests. NFC. --- tests/bases.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/bases.cpp b/tests/bases.cpp index 7189307..0055801 100644 --- a/tests/bases.cpp +++ b/tests/bases.cpp @@ -37,11 +37,11 @@ TEST_CASE("Triviality", "[bases.triviality]") { { struct T { - T(const T&){} - T(T&&) {}; - T& operator=(const T&) {} - T& operator=(T&&) {}; - ~T(){} + T(const T&) {} + T(T&&) {} + T& operator=(const T&) { return *this; } + T& operator=(T&&) { return *this; } + ~T() {} }; REQUIRE(!std::is_trivially_copy_constructible>::value); REQUIRE(!std::is_trivially_copy_assignable>::value); From 1ea24d876eba203349e44575d05679f5830a1703 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Sun, 2 Jan 2022 13:43:06 -0500 Subject: [PATCH 2/3] Fix `-Wunused-parameter` warnings in tests. NFC. --- tests/extensions.cpp | 18 ++++++++---------- tests/issues.cpp | 4 ++-- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/tests/extensions.cpp b/tests/extensions.cpp index 9670f90..2d1d3a1 100644 --- a/tests/extensions.cpp +++ b/tests/extensions.cpp @@ -9,7 +9,7 @@ TEST_CASE("Map extensions", "[extensions.map]") { auto mul2 = [](int a) { return a * 2; }; - auto ret_void = [](int a) {}; + auto ret_void = [](int) {}; { tl::expected e = 21; @@ -143,7 +143,7 @@ TEST_CASE("Map extensions", "[extensions.map]") { TEST_CASE("Map error extensions", "[extensions.map_error]") { auto mul2 = [](int a) { return a * 2; }; - auto ret_void = [](int a) {}; + auto ret_void = [](int) {}; { tl::expected e = 21; @@ -252,8 +252,8 @@ TEST_CASE("Map error extensions", "[extensions.map_error]") { } TEST_CASE("And then extensions", "[extensions.and_then]") { - auto succeed = [](int a) { return tl::expected(21 * 2); }; - auto fail = [](int a) { return tl::expected(tl::unexpect, 17); }; + auto succeed = [](int) { return tl::expected(21 * 2); }; + auto fail = [](int) { return tl::expected(tl::unexpect, 17); }; { tl::expected e = 21; @@ -370,9 +370,9 @@ TEST_CASE("And then extensions", "[extensions.and_then]") { TEST_CASE("or_else", "[extensions.or_else]") { using eptr = std::unique_ptr; - auto succeed = [](int a) { return tl::expected(21 * 2); }; - auto succeedptr = [](eptr e) { return tl::expected(21*2);}; - auto fail = [](int a) { return tl::expected(tl::unexpect, 17);}; + auto succeed = [](int) { return tl::expected(21 * 2); }; + auto succeedptr = [](eptr) { return tl::expected(21*2);}; + auto fail = [](int) { return tl::expected(tl::unexpect, 17);}; auto efail = [](eptr e) { *e = 17;return tl::expected(tl::unexpect, std::move(e));}; auto failptr = [](eptr e) { return tl::expected(tl::unexpect, std::move(e));}; auto failvoid = [](int) {}; @@ -568,9 +568,7 @@ struct F { TEST_CASE("14", "[issue.14]") { auto res = tl::expected{tl::unexpect, F{}}; - res.map_error([](F f) { - - }); + res.map_error([](F) {}); } TEST_CASE("32", "[issue.32]") { diff --git a/tests/issues.cpp b/tests/issues.cpp index e9f99da..ec60bde 100644 --- a/tests/issues.cpp +++ b/tests/issues.cpp @@ -15,7 +15,7 @@ TEST_CASE("Issue 1", "[issues.1]") { getInt1(); } tl::expected operation1() { return 42; } -tl::expected operation2(int const val) { return "Bananas"; } +tl::expected operation2(int) { return "Bananas"; } TEST_CASE("Issue 17", "[issues.17]") { auto const intermediate_result = operation1(); @@ -77,7 +77,7 @@ TEST_CASE("Issue 31", "[issues.31]") { TEST_CASE("Issue 33", "[issues.33]") { tl::expected res {tl::unexpect, 0}; REQUIRE(!res); - res = res.map_error([](int i) { return 42; }); + res = res.map_error([](int) { return 42; }); REQUIRE(res.error() == 42); } From 2bca148e86ce9adad49f383a0d41f5a61b36d498 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Sun, 2 Jan 2022 14:31:36 -0500 Subject: [PATCH 3/3] Fix a `-Wunused-value` warning in a test. NFC. --- tests/issues.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/issues.cpp b/tests/issues.cpp index ec60bde..3c366e5 100644 --- a/tests/issues.cpp +++ b/tests/issues.cpp @@ -67,7 +67,7 @@ struct i31{ }; TEST_CASE("Issue 31", "[issues.31]") { const tl::expected a = i31{42}; - a->i; + (void) a->i; tl::expected< void, std::string > result; tl::expected< void, std::string > result2 = result;