summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/utilities/any/any.class
diff options
context:
space:
mode:
authorCasey Carter <Casey@Carter.net>2017-04-21 22:38:59 +0000
committerCasey Carter <Casey@Carter.net>2017-04-21 22:38:59 +0000
commitc24d7974bcb9914540f6fcf331e53ae01e90ab05 (patch)
tree75bd48dc227b0573e7b5f7d71aeb6ba3ec467f3d /libcxx/test/std/utilities/any/any.class
parent71c4043ae9769a71e54b2ea7d995a31db24060a5 (diff)
downloadbcm5719-llvm-c24d7974bcb9914540f6fcf331e53ae01e90ab05.tar.gz
bcm5719-llvm-c24d7974bcb9914540f6fcf331e53ae01e90ab05.zip
Expand test coverage for LWG2857
* Cover optional's emplace-from-initializer_list overload * Verify that any::emplace and optional::emplace return a reference to the correct type even for throwing cases. Differential Revision: https://reviews.llvm.org/D32106 llvm-svn: 301055
Diffstat (limited to 'libcxx/test/std/utilities/any/any.class')
-rw-r--r--libcxx/test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/libcxx/test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp b/libcxx/test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp
index 75dfb0a2e70..7ed6121e530 100644
--- a/libcxx/test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp
+++ b/libcxx/test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp
@@ -44,7 +44,7 @@ void test_emplace_type() {
auto &v = a.emplace<Type>();
static_assert( std::is_same_v<Type&, decltype(v)>, "" );
- assert(&v == std::any_cast<Type>(&a));
+ assert(&v == std::any_cast<Type>(&a));
assert(Tracked::count == 0);
assert(Type::count == 1);
@@ -60,7 +60,7 @@ void test_emplace_type() {
auto &v = a.emplace<Type>(101);
static_assert( std::is_same_v<Type&, decltype(v)>, "" );
- assert(&v == std::any_cast<Type>(&a));
+ assert(&v == std::any_cast<Type>(&a));
assert(Tracked::count == 0);
assert(Type::count == 1);
@@ -76,7 +76,7 @@ void test_emplace_type() {
auto &v = a.emplace<Type>(-1, 42, -1);
static_assert( std::is_same_v<Type&, decltype(v)>, "" );
- assert(&v == std::any_cast<Type>(&a));
+ assert(&v == std::any_cast<Type>(&a));
assert(Tracked::count == 0);
assert(Type::count == 1);
@@ -97,7 +97,7 @@ void test_emplace_type_tracked() {
assert(Tracked::count == 1);
auto &v = a.emplace<Type>();
static_assert( std::is_same_v<Type&, decltype(v)>, "" );
- assert(&v == std::any_cast<Type>(&a));
+ assert(&v == std::any_cast<Type>(&a));
assert(Tracked::count == 0);
assertArgsMatch<Type>(a);
@@ -107,7 +107,7 @@ void test_emplace_type_tracked() {
assert(Tracked::count == 1);
auto &v = a.emplace<Type>(-1, 42, -1);
static_assert( std::is_same_v<Type&, decltype(v)>, "" );
- assert(&v == std::any_cast<Type>(&a));
+ assert(&v == std::any_cast<Type>(&a));
assert(Tracked::count == 0);
assertArgsMatch<Type, int, int, int>(a);
@@ -118,7 +118,7 @@ void test_emplace_type_tracked() {
assert(Tracked::count == 1);
auto &v = a.emplace<Type>({-1, 42, -1});
static_assert( std::is_same_v<Type&, decltype(v)>, "" );
- assert(&v == std::any_cast<Type>(&a));
+ assert(&v == std::any_cast<Type>(&a));
assert(Tracked::count == 0);
assertArgsMatch<Type, std::initializer_list<int>>(a);
@@ -129,7 +129,7 @@ void test_emplace_type_tracked() {
assert(Tracked::count == 1);
auto &v = a.emplace<Type>({-1, 42, -1}, x);
static_assert( std::is_same_v<Type&, decltype(v)>, "" );
- assert(&v == std::any_cast<Type>(&a));
+ assert(&v == std::any_cast<Type>(&a));
assert(Tracked::count == 0);
assertArgsMatch<Type, std::initializer_list<int>, int&>(a);
@@ -159,7 +159,8 @@ void test_emplace_throws()
std::any a(small{42});
assert(small::count == 1);
try {
- a.emplace<Type>(101);
+ auto &v = a.emplace<Type>(101);
+ static_assert( std::is_same_v<Type&, decltype(v)>, "" );
assert(false);
} catch (int const&) {
}
@@ -169,7 +170,8 @@ void test_emplace_throws()
std::any a(small{42});
assert(small::count == 1);
try {
- a.emplace<Type>({1, 2, 3}, 101);
+ auto &v = a.emplace<Type>({1, 2, 3}, 101);
+ static_assert( std::is_same_v<Type&, decltype(v)>, "" );
assert(false);
} catch (int const&) {
}
@@ -180,7 +182,8 @@ void test_emplace_throws()
std::any a(large{42});
assert(large::count == 1);
try {
- a.emplace<Type>(101);
+ auto &v = a.emplace<Type>(101);
+ static_assert( std::is_same_v<Type&, decltype(v)>, "" );
assert(false);
} catch (int const&) {
}
@@ -190,7 +193,8 @@ void test_emplace_throws()
std::any a(large{42});
assert(large::count == 1);
try {
- a.emplace<Type>({1, 2, 3}, 101);
+ auto &v = a.emplace<Type>({1, 2, 3}, 101);
+ static_assert( std::is_same_v<Type&, decltype(v)>, "" );
assert(false);
} catch (int const&) {
}
OpenPOWER on IntegriCloud