2
0
mirror of https://github.com/boostorg/convert.git synced 2026-01-28 07:02:16 +00:00

proof-reading

This commit is contained in:
VB
2014-03-11 12:41:25 +11:00
parent 1ce1d7c443
commit 6c7c0dc81b
35 changed files with 439 additions and 206 deletions

View File

@@ -57,6 +57,7 @@ test::algorithms()
////////////////////////////////////////////////////////////////////////////
// String to integer conversion. Explicit fallback, i.e. no throwing. Hex formatting.
////////////////////////////////////////////////////////////////////////////
std::transform(
strings.begin(),
strings.end(),
@@ -70,9 +71,33 @@ test::algorithms()
BOOST_ASSERT(integers[3] == 18);
BOOST_ASSERT(integers[4] == -1); // Failed conversion
#ifdef NOT_AVAILABLE_UNTIL_CPP11
std::vector<boost::convert<int>::result> opt_ints;
std::transform(
strings.begin(),
strings.end(),
std::back_inserter(opt_ints),
boost::convert<int>::from<std::string>(ccnv(arg::base = cnv::base::hex)));
BOOST_ASSERT(opt_ints.size() == 5);
BOOST_ASSERT( opt_ints[0]);
BOOST_ASSERT( opt_ints[1]);
BOOST_ASSERT( opt_ints[2]);
BOOST_ASSERT( opt_ints[3]);
BOOST_ASSERT(!opt_ints[4]); // Failed conversion
BOOST_ASSERT(opt_ints[0].value() == 15);
BOOST_ASSERT(opt_ints[1].value() == 16);
BOOST_ASSERT(opt_ints[2].value() == 17);
BOOST_ASSERT(opt_ints[3].value() == 18);
#endif
////////////////////////////////////////////////////////////////////////////
// int-to-string conversion. No explicit fallback value.
////////////////////////////////////////////////////////////////////////////
std::transform(
integers.begin(),
integers.end(),
@@ -85,4 +110,7 @@ test::algorithms()
BOOST_ASSERT(new_strings[2] == "17");
BOOST_ASSERT(new_strings[3] == "18");
BOOST_ASSERT(new_strings[4] == "-1");
}
}