]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/serialization/test/test_codecvt_null.cpp
1 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
2 // test_codecvt_null.cpp
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. Note: compilation with compilers
10 // which use wchar_t as 2 byte objects will emit warnings. These should be
13 #include <algorithm> // std::copy
19 #include <cstdio> // remove
20 #include <cstddef> // NULL, size_t
22 #include <boost/config.hpp>
23 #if defined(BOOST_NO_STDC_NAMESPACE)
29 #include "test_tools.hpp"
31 #include <boost/archive/codecvt_null.hpp>
32 #include <boost/archive/iterators/ostream_iterator.hpp>
33 #include <boost/archive/iterators/istream_iterator.hpp>
35 template<std::size_t S
>
38 static wchar_t wchar_encoding
[];
42 wchar_t test_data
<2>::wchar_encoding
[] = {
52 wchar_t test_data
<4>::wchar_encoding
[] = {
70 int test_main( int /* argc */, char* /* argv */[] ) {
71 const char * testfile
= boost::archive::tmpnam(NULL
);
72 BOOST_REQUIRE(NULL
!= testfile
);
75 std::locale null_locale
= std::locale(
77 new boost::archive::codecvt_null
<wchar_t>
80 typedef test_data
<sizeof(wchar_t)> td
;
83 ofs
.imbue(null_locale
);
84 ofs
.open(testfile
, std::ios::binary
);
87 td::wchar_encoding
+ sizeof(td::wchar_encoding
)/sizeof(wchar_t),
88 boost::archive::iterators::ostream_iterator
<wchar_t>(ofs
)
94 ifs
.imbue(null_locale
);
95 ifs
.open(testfile
, std::ios::binary
);
98 td::wchar_encoding
+ sizeof(td::wchar_encoding
)/sizeof(wchar_t),
99 boost::archive::iterators::istream_iterator
<wchar_t>(ifs
)
105 std::wofstream
ofs("testfile2");
106 ofs
.imbue(null_locale
);
111 std::wifstream
ifs("testfile2");
112 ifs
.imbue(null_locale
);
115 std::cout
<< "i=" << i
<< std::endl
;
116 std::cout
<< "i2=" << i2
<< std::endl
;
117 BOOST_CHECK(i
== i2
);
121 std::remove(testfile
);