2016-09-22 10:55:33 +02:00
|
|
|
#include "catch.hpp"
|
|
|
|
|
|
|
|
#include <maybe/result.hpp>
|
|
|
|
|
|
|
|
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<A, E>::err to result<B, E>::err")
|
|
|
|
{
|
|
|
|
auto a = result<A, int>::err(42);
|
|
|
|
auto b = a.into_err<result<B, int>>();
|
|
|
|
REQUIRE(!b);
|
|
|
|
REQUIRE(42 == b.err_value());
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("converts result<A, E>::err to result<void, E>::err")
|
|
|
|
{
|
|
|
|
auto a = result<A, int>::err(42);
|
2016-09-22 14:54:52 +02:00
|
|
|
auto b = a.into_err<void>();
|
2016-09-22 10:55:33 +02:00
|
|
|
REQUIRE(!b);
|
|
|
|
REQUIRE(42 == b.err_value());
|
|
|
|
}
|
|
|
|
}
|