[libcxx] r305843 - [libcxx] [test] Add more tests to tuple_size_structured_bindings.pass.cpp and make it friendlier to C1XX.

Stephan T. Lavavej via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 20 13:34:51 PDT 2017


Author: stl_msft
Date: Tue Jun 20 15:34:50 2017
New Revision: 305843

URL: http://llvm.org/viewvc/llvm-project?rev=305843&view=rev
Log:
[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.

Modified:
    libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp

Modified: libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp?rev=305843&r1=305842&r2=305843&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp Tue Jun 20 15:34:50 2017
@@ -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_specializati
 }
 
 template <>
-class std::tuple_size<Test> {
-public:
+struct std::tuple_size<Test> {
   static const size_t value = 1;
 };
 




More information about the cfe-commits mailing list