diff --git a/src/maybe/result.hpp b/src/maybe/result.hpp index 6ad2912..f8ea7d9 100644 --- a/src/maybe/result.hpp +++ b/src/maybe/result.hpp @@ -419,7 +419,7 @@ namespace maybe { constexpr static result default_ok() noexcept { return std::experimental::constexpr_move( - result(void(), internal::placeholder{})); + result(internal::placeholder{})); } /** diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3348a3a..1950706 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -8,6 +8,7 @@ add_executable(${TARGET} result_tests.cpp result_map_tests.cpp result_map_err_tests.cpp + result_into_err_tests.cpp result_and_then_tests.cpp example_test.cpp) diff --git a/tests/result_into_err_tests.cpp b/tests/result_into_err_tests.cpp new file mode 100644 index 0000000..092ba38 --- /dev/null +++ b/tests/result_into_err_tests.cpp @@ -0,0 +1,35 @@ +#include "catch.hpp" + +#include + +class A final { +public: + A(std::string value) : value(value) + { + } + std::string value; +}; + +class B final { +}; + +using maybe::result; + +TEST_CASE("result_into_err") +{ + SECTION("converts result::err to result::err") + { + auto a = result::err(42); + auto b = a.into_err>(); + REQUIRE(!b); + REQUIRE(42 == b.err_value()); + } + + SECTION("converts result::err to result::err") + { + auto a = result::err(42); + auto b = a.into_err>(); + REQUIRE(!b); + REQUIRE(42 == b.err_value()); + } +} \ No newline at end of file