Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename test folder to test (for evoke), fix warnings in pedantic #119

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ if(EXPECTED_BUILD_TESTS)
FetchContent_MakeAvailable(Catch2)

file(GLOB test-sources CONFIGURE_DEPENDS tests/*.cpp)
list(FILTER test-sources EXCLUDE REGEX "tests/test.cpp")
add_executable(${PROJECT_NAME}-tests "${test-sources}")
target_compile_options(${PROJECT_NAME}-tests PRIVATE
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra>)
Expand Down
4 changes: 2 additions & 2 deletions tests/assignment.cpp → test/assignment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ TEST_CASE("Assignment deletion", "[assignment.deletion]") {
except_move(except_move &&) noexcept(false){};
except_move &operator=(const except_move &) = default;
};
tl::expected<except_move, except_move> e3 = {};
tl::expected<except_move, except_move> e4 = {};
[[maybe_unused]] tl::expected<except_move, except_move> e3 = {};
[[maybe_unused]] tl::expected<except_move, except_move> e4 = {};
// e3 = e4; should not compile
}
4 changes: 2 additions & 2 deletions tests/bases.cpp → test/bases.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ TEST_CASE("Triviality", "[bases.triviality]") {
struct T {
T(const T&){}
T(T&&) {};
T& operator=(const T&) {}
T& operator=(T&&) {};
T& operator=(const T&) { return *this; }
T& operator=(T&&) { return *this; };
~T(){}
};
REQUIRE(!std::is_trivially_copy_constructible<tl::expected<T,int>>::value);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
22 changes: 12 additions & 10 deletions tests/extensions.cpp → test/extensions.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#include <catch2/catch.hpp>
#include <tl/expected.hpp>

// catch also defines this exact name
#undef STATIC_REQUIRE
#define TOKENPASTE(x, y) x##y
#define TOKENPASTE2(x, y) TOKENPASTE(x, y)
#define STATIC_REQUIRE(e) \
constexpr bool TOKENPASTE2(rqure, __LINE__) = e; \
[[maybe_unused]] constexpr bool TOKENPASTE2(rqure, __LINE__) = e; \
REQUIRE(e);

TEST_CASE("Map extensions", "[extensions.map]") {
auto mul2 = [](int a) { return a * 2; };
auto ret_void = [](int a) {};
auto ret_void = [](int) {};

{
tl::expected<int, int> e = 21;
Expand Down Expand Up @@ -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) {};

{
tl::expected<int, int> e = 21;
Expand Down Expand Up @@ -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) { return tl::expected<int, int>(21 * 2); };
auto fail = [](int) { return tl::expected<int, int>(tl::unexpect, 17); };

{
tl::expected<int, int> e = 21;
Expand Down Expand Up @@ -370,11 +372,11 @@ 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 succeed = [](int) { return tl::expected<int, int>(21 * 2); };
auto succeedptr = [](eptr) { return tl::expected<int,eptr>(21*2);};
auto fail = [](int) { 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));};
[[maybe_unused]] auto failptr = [](eptr e) { return tl::expected<int,eptr>(tl::unexpect, std::move(e));};
auto failvoid = [](int) {};
auto failvoidptr = [](const eptr&) { /* don't consume */};
auto consumeptr = [](eptr) {};
Expand Down Expand Up @@ -568,7 +570,7 @@ struct F {
TEST_CASE("14", "[issue.14]") {
auto res = tl::expected<S,F>{tl::unexpect, F{}};

res.map_error([](F f) {
res.map_error([](F) {

});
}
Expand Down
6 changes: 3 additions & 3 deletions tests/issues.cpp → test/issues.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) { return "Bananas"; }

TEST_CASE("Issue 17", "[issues.17]") {
auto const intermediate_result = operation1();
Expand Down Expand Up @@ -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;
Expand All @@ -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) { return 42; });
REQUIRE(res.error() == 42);
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
32 changes: 0 additions & 32 deletions tests/test.cpp

This file was deleted.