Merge branch 'master' into cmake_love

This commit is contained in:
Simon Brand
2019-06-25 11:17:40 +01:00
3 changed files with 30 additions and 2 deletions

26
tests/swap.cpp Normal file
View File

@ -0,0 +1,26 @@
#include "catch.hpp"
#include "optional.hpp"
TEST_CASE("Swap value", "[swap.value]") {
tl::optional<int> o1 = 42;
tl::optional<int> o2 = 12;
o1.swap(o2);
CHECK(o1.value() == 12);
CHECK(o2.value() == 42);
}
TEST_CASE("Swap value with null intialized", "[swap.value_nullopt]") {
tl::optional<int> o1 = 42;
tl::optional<int> o2 = tl::nullopt;
o1.swap(o2);
CHECK(!o1.has_value());
CHECK(o2.value() == 42);
}
TEST_CASE("Swap null intialized with value", "[swap.nullopt_value]") {
tl::optional<int> o1 = tl::nullopt;
tl::optional<int> o2 = 42;
o1.swap(o2);
CHECK(o1.value() == 42);
CHECK(!o2.has_value());
}