summaryrefslogtreecommitdiff
path: root/test/std/experimental/optional/optional.object/optional.object.ctor
diff options
context:
space:
mode:
Diffstat (limited to 'test/std/experimental/optional/optional.object/optional.object.ctor')
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp7
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp23
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp6
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp7
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp34
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp7
6 files changed, 72 insertions, 12 deletions
diff --git a/test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp
index 9b6511a0006d..6371dcb4e51c 100644
--- a/test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp
+++ b/test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp
@@ -8,7 +8,6 @@
//===----------------------------------------------------------------------===//
//
// UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
// <optional>
@@ -18,6 +17,8 @@
#include <type_traits>
#include <cassert>
+#include "test_macros.h"
+
using std::experimental::optional;
class X
@@ -42,7 +43,7 @@ class Z
{
public:
Z(int) {}
- Z(const Z&) {throw 6;}
+ Z(const Z&) {TEST_THROW(6);}
};
@@ -97,6 +98,7 @@ int main()
};
}
+#ifndef TEST_HAS_NO_EXCEPTIONS
{
typedef Z T;
try
@@ -110,4 +112,5 @@ int main()
assert(i == 6);
}
}
+#endif
}
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);
diff --git a/test/std/experimental/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp
index dc1666b10362..c46407896576 100644
--- a/test/std/experimental/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp
+++ b/test/std/experimental/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp
@@ -8,7 +8,6 @@
//===----------------------------------------------------------------------===//
//
// UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
// <optional>
@@ -19,6 +18,7 @@
#include <type_traits>
#include <cassert>
+#include "test_macros.h"
using std::experimental::optional;
using std::experimental::in_place_t;
@@ -55,7 +55,7 @@ public:
class Z
{
public:
- Z(int i) {throw 6;}
+ Z(int) {TEST_THROW(6);}
};
@@ -128,6 +128,7 @@ int main()
};
}
+#ifndef TEST_HAS_NO_EXCEPTIONS
{
try
{
@@ -139,4 +140,5 @@ int main()
assert(i == 6);
}
}
+#endif
}
diff --git a/test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp
index 9bd6b18989fc..b75c147df513 100644
--- a/test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp
+++ b/test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp
@@ -8,7 +8,6 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
// <optional>
// template <class U, class... Args>
@@ -20,6 +19,8 @@
#include <vector>
#include <cassert>
+#include "test_macros.h"
+
using std::experimental::optional;
using std::experimental::in_place_t;
using std::experimental::in_place;
@@ -60,7 +61,7 @@ public:
constexpr Z() : i_(0) {}
constexpr Z(int i) : i_(i) {}
Z(std::initializer_list<int> il) : i_(il.begin()[0]), j_(il.begin()[1])
- {throw 6;}
+ {TEST_THROW(6);}
friend constexpr bool operator==(const Z& x, const Z& y)
{return x.i_ == y.i_ && x.j_ == y.j_;}
@@ -100,6 +101,7 @@ int main()
constexpr test_constexpr_ctor dopt(in_place, {42, 101, -1});
static_assert(*dopt == Y{42, 101, -1}, "");
}
+#ifndef TEST_HAS_NO_EXCEPTIONS
{
static_assert(std::is_constructible<optional<Z>, std::initializer_list<int>&>::value, "");
try
@@ -112,4 +114,5 @@ int main()
assert(i == 6);
}
}
+#endif
}
diff --git a/test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp
index 851157f960f9..a8bb6e9c275c 100644
--- a/test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp
+++ b/test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp
@@ -8,7 +8,6 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
// <optional>
// optional(optional<T>&& rhs) noexcept(is_nothrow_move_constructible<T>::value);
@@ -17,6 +16,8 @@
#include <type_traits>
#include <cassert>
+#include "test_macros.h"
+
using std::experimental::optional;
template <class T>
@@ -26,16 +27,24 @@ test(optional<T>& rhs, bool is_going_to_throw = false)
static_assert(std::is_nothrow_move_constructible<optional<T>>::value ==
std::is_nothrow_move_constructible<T>::value, "");
bool rhs_engaged = static_cast<bool>(rhs);
+#ifdef TEST_HAS_NO_EXCEPTIONS
+ if (is_going_to_throw)
+ return;
+#else
try
+#endif
{
optional<T> lhs = std::move(rhs);
assert(is_going_to_throw == false);
assert(static_cast<bool>(lhs) == rhs_engaged);
}
+#ifndef TEST_HAS_NO_EXCEPTIONS
catch (int i)
{
assert(i == 6);
+ assert(is_going_to_throw);
}
+#endif
}
class X
@@ -68,12 +77,23 @@ public:
Z(Z&&)
{
if (++count == 2)
- throw 6;
+ TEST_THROW(6);
}
friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == y.i_;}
};
+
+class ConstMovable
+{
+ int i_;
+public:
+ ConstMovable(int i) : i_(i) {}
+ ConstMovable(const ConstMovable&& x) : i_(x.i_) {}
+ ~ConstMovable() {i_ = 0;}
+ friend bool operator==(const ConstMovable& x, const ConstMovable& y) {return x.i_ == y.i_;}
+};
+
int main()
{
{
@@ -87,6 +107,11 @@ int main()
test(rhs);
}
{
+ typedef const int T;
+ optional<T> rhs(3);
+ test(rhs);
+ }
+ {
typedef X T;
optional<T> rhs;
test(rhs);
@@ -97,6 +122,11 @@ int main()
test(rhs);
}
{
+ typedef const ConstMovable T;
+ optional<T> rhs(ConstMovable(3));
+ test(rhs);
+ }
+ {
typedef Y T;
optional<T> rhs;
test(rhs);
diff --git a/test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp
index ef21fcdf9e6d..1941546a53f7 100644
--- a/test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp
+++ b/test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp
@@ -8,7 +8,6 @@
//===----------------------------------------------------------------------===//
//
// UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
// <optional>
@@ -18,6 +17,8 @@
#include <type_traits>
#include <cassert>
+#include "test_macros.h"
+
using std::experimental::optional;
class X
@@ -44,7 +45,7 @@ class Z
{
public:
Z(int) {}
- Z(Z&&) {throw 6;}
+ Z(Z&&) {TEST_THROW(6);}
};
@@ -92,6 +93,7 @@ int main()
constexpr test_constexpr_ctor(T&&) {}
};
}
+#ifndef TEST_HAS_NO_EXCEPTIONS
{
typedef Z T;
try
@@ -104,4 +106,5 @@ int main()
assert(i == 6);
}
}
+#endif
}