[libcxx] r245528 - Fix one last dynarray test

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 19 17:20:06 PDT 2015


Author: ericwf
Date: Wed Aug 19 19:20:05 2015
New Revision: 245528

URL: http://llvm.org/viewvc/llvm-project?rev=245528&view=rev
Log:
Fix one last dynarray test

Modified:
    libcxx/trunk/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/front_back.pass.cpp

Modified: libcxx/trunk/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/front_back.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/front_back.pass.cpp?rev=245528&r1=245527&r2=245528&view=diff
==============================================================================
--- libcxx/trunk/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/front_back.pass.cpp (original)
+++ libcxx/trunk/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/front_back.pass.cpp Wed Aug 19 19:20:05 2015
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+// UNSUPPORTED: c++98, c++03, c++11
+
 // dynarray.overview
 
 // reference       front();
@@ -14,10 +16,6 @@
 // reference       back();
 // const_reference back()  const;
 
-  
-#include <__config>
-
-#if _LIBCPP_STD_VER > 11
 
 #include <experimental/dynarray>
 #include <cassert>
@@ -29,40 +27,47 @@
 using std::experimental::dynarray;
 
 template <class T>
-void dyn_test_const ( const dynarray<T> &dyn ) {
+void dyn_test_const ( const dynarray<T> &dyn, bool CheckValues = true ) {
     const T *data = dyn.data ();
-    assert ( *data == dyn.front ());
-    assert ( *(data + dyn.size() - 1 ) == dyn.back ());
+    assert(data == &dyn.front());
+    assert((data + dyn.size() - 1) == &dyn.back());
+    if (CheckValues) {
+        assert ( *data == dyn.front ());
+        assert ( *(data + dyn.size() - 1 ) == dyn.back ());
     }
+}
 
 template <class T>
-void dyn_test ( dynarray<T> &dyn ) {
+void dyn_test ( dynarray<T> &dyn, bool CheckValues = true ) {
     T *data = dyn.data ();
-    assert ( *data == dyn.front ());
-    assert ( *(data + dyn.size() - 1 ) == dyn.back ());
+    assert(data == &dyn.front());
+    assert((data + dyn.size() - 1) == &dyn.back());
+    if (CheckValues) {
+        assert ( *data == dyn.front ());
+        assert ( *(data + dyn.size() - 1 ) == dyn.back ());
     }
+}
 
 
 template <class T>
-void test ( const T &val ) {
+void test ( const T &val, bool DefaultValueIsIndeterminate = false) {
     typedef dynarray<T> dynA;
-    
+
+    const bool CheckDefaultValues = ! DefaultValueIsIndeterminate;
+
     dynA d1 ( 4 );
-    dyn_test ( d1 );
-    dyn_test_const ( d1 );
+    dyn_test ( d1, CheckDefaultValues );
+    dyn_test_const ( d1, CheckDefaultValues );
     
     dynA d2 ( 7, val );
     dyn_test ( d2 );
     dyn_test_const ( d2 );
-    }
+}
 
 int main()
 {
-    test<int> ( 14 );
-    test<double> ( 14.0 );
+    test<int> ( 14, /* DefaultValueIsIndeterminate */ true);
+    test<double> ( 14.0, true );
     test<std::complex<double>> ( std::complex<double> ( 14, 0 ));
     test<std::string> ( "fourteen" );
 }
-#else
-int main() {}
-#endif




More information about the cfe-commits mailing list