diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-01-02 19:18:58 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-01-02 19:18:58 +0000 |
| commit | 53a420fba21cf1644972b34dcd811a43cdb8368d (patch) | |
| tree | 66a19f6f8b65215772549a51d688492ab8addc0d /test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp | |
| parent | b50f1549701eb950921e5d6f2e55ba1a1dadbb43 (diff) | |
Notes
Diffstat (limited to 'test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp')
| -rw-r--r-- | test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp index 144af2e3a7dc..4b66fe80bbb2 100644 --- a/test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp +++ b/test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: libcpp-no-exceptions // <optional> // optional(const optional<T>& rhs); @@ -17,6 +16,8 @@ #include <type_traits> #include <cassert> +#include "test_macros.h" + using std::experimental::optional; template <class T> @@ -24,7 +25,12 @@ void test(const optional<T>& rhs, bool is_going_to_throw = false) { bool rhs_engaged = static_cast<bool>(rhs); +#ifdef TEST_HAS_NO_EXCEPTIONS + if (is_going_to_throw) + return; +#else try +#endif { optional<T> lhs = rhs; assert(is_going_to_throw == false); @@ -32,10 +38,13 @@ test(const optional<T>& rhs, bool is_going_to_throw = false) if (rhs_engaged) assert(*lhs == *rhs); } +#ifndef TEST_HAS_NO_EXCEPTIONS catch (int i) { assert(i == 6); + assert(is_going_to_throw); } +#endif } class X @@ -68,7 +77,7 @@ public: Z(const Z&) { if (++count == 2) - throw 6; + TEST_THROW(6); } friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == y.i_;} @@ -88,6 +97,11 @@ int main() test(rhs); } { + typedef const int T; + optional<T> rhs(3); + test(rhs); + } + { typedef X T; optional<T> rhs; test(rhs); @@ -98,6 +112,11 @@ int main() test(rhs); } { + typedef const X T; + optional<T> rhs(X(3)); + test(rhs); + } + { typedef Y T; optional<T> rhs; test(rhs); |
