Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r66294 - trunk/libs/array/test
From: marshall_at_[hidden]
Date: 2010-10-30 22:25:05


Author: marshall
Date: 2010-10-30 22:25:04 EDT (Sat, 30 Oct 2010)
New Revision: 66294
URL: http://svn.boost.org/trac/boost/changeset/66294

Log:
Added a test for 'get_c_array'
Added:
   trunk/libs/array/test/array6.cpp (contents, props changed)
Text files modified:
   trunk/libs/array/test/Jamfile.v2 | 1 +
   1 files changed, 1 insertions(+), 0 deletions(-)

Modified: trunk/libs/array/test/Jamfile.v2
==============================================================================
--- trunk/libs/array/test/Jamfile.v2 (original)
+++ trunk/libs/array/test/Jamfile.v2 2010-10-30 22:25:04 EDT (Sat, 30 Oct 2010)
@@ -11,4 +11,5 @@
     [ run array3.cpp ]
     [ run array4.cpp ]
     [ run array5.cpp ]
+ [ run array6.cpp ]
     ;

Added: trunk/libs/array/test/array6.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/array/test/array6.cpp 2010-10-30 22:25:04 EDT (Sat, 30 Oct 2010)
@@ -0,0 +1,47 @@
+/* tests for using class array<> specialization for size 0
+ * (C) Copyright Alisdair Meredith 2006.
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#include <string>
+#include <iostream>
+#include <boost/array.hpp>
+#include <algorithm>
+
+namespace {
+unsigned int failed_tests = 0;
+
+void fail_test( const char * reason ) {
+ ++failed_tests;
+ std::cerr << "Test failure " << failed_tests << ": " << reason << std::endl;
+}
+
+template< class T >
+void RunTests()
+{
+ typedef boost::array< T, 5 > test_type;
+ typedef T arr[5];
+ test_type test_case; // = { 1, 1, 2, 3, 5 };
+
+ arr &aRef = get_c_array ( test_case );
+ if ( &*test_case.begin () != &aRef[0] )
+ fail_test ( "Array6: Same thing not equal?(1)" );
+
+ const arr &caRef = get_c_array ( test_case );
+ if ( &*test_case.begin () != &caRef[0] )
+ fail_test ( "Array6: Same thing not equal?(2)" );
+}
+
+}
+
+int main()
+{
+ RunTests< bool >();
+ RunTests< void * >();
+ RunTests< long double >();
+ RunTests< std::string >();
+ return failed_tests;
+}
+


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk