~ubuntu-branches/debian/sid/boost1.49/sid

« back to all changes in this revision

Viewing changes to libs/serialization/test/test_valarray.cpp

  • Committer: Package Import Robot
  • Author(s): Steve M. Robbins
  • Date: 2012-02-26 00:31:44 UTC
  • Revision ID: package-import@ubuntu.com-20120226003144-eaytp12cbf6ubpms
Tags: upstream-1.49.0
ImportĀ upstreamĀ versionĀ 1.49.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
 
2
// test_valarrray.cpp
 
3
 
 
4
// (C) Copyright 2005 Matthias Troyer . 
 
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)
 
8
 
 
9
// should pass compilation and execution
 
10
 
 
11
#include <cstddef> // NULL
 
12
#include <fstream>
 
13
 
 
14
#include <cstdio> // remove
 
15
#include <boost/config.hpp>
 
16
#if defined(BOOST_NO_STDC_NAMESPACE)
 
17
namespace std{ 
 
18
    using ::remove;
 
19
}
 
20
#endif
 
21
 
 
22
#include "test_tools.hpp"
 
23
 
 
24
#include <boost/serialization/valarray.hpp>
 
25
 
 
26
int test_main( int /* argc */, char* /* argv */[] )
 
27
{
 
28
    const char * testfile = boost::archive::tmpnam(NULL);
 
29
    BOOST_REQUIRE(NULL != testfile);
 
30
 
 
31
    // test array of objects
 
32
    std::valarray<int> avalarray(2);
 
33
    avalarray[0] = 42;
 
34
    avalarray[1] = -42;
 
35
    {   
 
36
        test_ostream os(testfile, TEST_STREAM_FLAGS);
 
37
        test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
 
38
        oa << boost::serialization::make_nvp("avalarray", avalarray);
 
39
    }
 
40
    std::valarray<int> avalarray1;
 
41
    {
 
42
        test_istream is(testfile, TEST_STREAM_FLAGS);
 
43
        test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
 
44
        ia >> boost::serialization::make_nvp("avalarray", avalarray1);
 
45
    }
 
46
    bool equal = (    avalarray.size() == avalarray1.size() 
 
47
                   && avalarray[0] == avalarray1[0]
 
48
                   && avalarray[1] == avalarray1[1]
 
49
                 );
 
50
                  
 
51
    BOOST_CHECK(equal);
 
52
    std::remove(testfile);
 
53
    return EXIT_SUCCESS;
 
54
}
 
55
 
 
56
// EOF