|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r82200 - branches/release/libs/serialization/test
From: ramey_at_[hidden]
Date: 2012-12-24 13:12:44
Author: ramey
Date: 2012-12-24 13:12:43 EST (Mon, 24 Dec 2012)
New Revision: 82200
URL: http://svn.boost.org/trac/boost/changeset/82200
Log:
update test_utf8_codecvt test to use std::istream_iterator.
update other tests for improvements in base64_from_binary
tweak test_complex to play nice with PGI library.
Properties modified:
branches/release/libs/serialization/test/ (props changed)
branches/release/libs/serialization/test/test_diamond_complex.cpp (props changed)
Text files modified:
branches/release/libs/serialization/test/test_binary.cpp | 16 ++++++++++++--
branches/release/libs/serialization/test/test_complex.cpp | 4 ++
branches/release/libs/serialization/test/test_iterators.cpp | 25 +++++++++++++++-------
branches/release/libs/serialization/test/test_iterators_base64.cpp | 19 ++++++++++++-----
branches/release/libs/serialization/test/test_utf8_codecvt.cpp | 43 +++++++++++++++++++--------------------
5 files changed, 67 insertions(+), 40 deletions(-)
Modified: branches/release/libs/serialization/test/test_binary.cpp
==============================================================================
--- branches/release/libs/serialization/test/test_binary.cpp (original)
+++ branches/release/libs/serialization/test/test_binary.cpp 2012-12-24 13:12:43 EST (Mon, 24 Dec 2012)
@@ -70,16 +70,22 @@
char s3[] = "abc";
char s4[] = "abcd";
const int i = 12345;
+
A a1;
char s1_1[10];
char s1_2[10];
char s1_3[10];
char s1_4[10];
int i1 = 34790;
+
+ std::memset(s1_1, '\0', sizeof(s1_1));
+ std::memset(s1_2, '\0', sizeof(s1_2));
+ std::memset(s1_3, '\0', sizeof(s1_3));
+ std::memset(s1_4, '\0', sizeof(s1_4));
{
test_ostream os(testfile, TEST_STREAM_FLAGS);
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
- boost::serialization::make_nvp(
+ oa << boost::serialization::make_nvp(
"s1",
boost::serialization::make_binary_object(
s1,
@@ -115,7 +121,7 @@
{
test_istream is(testfile, TEST_STREAM_FLAGS);
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
- boost::serialization::make_nvp(
+ ia >> boost::serialization::make_nvp(
"s1",
boost::serialization::make_binary_object(
s1_1,
@@ -148,8 +154,12 @@
// failure of text mode binary.
ia >> BOOST_SERIALIZATION_NVP(i1);
}
- BOOST_CHECK(i == i1);
+ BOOST_CHECK(0 == std::strcmp(s1, s1_1));
+ BOOST_CHECK(0 == std::strcmp(s2, s1_2));
+ BOOST_CHECK(0 == std::strcmp(s3, s1_3));
+ BOOST_CHECK(0 == std::strcmp(s4, s1_4));
BOOST_CHECK(a == a1);
+ BOOST_CHECK(i == i1);
std::remove(testfile);
return EXIT_SUCCESS;
}
Modified: branches/release/libs/serialization/test/test_complex.cpp
==============================================================================
--- branches/release/libs/serialization/test/test_complex.cpp (original)
+++ branches/release/libs/serialization/test/test_complex.cpp 2012-12-24 13:12:43 EST (Mon, 24 Dec 2012)
@@ -20,11 +20,13 @@
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::rand;
- using ::fabs;
using ::remove;
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(UNDER_CE)
using ::numeric_limits;
#endif
+ #if !defined(__PGIC__)
+ using ::fabs;
+ #endif
}
#endif
Modified: branches/release/libs/serialization/test/test_iterators.cpp
==============================================================================
--- branches/release/libs/serialization/test/test_iterators.cpp (original)
+++ branches/release/libs/serialization/test/test_iterators.cpp 2012-12-24 13:12:43 EST (Mon, 24 Dec 2012)
@@ -102,9 +102,9 @@
void test_transform_width(unsigned int size){
// test transform_width
char rawdata[8];
-
+
char * rptr;
- for(rptr = rawdata + 6; rptr-- > rawdata;)
+ for(rptr = rawdata + size; rptr-- > rawdata;)
*rptr = static_cast<char>(0xff & std::rand());
// convert 8 to 6 bit characters
@@ -112,32 +112,41 @@
char *, BitsOut, BitsIn
> translator1;
- std::vector<char> v6;
+ std::vector<char> vout;
std::copy(
translator1(BOOST_MAKE_PFTO_WRAPPER(static_cast<char *>(rawdata))),
translator1(BOOST_MAKE_PFTO_WRAPPER(rawdata + size)),
- std::back_inserter(v6)
+ std::back_inserter(vout)
);
// check to see we got the expected # of characters out
if(0 == size)
- BOOST_CHECK(v6.size() == 0);
+ BOOST_CHECK(vout.size() == 0);
else
- BOOST_CHECK(v6.size() == (size * BitsIn - 1 ) / BitsOut + 1);
+ BOOST_CHECK(vout.size() == (size * BitsIn - 1 ) / BitsOut + 1);
typedef boost::archive::iterators::transform_width<
std::vector<char>::iterator, BitsIn, BitsOut
> translator2;
+ std::vector<char> vin;
+ std::copy(
+ translator2(BOOST_MAKE_PFTO_WRAPPER(vout.begin())),
+ translator2(BOOST_MAKE_PFTO_WRAPPER(vout.end())),
+ std::back_inserter(vin)
+ );
+
+ // check to see we got the expected # of characters out
+ BOOST_CHECK(vin.size() == size);
+
BOOST_CHECK(
std::equal(
rawdata,
rawdata + size,
- translator2(BOOST_MAKE_PFTO_WRAPPER(v6.begin()))
+ vin.begin()
)
);
-
}
template<class CharType>
Modified: branches/release/libs/serialization/test/test_iterators_base64.cpp
==============================================================================
--- branches/release/libs/serialization/test/test_iterators_base64.cpp (original)
+++ branches/release/libs/serialization/test/test_iterators_base64.cpp 2012-12-24 13:12:43 EST (Mon, 24 Dec 2012)
@@ -37,12 +37,11 @@
#include <iostream>
template<typename CharType>
-void test_base64(){
+void test_base64(unsigned int size){
CharType rawdata[150];
- std::size_t size = sizeof(rawdata) / sizeof(CharType);
CharType * rptr;
for(rptr = rawdata + size; rptr-- > rawdata;)
- *rptr = static_cast<CharType>(std::rand());
+ *rptr = static_cast<CharType>(std::rand()& 0xff);
// convert to base64
typedef std::list<CharType> text_base64_type;
@@ -57,7 +56,7 @@
,sizeof(CharType) * 8
>
>
- ,72
+ ,76
>
translate_out;
@@ -92,9 +91,17 @@
int
test_main( int /*argc*/, char* /*argv*/[] )
{
- test_base64<char>();
+ test_base64<char>(1);
+ test_base64<char>(2);
+ test_base64<char>(3);
+ test_base64<char>(4);
+ test_base64<char>(150);
#ifndef BOOST_NO_CWCHAR
- test_base64<wchar_t>();
+ test_base64<wchar_t>(1);
+ test_base64<wchar_t>(2);
+ test_base64<wchar_t>(3);
+ test_base64<wchar_t>(4);
+ test_base64<wchar_t>(150);
#endif
return EXIT_SUCCESS;
}
Modified: branches/release/libs/serialization/test/test_utf8_codecvt.cpp
==============================================================================
--- branches/release/libs/serialization/test/test_utf8_codecvt.cpp (original)
+++ branches/release/libs/serialization/test/test_utf8_codecvt.cpp 2012-12-24 13:12:43 EST (Mon, 24 Dec 2012)
@@ -22,7 +22,7 @@
namespace std{
using ::size_t;
using ::wcslen;
-#ifndef UNDER_CE
+#if !defined(UNDER_CE) && !defined(__PGIC__)
using ::w_int;
#endif
} // namespace std
@@ -36,12 +36,10 @@
// NOTE: Use BOOST_WORKAROUND?
#if (defined(__QNX__) && defined(BOOST_DINKUMWARE_STDLIB)) \
|| defined(__SUNPRO_CC)
-using ::std::wint_t;
+ using ::std::wint_t;
#endif
#include "test_tools.hpp"
-#include <boost/archive/iterators/istream_iterator.hpp>
-#include <boost/archive/iterators/ostream_iterator.hpp>
#include <boost/archive/add_facet.hpp>
#include <boost/archive/detail/utf8_codecvt_facet.hpp>
@@ -92,19 +90,19 @@
template<>
wchar_t test_data<4>::wchar_encoding[] = {
- 0x00000001,
- 0x0000007f,
- 0x00000080,
- 0x000007ff,
- 0x00000800,
- 0x0000ffff,
- 0x00010000,
- 0x0010ffff,
- 0x001fffff,
- 0x00200000,
- 0x03ffffff,
- 0x04000000,
- 0x7fffffff
+ (wchar_t)0x00000001,
+ (wchar_t)0x0000007f,
+ (wchar_t)0x00000080,
+ (wchar_t)0x000007ff,
+ (wchar_t)0x00000800,
+ (wchar_t)0x0000ffff,
+ (wchar_t)0x00010000,
+ (wchar_t)0x0010ffff,
+ (wchar_t)0x001fffff,
+ (wchar_t)0x00200000,
+ (wchar_t)0x03ffffff,
+ (wchar_t)0x04000000,
+ (wchar_t)0x7fffffff
};
int
@@ -132,7 +130,7 @@
// so use this instead
td::utf8_encoding + 12,
#endif
- boost::archive::iterators::ostream_iterator<utf8_t>(ofs)
+ std::ostream_iterator<utf8_t>(ofs)
);
}
@@ -176,13 +174,13 @@
std::copy(
from_file.begin(),
from_file.end(),
- boost::archive::iterators::ostream_iterator<wchar_t>(ofs)
+ std::ostream_iterator<wchar_t, wchar_t>(ofs)
);
}
// Make sure that both files are the same
{
- typedef boost::archive::iterators::istream_iterator<utf8_t> is_iter;
+ typedef std::istream_iterator<utf8_t> is_iter;
is_iter end_iter;
std::ifstream ifs1("test.dat");
@@ -237,7 +235,7 @@
std::copy(
test3_data,
test3_data + l,
- boost::archive::iterators::ostream_iterator<wchar_t>(ofs)
+ std::ostream_iterator<wchar_t, wchar_t>(ofs)
);
}
@@ -246,11 +244,12 @@
std::wifstream ifs;
ifs.imbue(*utf8_locale);
ifs.open("test3.dat");
+ ifs >> std::noskipws;
BOOST_CHECK(
std::equal(
test3_data,
test3_data + l,
- boost::archive::iterators::istream_iterator<wchar_t>(ifs)
+ std::istream_iterator<wchar_t, wchar_t>(ifs)
)
);
}
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