forked from TartanLlama/expected
Fix warnings in test (#92)
* Convert tabs to spaces * Remove extra semicolons in test * Fix warnings in test -Wreturn-type -Wunused-parameter -Wunused-value * Fix -Wunused-variable warning in test The variable 'failptr' is unused. From looking at the other variables in the test case, it seems the fix is to first remove 'failptr' and then rename 'efail' to 'failptr'. * Fix -Wunused-variable warning in test * Fix -Wmacro-redefined warning in test STATIC_REQUIRE has a previous definition in catch2/catch.hpp.
This commit is contained in:
@@ -825,7 +825,7 @@ struct expected_operations_base : expected_storage_base<T, E> {
|
||||
if (rhs.m_has_val) {
|
||||
get() = std::forward<Rhs>(rhs).get();
|
||||
} else {
|
||||
destroy_val();
|
||||
destroy_val();
|
||||
construct_error(std::forward<Rhs>(rhs).geterr());
|
||||
}
|
||||
} else {
|
||||
@@ -858,7 +858,7 @@ struct expected_operations_base : expected_storage_base<T, E> {
|
||||
#endif
|
||||
|
||||
TL_EXPECTED_11_CONSTEXPR void destroy_val() {
|
||||
get().~T();
|
||||
get().~T();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -913,7 +913,7 @@ struct expected_operations_base<void, E> : expected_storage_base<void, E> {
|
||||
#endif
|
||||
|
||||
TL_EXPECTED_11_CONSTEXPR void destroy_val() {
|
||||
//no-op
|
||||
//no-op
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -38,9 +38,9 @@ TEST_CASE("Triviality", "[bases.triviality]") {
|
||||
{
|
||||
struct T {
|
||||
T(const T&){}
|
||||
T(T&&) {};
|
||||
T& operator=(const T&) {}
|
||||
T& operator=(T&&) {};
|
||||
T(T&&) {}
|
||||
T& operator=(const T&) { return *this; }
|
||||
T& operator=(T&&) { return *this; }
|
||||
~T(){}
|
||||
};
|
||||
REQUIRE(!std::is_trivially_copy_constructible<tl::expected<T,int>>::value);
|
||||
|
@@ -3,13 +3,15 @@
|
||||
|
||||
#define TOKENPASTE(x, y) x##y
|
||||
#define TOKENPASTE2(x, y) TOKENPASTE(x, y)
|
||||
#undef STATIC_REQUIRE
|
||||
#define STATIC_REQUIRE(e) \
|
||||
constexpr bool TOKENPASTE2(rqure, __LINE__) = e; \
|
||||
(void)TOKENPASTE2(rqure, __LINE__); \
|
||||
REQUIRE(e);
|
||||
|
||||
TEST_CASE("Map extensions", "[extensions.map]") {
|
||||
auto mul2 = [](int a) { return a * 2; };
|
||||
auto ret_void = [](int a) {};
|
||||
auto ret_void = [](int a) { (void)a; };
|
||||
|
||||
{
|
||||
tl::expected<int, int> e = 21;
|
||||
@@ -143,7 +145,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 a) { (void)a; };
|
||||
|
||||
{
|
||||
tl::expected<int, int> e = 21;
|
||||
@@ -252,8 +254,8 @@ TEST_CASE("Map error extensions", "[extensions.map_error]") {
|
||||
}
|
||||
|
||||
TEST_CASE("And then extensions", "[extensions.and_then]") {
|
||||
auto succeed = [](int a) { return tl::expected<int, int>(21 * 2); };
|
||||
auto fail = [](int a) { return tl::expected<int, int>(tl::unexpect, 17); };
|
||||
auto succeed = [](int a) { (void)a; return tl::expected<int, int>(21 * 2); };
|
||||
auto fail = [](int a) { (void)a; return tl::expected<int, int>(tl::unexpect, 17); };
|
||||
|
||||
{
|
||||
tl::expected<int, int> e = 21;
|
||||
@@ -370,11 +372,10 @@ TEST_CASE("And then extensions", "[extensions.and_then]") {
|
||||
|
||||
TEST_CASE("or_else", "[extensions.or_else]") {
|
||||
using eptr = std::unique_ptr<int>;
|
||||
auto succeed = [](int a) { return tl::expected<int, int>(21 * 2); };
|
||||
auto succeedptr = [](eptr e) { return tl::expected<int,eptr>(21*2);};
|
||||
auto fail = [](int a) { return tl::expected<int,int>(tl::unexpect, 17);};
|
||||
auto efail = [](eptr e) { *e = 17;return tl::expected<int,eptr>(tl::unexpect, std::move(e));};
|
||||
auto failptr = [](eptr e) { return tl::expected<int,eptr>(tl::unexpect, std::move(e));};
|
||||
auto succeed = [](int a) { (void)a; return tl::expected<int, int>(21 * 2); };
|
||||
auto succeedptr = [](eptr e) { (void)e; return tl::expected<int,eptr>(21*2);};
|
||||
auto fail = [](int a) { (void)a; return tl::expected<int,int>(tl::unexpect, 17);};
|
||||
auto failptr = [](eptr e) { *e = 17;return tl::expected<int,eptr>(tl::unexpect, std::move(e));};
|
||||
auto failvoid = [](int) {};
|
||||
auto failvoidptr = [](const eptr&) { /* don't consume */};
|
||||
auto consumeptr = [](eptr) {};
|
||||
@@ -439,7 +440,7 @@ TEST_CASE("or_else", "[extensions.or_else]") {
|
||||
|
||||
{
|
||||
tl::expected<int, eptr> e = 21;
|
||||
auto ret = std::move(e).or_else(efail);
|
||||
auto ret = std::move(e).or_else(failptr);
|
||||
REQUIRE(ret);
|
||||
REQUIRE(ret == 21);
|
||||
}
|
||||
@@ -569,7 +570,7 @@ TEST_CASE("14", "[issue.14]") {
|
||||
auto res = tl::expected<S,F>{tl::unexpect, F{}};
|
||||
|
||||
res.map_error([](F f) {
|
||||
|
||||
(void)f;
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -15,7 +15,7 @@ TEST_CASE("Issue 1", "[issues.1]") { getInt1(); }
|
||||
|
||||
tl::expected<int, int> operation1() { return 42; }
|
||||
|
||||
tl::expected<std::string, int> operation2(int const val) { return "Bananas"; }
|
||||
tl::expected<std::string, int> operation2(int const val) { (void)val; return "Bananas"; }
|
||||
|
||||
TEST_CASE("Issue 17", "[issues.17]") {
|
||||
auto const intermediate_result = operation1();
|
||||
@@ -67,7 +67,7 @@ struct i31{
|
||||
};
|
||||
TEST_CASE("Issue 31", "[issues.31]") {
|
||||
const tl::expected<i31, int> a = i31{42};
|
||||
a->i;
|
||||
(void)a->i;
|
||||
|
||||
tl::expected< void, std::string > result;
|
||||
tl::expected< void, std::string > result2 = result;
|
||||
@@ -77,7 +77,7 @@ TEST_CASE("Issue 31", "[issues.31]") {
|
||||
TEST_CASE("Issue 33", "[issues.33]") {
|
||||
tl::expected<void, int> res {tl::unexpect, 0};
|
||||
REQUIRE(!res);
|
||||
res = res.map_error([](int i) { return 42; });
|
||||
res = res.map_error([](int i) { (void)i; return 42; });
|
||||
REQUIRE(res.error() == 42);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user