summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/utilities
diff options
context:
space:
mode:
authorStephan T. Lavavej <stl@exchange.microsoft.com>2017-06-20 20:34:50 +0000
committerStephan T. Lavavej <stl@exchange.microsoft.com>2017-06-20 20:34:50 +0000
commitafdc99333aea79bd3095f5db18d90539f3a1e6ea (patch)
treeec36081d8b0d8c263fb8e46f536602ce9cca85db /libcxx/test/std/utilities
parent665e1c9240a71463b492f57515cb5ae1aa8237eb (diff)
downloadbcm5719-llvm-afdc99333aea79bd3095f5db18d90539f3a1e6ea.tar.gz
bcm5719-llvm-afdc99333aea79bd3095f5db18d90539f3a1e6ea.zip
[libcxx] [test] Add more tests to tuple_size_structured_bindings.pass.cpp and make it friendlier to C1XX.
Style/paranoia: 42.1 doesn't have an exact binary representation. Although this doesn't cause failures, it makes me uncomfortable, so I'm changing it to 42.5. C1XX rightly warns about unreferenced variables. Adding tests for their values makes C1XX happy and improves test coverage. C1XX (somewhat obnoxiously) warns about seeing a struct specialized as a class. Although the Standard doesn't care, saying struct consistently is better. (The Standard itself is still inconsistent about whether to depict tuple_element and tuple_size as structs or classes.) Fixes D33953. llvm-svn: 305843
Diffstat (limited to 'libcxx/test/std/utilities')
-rw-r--r--libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp
index aadbf3d5a36..fdd60663ce3 100644
--- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp
+++ b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp
@@ -64,18 +64,22 @@ void test_decomp_tuple() {
void test_decomp_pair() {
typedef std::pair<int, double> T;
{
- T s{99, 42.1};
+ T s{99, 42.5};
auto [m1, m2] = s;
auto& [r1, r2] = s;
assert(m1 == 99);
+ assert(m2 == 42.5);
assert(&r1 == &std::get<0>(s));
+ assert(&r2 == &std::get<1>(s));
}
{
- T const s{99, 42.1};
+ T const s{99, 42.5};
auto [m1, m2] = s;
auto& [r1, r2] = s;
assert(m1 == 99);
+ assert(m2 == 42.5);
assert(&r1 == &std::get<0>(s));
+ assert(&r2 == &std::get<1>(s));
}
}
@@ -86,14 +90,22 @@ void test_decomp_array() {
auto [m1, m2, m3] = s;
auto& [r1, r2, r3] = s;
assert(m1 == 99);
+ assert(m2 == 42);
+ assert(m3 == -1);
assert(&r1 == &std::get<0>(s));
+ assert(&r2 == &std::get<1>(s));
+ assert(&r3 == &std::get<2>(s));
}
{
T const s{{99, 42, -1}};
auto [m1, m2, m3] = s;
auto& [r1, r2, r3] = s;
assert(m1 == 99);
+ assert(m2 == 42);
+ assert(m3 == -1);
assert(&r1 == &std::get<0>(s));
+ assert(&r2 == &std::get<1>(s));
+ assert(&r3 == &std::get<2>(s));
}
}
@@ -105,8 +117,7 @@ template <size_t N>
int get(Test const&) { static_assert(N == 0, ""); return -1; }
template <>
-class std::tuple_element<0, Test> {
-public:
+struct std::tuple_element<0, Test> {
typedef int type;
};
@@ -117,8 +128,7 @@ void test_before_tuple_size_specialization() {
}
template <>
-class std::tuple_size<Test> {
-public:
+struct std::tuple_size<Test> {
static const size_t value = 1;
};
OpenPOWER on IntegriCloud