Boost logo

Boost-Commit :

From: jared_at_[hidden]
Date: 2007-05-24 01:43:37


Author: jared
Date: 2007-05-24 01:43:36 EDT (Thu, 24 May 2007)
New Revision: 4224
URL: http://svn.boost.org/trac/boost/changeset/4224

Log:
Added c style array tests.

Added:
   sandbox/explore/libs/explore/test/c_array.cpp
Text files modified:
   sandbox/explore/libs/explore/test/Jamfile.v2 | 2 +-
   1 files changed, 1 insertions(+), 1 deletions(-)

Modified: sandbox/explore/libs/explore/test/Jamfile.v2
==============================================================================
--- sandbox/explore/libs/explore/test/Jamfile.v2 (original)
+++ sandbox/explore/libs/explore/test/Jamfile.v2 2007-05-24 01:43:36 EDT (Thu, 24 May 2007)
@@ -20,6 +20,7 @@
   test-suite printing
     :
   [ run simple_types.cpp ]
+ [ run c_array.cpp ]
 
   [ run std_vector.cpp ]
   [ run std_deque.cpp ]
@@ -29,7 +30,6 @@
   [ run std_pair.cpp ]
   
   [ run boost_array.cpp ]
-
   [ run boost_tuple.cpp ]
   [ run boost_variant.cpp ]
  ;

Added: sandbox/explore/libs/explore/test/c_array.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore/libs/explore/test/c_array.cpp 2007-05-24 01:43:36 EDT (Thu, 24 May 2007)
@@ -0,0 +1,88 @@
+// Boost.Print library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to 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)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <string>
+#include <sstream>
+#include <vector>
+#include "../../../boost/explore/explore.hpp"
+#include "../../../boost/explore/stream_container.hpp"
+
+BOOST_AUTO_TEST_CASE( basic_c_array_print_test )
+{
+ std::stringstream str_out;
+
+ int arri1[] = {1};
+ explore::print(arri1, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1]");
+
+ str_out.str("");
+
+ int arri3[] = {1,2,3};
+ explore::print(arri3, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2, 3]");
+}
+
+BOOST_AUTO_TEST_CASE( basic_c_array_stream_test )
+{
+ using namespace boost;
+ std::stringstream str_out;
+
+ int arri1[] = {1};
+ str_out << arri1;
+ BOOST_CHECK_EQUAL(str_out.str(), "[1]");
+
+ str_out.str("");
+
+ int arri3[] = {1,2,3};
+ str_out << arri3;
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2, 3]");
+}
+
+BOOST_AUTO_TEST_CASE( vector_in_c_array_print_test )
+{
+ std::stringstream str_out;
+
+ std::vector<int> vi;
+ vi.push_back(1);
+ vi.push_back(2);
+ vi.push_back(3);
+
+ std::vector<int> arrvi1[] = {vi};
+ explore::print(arrvi1, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3]]");
+
+ str_out.str("");
+
+ std::vector<int> arrvi3[] = {vi,vi,vi};
+ explore::print(arrvi3, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3], [1, 2, 3]]");
+}
+
+BOOST_AUTO_TEST_CASE( vector_in_c_array_stream_test )
+{
+ using namespace boost;
+ std::stringstream str_out;
+
+ std::vector<int> vi;
+ vi.push_back(1);
+ vi.push_back(2);
+ vi.push_back(3);
+
+ std::vector<int> arrvi1[] = {vi};
+ str_out << arrvi1;
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3]]");
+
+ str_out.str("");
+
+ std::vector<int> arrvi3[] = {vi,vi,vi};
+ str_out << arrvi3;
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3], [1, 2, 3]]");
+}
\ No newline at end of file


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