diff --git a/tests/noexcept.cpp b/tests/noexcept.cpp index 03e3242..74dd4ad 100644 --- a/tests/noexcept.cpp +++ b/tests/noexcept.cpp @@ -30,13 +30,15 @@ TEST_CASE("Noexcept", "[noexcept]") { }; struct throw_swappable { + throw_swappable(throw_swappable &&) {} throw_swappable &swap(const throw_swappable &) { return *this; } }; - REQUIRE(noexcept(std::declval().swap( - std::declval()))); - REQUIRE(!noexcept( - std::declval().swap(std::declval()))); + tl::optional ont; + tl::optional ot; + + REQUIRE(noexcept(ont.swap(ont))); + REQUIRE(!noexcept(ot.swap(ot))); } SECTION("constructors") { @@ -44,17 +46,18 @@ TEST_CASE("Noexcept", "[noexcept]") { REQUIRE(noexcept(tl::optional{tl::nullopt})); struct nothrow_move { - nothrow_move() = default; nothrow_move(nothrow_move &&) noexcept = default; }; struct throw_move { - throw_move() = default; - throw_move(throw_move &&) = default; + throw_move(throw_move &&){}; }; - REQUIRE(noexcept(tl::optional{std::declval()})); - REQUIRE(!noexcept(tl::optional{std::declval()})); + using nothrow_opt = tl::optional; + using throw_opt = tl::optional; + + REQUIRE(noexcept(nothrow_opt{std::declval()})); + REQUIRE(!noexcept(throw_opt{std::declval()})); } SECTION("assignment") { @@ -72,10 +75,12 @@ TEST_CASE("Noexcept", "[noexcept]") { throw_move_assign &operator=(const throw_move_assign &) {} }; - REQUIRE(noexcept(std::declval() = - std::declval())); - REQUIRE(!noexcept(std::declval() = - std::declval())); + using nothrow_opt = tl::optional; + using throw_opt = tl::optional; + + REQUIRE( + noexcept(std::declval() = std::declval())); + REQUIRE(!noexcept(std::declval() = std::declval())); } SECTION("observers") { @@ -83,7 +88,5 @@ TEST_CASE("Noexcept", "[noexcept]") { REQUIRE(noexcept(o1.has_value())); } - SECTION("modifiers") { - REQUIRE(noexcept(o1.reset())); - } + SECTION("modifiers") { REQUIRE(noexcept(o1.reset())); } }