Merge branch 'master' into trivial_copy_fix

This commit is contained in:
Simon Brand authored and GitHub committed 2017-12-05 20:19:46 +00:00
commit cb74470fc7
4 files changed
+139 -29

No files matched your search

+58
View File
@@ -130,6 +130,15 @@ TEST_CASE("Map extensions", "[extensions.map]") {
STATIC_REQUIRE(
(std::is_same<decltype(ret), tl::expected<tl::monostate, int>>::value));
}
// mapping functions which return references
{
tl::expected<int, int> e(42);
auto ret = e.map([](int& i) -> int& { return i; });
REQUIRE(ret);
REQUIRE(ret == 42);
}
}
TEST_CASE("Map error extensions", "[extensions.map_error]") {
@@ -191,6 +200,55 @@ TEST_CASE("Map error extensions", "[extensions.map_error]") {
REQUIRE(!ret);
REQUIRE(ret.error() == 42);
}
{
tl::expected<int, int> e = 21;
auto ret = e.map_error(ret_void);
REQUIRE(ret);
}
{
const tl::expected<int, int> e = 21;
auto ret = e.map_error(ret_void);
REQUIRE(ret);
}
{
tl::expected<int, int> e = 21;
auto ret = std::move(e).map_error(ret_void);
REQUIRE(ret);
}
{
const tl::expected<int, int> e = 21;
auto ret = std::move(e).map_error(ret_void);
REQUIRE(ret);
}
{
tl::expected<int, int> e(tl::unexpect, 21);
auto ret = e.map_error(ret_void);
REQUIRE(!ret);
}
{
const tl::expected<int, int> e(tl::unexpect, 21);
auto ret = e.map_error(ret_void);
REQUIRE(!ret);
}
{
tl::expected<int, int> e(tl::unexpect, 21);
auto ret = std::move(e).map_error(ret_void);
REQUIRE(!ret);
}
{
const tl::expected<int, int> e(tl::unexpect, 21);
auto ret = std::move(e).map_error(ret_void);
REQUIRE(!ret);
}
}
TEST_CASE("And then extensions", "[extensions.and_then]") {