1 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
4 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
5 // Use, modification and distribution is subject to the Boost Software
6 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 // should pass compilation and execution
13 #include <boost/config.hpp>
16 #include <algorithm> // equal
17 #include <cstdio> // remove
18 #if defined(BOOST_NO_STDC_NAMESPACE)
23 #include "test_tools.hpp"
24 #include <boost/core/no_exceptions_support.hpp>
25 #include <boost/archive/archive_exception.hpp>
31 int test_native_array(){
32 const char * testfile = boost::archive::tmpnam(NULL);
33 BOOST_REQUIRE(NULL != testfile);
35 // test array of objects
36 const T a_array[10]={T(),T(),T(),T(),T(),T(),T(),T(),T(),T()};
37 const T b_array[2][3]={{T(),T(),T()},{T(),T(),T()}};
39 test_ostream os(testfile, TEST_STREAM_FLAGS);
41 test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
42 oa << boost::serialization::make_nvp("a_array", a_array);
43 oa << boost::serialization::make_nvp("b_array", b_array);
50 test_istream is(testfile, TEST_STREAM_FLAGS);
52 test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
53 ia >> boost::serialization::make_nvp("a_array", a_array1);
54 ia >> boost::serialization::make_nvp("b_array", b_array1);
57 BOOST_CHECK(std::equal(& a_array[0], & a_array[10], & a_array1[0]));
58 BOOST_CHECK(b_array[0][0] == b_array1[0][0]);
59 BOOST_CHECK(b_array[1][0] == b_array1[1][0]);
64 test_istream is(testfile, TEST_STREAM_FLAGS);
66 test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
67 bool exception_invoked = false;
69 ia >> boost::serialization::make_nvp("a_array", a_array1);
70 ia >> boost::serialization::make_nvp("b_array", b_array1);
72 BOOST_CATCH (boost::archive::archive_exception ae){
74 boost::archive::archive_exception::array_size_too_short
77 exception_invoked = true;
80 BOOST_CHECK(exception_invoked);
84 std::remove(testfile);
88 int test_main( int /* argc */, char* /* argv */[] ){
92 res = test_native_array<A>();
93 if (res != EXIT_SUCCESS)
95 // test an int array for which optimized versions should be available
96 res = test_native_array<int>();
97 if (res != EXIT_SUCCESS)