STL_MSFT created this revision.
[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.)
https://reviews.llvm.org/D33953
Files:
test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp
Index:
test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp
===
---
test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp
+++
test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp
@@ -64,18 +64,22 @@
void test_decomp_pair() {
typedef std::pair 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 @@
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 @@
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 @@
}
template <>
-class std::tuple_size {
-public:
+struct std::tuple_size {
static const size_t value = 1;
};
Index: test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp
===
--- test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp
+++ test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp
@@ -64,18 +64,22 @@
void test_decomp_pair() {
typedef std::pair 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 @@
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 @@
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 @@
}
template <>
-class std::tuple_size {
-public:
+struct std::tuple_size {
static const size_t value = 1;
};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits