Revert "Linux warning and errors addressed"
This reverts commit83289d7db6
, reversing changes made to25aef40dd0
.
This commit is contained in:
parent
1818bbd469
commit
88b6976710
@ -14,7 +14,7 @@ namespace utf = boost::unit_test;
|
||||
const bool io_implemented = true;
|
||||
const bool db_implemented = false;
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(suite1, * utf::disabled())
|
||||
BOOST_AUTO_TEST_SUITE(suite1, * utf::disabled());
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_1)
|
||||
{
|
||||
@ -38,5 +38,5 @@ BOOST_AUTO_TEST_SUITE(suite1, * utf::disabled())
|
||||
BOOST_TEST(4 != 4);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
BOOST_AUTO_TEST_SUITE_END();
|
||||
//]
|
||||
|
@ -25,9 +25,9 @@ namespace unit_test {
|
||||
namespace data {
|
||||
|
||||
namespace {
|
||||
auto const& begin = unit_test::static_constant<nfp::keyword<struct begin_t>>::value;
|
||||
auto const& end = unit_test::static_constant<nfp::keyword<struct end_t>>::value;
|
||||
auto const& step = unit_test::static_constant<nfp::keyword<struct step_t>>::value;
|
||||
nfp::keyword<struct begin_t> begin;
|
||||
nfp::keyword<struct end_t> end;
|
||||
nfp::keyword<struct step_t> step;
|
||||
} // local namespace
|
||||
|
||||
} // namespace data
|
||||
|
@ -54,8 +54,8 @@ public:
|
||||
{}
|
||||
|
||||
// forward iterator interface
|
||||
sample const& operator*() const { return m_first_size > 0 ? *m_it1 : *m_it2; }
|
||||
void operator++() { if( m_first_size > 0 ) { --m_first_size; ++m_it1; } else ++m_it2; }
|
||||
sample const& operator*() const { return m_first_size > 0 ? *m_it1 : *m_it2; }
|
||||
void operator++() { m_first_size > 0 ? (--m_first_size,++m_it1) : ++m_it2; }
|
||||
|
||||
private:
|
||||
// Data members
|
||||
|
@ -44,7 +44,7 @@ enum report_level { INV_REPORT_LEVEL, CONFIRMATION_REPORT, SHORT_REPORT, DETAIL
|
||||
enum output_format { OF_INVALID,
|
||||
OF_CLF, ///< compiler log format
|
||||
OF_XML, ///< XML format for report and log,
|
||||
OF_DOT ///< dot format for output content
|
||||
OF_DOT ///< dot format for output content
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
@ -77,8 +77,6 @@ test_id_2_unit_type( test_unit_id id )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace ut_detail
|
||||
|
||||
// helper templates to prevent ODR violations
|
||||
template<class T>
|
||||
struct static_constant {
|
||||
@ -90,6 +88,8 @@ T static_constant<T>::value;
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace ut_detail
|
||||
|
||||
} // namespace unit_test
|
||||
} // namespace boost
|
||||
|
||||
|
@ -41,6 +41,7 @@
|
||||
// Boost
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/cstdlib.hpp>
|
||||
|
@ -50,7 +50,7 @@ struct specialized_compare<Col> : public mpl::true_ {}; \
|
||||
|
||||
namespace op {
|
||||
|
||||
template <typename OP, bool can_be_equal, bool prefer_shorter,
|
||||
template <typename OP, bool can_be_equal, bool prefer_shorter,
|
||||
typename Lhs, typename Rhs>
|
||||
inline assertion_result
|
||||
lexicographic_compare( Lhs const& lhs, Rhs const& rhs )
|
||||
@ -69,13 +69,13 @@ lexicographic_compare( Lhs const& lhs, Rhs const& rhs )
|
||||
return ar; // a < b
|
||||
|
||||
assertion_result const& reverse_ar = OP::eval(*first2, *first1);
|
||||
if( element_ar && !reverse_ar )
|
||||
if( element_ar && !reverse_ar )
|
||||
return ar; // a<=b and !(b<=a) => a < b => return true
|
||||
|
||||
if( element_ar || !reverse_ar )
|
||||
continue; // (a<=b and b<=a) or (!(a<b) and !(b<a)) => a == b => keep looking
|
||||
|
||||
if( element_ar || !reverse_ar )
|
||||
continue; // (a<=b and b<=a) or (!(a<b) and !(b<a)) => a == b => keep looking
|
||||
|
||||
// !(a<=b) and b<=a => b < a => return false
|
||||
// !(a<=b) and b<=a => b < a => return false
|
||||
ar = false;
|
||||
ar.message() << "\nFailure at position " << pos << ": "
|
||||
<< tt_detail::print_helper(*first1)
|
||||
@ -85,7 +85,7 @@ lexicographic_compare( Lhs const& lhs, Rhs const& rhs )
|
||||
return ar;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if( first1 != last1 ) {
|
||||
if( prefer_shorter ) {
|
||||
ar = false;
|
||||
@ -376,3 +376,4 @@ BOOST_TEST_FOR_EACH_COMP_OP( DEFINE_COLLECTION_COMPARISON )
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // BOOST_TEST_TOOLS_COLLECTION_COMPARISON_OP_HPP_050815GER
|
||||
|
||||
|
@ -22,9 +22,9 @@
|
||||
// Boost.Test
|
||||
#include <boost/test/utils/basic_cstring/io.hpp>
|
||||
#include <boost/test/utils/basic_cstring/compare.hpp>
|
||||
#include <boost/test/utils/string_cast.hpp>
|
||||
|
||||
// Boost
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/function/function2.hpp>
|
||||
|
||||
// STL
|
||||
@ -51,11 +51,13 @@ struct value_interpreter<ValueType, false> {
|
||||
|
||||
ValueType interpret( cstring param_name, cstring source ) const
|
||||
{
|
||||
ValueType res;
|
||||
if( !unit_test::utils::string_as<ValueType>( source, res ) )
|
||||
BOOST_TEST_I_THROW( format_error( param_name ) << source <<
|
||||
" can't be interpreted as value of parameter " << param_name << "." );
|
||||
return res;
|
||||
BOOST_TEST_I_TRY{
|
||||
return lexical_cast<ValueType>(source);
|
||||
} BOOST_TEST_I_CATCH0( bad_lexical_cast ) {
|
||||
BOOST_TEST_I_THROW( format_error( param_name ) << source <<
|
||||
" can't be interpreted as value of parameter " << param_name << "." );
|
||||
}
|
||||
return ValueType{};
|
||||
}
|
||||
};
|
||||
|
||||
@ -105,7 +107,7 @@ struct value_interpreter<bool, false> {
|
||||
|
||||
source.trim();
|
||||
|
||||
if( source.is_empty() ||
|
||||
if( source.is_empty() ||
|
||||
case_ins_eq( source, s_YES ) ||
|
||||
case_ins_eq( source, s_Y ) ||
|
||||
case_ins_eq( source, s_one ) ||
|
||||
@ -137,7 +139,7 @@ struct value_interpreter<EnumType, true> {
|
||||
auto found = m_name_to_value.find( source );
|
||||
|
||||
BOOST_TEST_I_ASSRT( found != m_name_to_value.end(),
|
||||
format_error( param_name ) << source <<
|
||||
format_error( param_name ) << source <<
|
||||
" is not a valid enumeration value name for parameter " << param_name << "." );
|
||||
|
||||
return found->second;
|
||||
|
@ -18,11 +18,9 @@
|
||||
// Boost.Test Runtime parameters
|
||||
#include <boost/test/utils/runtime/fwd.hpp>
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/utils/string_cast.hpp>
|
||||
|
||||
// Boost
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
// STL
|
||||
#include <exception>
|
||||
@ -87,7 +85,7 @@ template<typename Derived, typename Base, typename T>
|
||||
inline Derived
|
||||
operator<<(specific_param_error<Derived, Base>&& ex, T const& val)
|
||||
{
|
||||
ex.msg.append( unit_test::utils::string_cast( val ) );
|
||||
ex.msg.append( lexical_cast<std::string>( val ) );
|
||||
|
||||
return reinterpret_cast<Derived&&>(ex);
|
||||
}
|
||||
@ -123,7 +121,7 @@ SPECIFIC_EX_TYPE( missing_req_arg, input_error );
|
||||
|
||||
class ambiguous_param : public specific_param_error<ambiguous_param, input_error> {
|
||||
public:
|
||||
explicit ambiguous_param( std::vector<cstring>&& amb_candidates )
|
||||
explicit ambiguous_param( std::vector<cstring>&& amb_candidates )
|
||||
: specific_param_error<ambiguous_param,input_error>( "" )
|
||||
, m_amb_candidates( std::move( amb_candidates ) ) {}
|
||||
|
||||
|
@ -32,21 +32,22 @@ namespace runtime {
|
||||
|
||||
namespace {
|
||||
|
||||
auto const& description = unit_test::static_constant<nfp::typed_keyword<cstring,struct description_t>>::value;
|
||||
auto const& help = unit_test::static_constant<nfp::typed_keyword<cstring,struct help_t>>::value;
|
||||
auto const& env_var = unit_test::static_constant<nfp::typed_keyword<cstring,struct env_var_t>>::value;
|
||||
auto const& end_of_params = unit_test::static_constant<nfp::typed_keyword<cstring,struct end_of_params_t>>::value;
|
||||
auto const& negation_prefix = unit_test::static_constant<nfp::typed_keyword<cstring,struct neg_prefix_t>>::value;
|
||||
auto const& value_hint = unit_test::static_constant<nfp::typed_keyword<cstring,struct value_hint_t>>::value;
|
||||
auto const& optional_value = unit_test::static_constant<nfp::keyword<struct optional_value_t>>::value;
|
||||
auto const& default_value = unit_test::static_constant<nfp::keyword<struct default_value_t>>::value;
|
||||
auto const& callback = unit_test::static_constant<nfp::keyword<struct callback_t>>::value;
|
||||
nfp::typed_keyword<cstring,struct description_t> description;
|
||||
nfp::typed_keyword<cstring,struct help_t> help;
|
||||
nfp::typed_keyword<cstring,struct env_var_t> env_var;
|
||||
nfp::typed_keyword<cstring,struct end_of_params_t> end_of_params;
|
||||
nfp::typed_keyword<cstring,struct neg_prefix_t> negation_prefix;
|
||||
nfp::typed_keyword<cstring,struct value_hint_t> value_hint;
|
||||
|
||||
template<typename EnumType>
|
||||
using enum_values = unit_test::static_constant<
|
||||
using enum_values = unit_test::ut_detail::static_constant<
|
||||
nfp::typed_keyword<std::initializer_list<std::pair<const cstring,EnumType>>, struct enum_values_t>
|
||||
>;
|
||||
|
||||
nfp::keyword<struct optional_value_t> optional_value;
|
||||
nfp::keyword<struct default_value_t> default_value;
|
||||
nfp::keyword<struct callback_t> callback;
|
||||
|
||||
} // local namespace
|
||||
|
||||
} // namespace runtime
|
||||
|
@ -1,69 +0,0 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
// File : $RCSfile$
|
||||
//
|
||||
// Version : $Revision$
|
||||
//
|
||||
// Description : trivial utility to cast to/from strings
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_UTILS_STRING_CAST_HPP
|
||||
#define BOOST_TEST_UTILS_STRING_CAST_HPP
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/utils/basic_cstring/basic_cstring.hpp>
|
||||
|
||||
// STL
|
||||
#include <sstream>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace boost {
|
||||
namespace unit_test {
|
||||
namespace utils {
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** string_cast ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
template<typename T>
|
||||
inline std::string
|
||||
string_cast( T const& t )
|
||||
{
|
||||
std::ostringstream buff;
|
||||
buff << t;
|
||||
return buff.str();
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** string_as ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
template<typename T>
|
||||
inline bool
|
||||
string_as( const_string str, T& res )
|
||||
{
|
||||
std::istringstream buff( std::string( str.begin(), str.end() ) );
|
||||
buff >> res;
|
||||
|
||||
return !buff.fail() && buff.eof();
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace utils
|
||||
} // namespace unit_test
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // BOOST_TEST_UTILS_STRING_CAST_HPP
|
@ -83,7 +83,6 @@ test-suite "utils-ts"
|
||||
[ boost.test-self-test run : utils-ts : foreach-test ]
|
||||
[ boost.test-self-test run : utils-ts : named_params-test ]
|
||||
[ boost.test-self-test run : utils-ts : runtime-param-test ]
|
||||
[ boost.test-self-test run : utils-ts : string_cast-test ]
|
||||
[ boost.test-self-test run : utils-ts : token_iterator-test ]
|
||||
;
|
||||
|
||||
|
@ -2,14 +2,14 @@
|
||||
===========================
|
||||
log level: log_successful_tests; error type: no error;
|
||||
|
||||
160: Entering test case "error_on_demand"
|
||||
95: info: check 'no error' has passed
|
||||
164: Entering test case "error_on_demand"
|
||||
99: info: check 'no error' has passed
|
||||
Leaving test case "error_on_demand"
|
||||
|
||||
===========================
|
||||
log level: log_successful_tests; error type: user message;
|
||||
|
||||
160: Entering test case "error_on_demand"
|
||||
164: Entering test case "error_on_demand"
|
||||
message
|
||||
Test case error_on_demand did not check any assertions
|
||||
Leaving test case "error_on_demand"
|
||||
@ -17,43 +17,43 @@ Leaving test case "error_on_demand"
|
||||
===========================
|
||||
log level: log_successful_tests; error type: user warning;
|
||||
|
||||
160: Entering test case "error_on_demand"
|
||||
103: warning: in "error_on_demand": warning
|
||||
164: Entering test case "error_on_demand"
|
||||
107: warning: in "error_on_demand": warning
|
||||
Test case error_on_demand did not check any assertions
|
||||
Leaving test case "error_on_demand"
|
||||
|
||||
===========================
|
||||
log level: log_successful_tests; error type: user non-fatal error;
|
||||
|
||||
160: Entering test case "error_on_demand"
|
||||
107: error: in "error_on_demand": non-fatal error
|
||||
164: Entering test case "error_on_demand"
|
||||
111: error: in "error_on_demand": non-fatal error
|
||||
Leaving test case "error_on_demand"
|
||||
|
||||
===========================
|
||||
log level: log_successful_tests; error type: cpp exception;
|
||||
|
||||
160: Entering test case "error_on_demand"
|
||||
164: Entering test case "error_on_demand"
|
||||
0: fatal error: in "error_on_demand": std::runtime_error: test std::runtime error what() message
|
||||
117: last checkpoint: error_on_demand() throw runtime_error
|
||||
121: last checkpoint: error_on_demand() throw runtime_error
|
||||
Leaving test case "error_on_demand"
|
||||
|
||||
===========================
|
||||
log level: log_successful_tests; error type: system error;
|
||||
|
||||
160: Entering test case "error_on_demand"
|
||||
111: fatal error: in "error_on_demand": fatal error
|
||||
164: Entering test case "error_on_demand"
|
||||
115: fatal error: in "error_on_demand": fatal error
|
||||
Leaving test case "error_on_demand"
|
||||
|
||||
===========================
|
||||
log level: log_test_suites; error type: no error;
|
||||
|
||||
160: Entering test case "error_on_demand"
|
||||
164: Entering test case "error_on_demand"
|
||||
Leaving test case "error_on_demand"
|
||||
|
||||
===========================
|
||||
log level: log_test_suites; error type: user message;
|
||||
|
||||
160: Entering test case "error_on_demand"
|
||||
164: Entering test case "error_on_demand"
|
||||
message
|
||||
Test case error_on_demand did not check any assertions
|
||||
Leaving test case "error_on_demand"
|
||||
@ -61,31 +61,31 @@ Leaving test case "error_on_demand"
|
||||
===========================
|
||||
log level: log_test_suites; error type: user warning;
|
||||
|
||||
160: Entering test case "error_on_demand"
|
||||
103: warning: in "error_on_demand": warning
|
||||
164: Entering test case "error_on_demand"
|
||||
107: warning: in "error_on_demand": warning
|
||||
Test case error_on_demand did not check any assertions
|
||||
Leaving test case "error_on_demand"
|
||||
|
||||
===========================
|
||||
log level: log_test_suites; error type: user non-fatal error;
|
||||
|
||||
160: Entering test case "error_on_demand"
|
||||
107: error: in "error_on_demand": non-fatal error
|
||||
164: Entering test case "error_on_demand"
|
||||
111: error: in "error_on_demand": non-fatal error
|
||||
Leaving test case "error_on_demand"
|
||||
|
||||
===========================
|
||||
log level: log_test_suites; error type: cpp exception;
|
||||
|
||||
160: Entering test case "error_on_demand"
|
||||
164: Entering test case "error_on_demand"
|
||||
0: fatal error: in "error_on_demand": std::runtime_error: test std::runtime error what() message
|
||||
117: last checkpoint: error_on_demand() throw runtime_error
|
||||
121: last checkpoint: error_on_demand() throw runtime_error
|
||||
Leaving test case "error_on_demand"
|
||||
|
||||
===========================
|
||||
log level: log_test_suites; error type: system error;
|
||||
|
||||
160: Entering test case "error_on_demand"
|
||||
111: fatal error: in "error_on_demand": fatal error
|
||||
164: Entering test case "error_on_demand"
|
||||
115: fatal error: in "error_on_demand": fatal error
|
||||
Leaving test case "error_on_demand"
|
||||
|
||||
===========================
|
||||
@ -101,24 +101,24 @@ Test case error_on_demand did not check any assertions
|
||||
===========================
|
||||
log level: log_messages; error type: user warning;
|
||||
|
||||
103: warning: in "error_on_demand": warning
|
||||
107: warning: in "error_on_demand": warning
|
||||
Test case error_on_demand did not check any assertions
|
||||
|
||||
===========================
|
||||
log level: log_messages; error type: user non-fatal error;
|
||||
|
||||
107: error: in "error_on_demand": non-fatal error
|
||||
111: error: in "error_on_demand": non-fatal error
|
||||
|
||||
===========================
|
||||
log level: log_messages; error type: cpp exception;
|
||||
|
||||
0: fatal error: in "error_on_demand": std::runtime_error: test std::runtime error what() message
|
||||
117: last checkpoint: error_on_demand() throw runtime_error
|
||||
121: last checkpoint: error_on_demand() throw runtime_error
|
||||
|
||||
===========================
|
||||
log level: log_messages; error type: system error;
|
||||
|
||||
111: fatal error: in "error_on_demand": fatal error
|
||||
115: fatal error: in "error_on_demand": fatal error
|
||||
|
||||
===========================
|
||||
log level: log_warnings; error type: no error;
|
||||
@ -131,23 +131,23 @@ log level: log_warnings; error type: user message;
|
||||
===========================
|
||||
log level: log_warnings; error type: user warning;
|
||||
|
||||
103: warning: in "error_on_demand": warning
|
||||
107: warning: in "error_on_demand": warning
|
||||
|
||||
===========================
|
||||
log level: log_warnings; error type: user non-fatal error;
|
||||
|
||||
107: error: in "error_on_demand": non-fatal error
|
||||
111: error: in "error_on_demand": non-fatal error
|
||||
|
||||
===========================
|
||||
log level: log_warnings; error type: cpp exception;
|
||||
|
||||
0: fatal error: in "error_on_demand": std::runtime_error: test std::runtime error what() message
|
||||
117: last checkpoint: error_on_demand() throw runtime_error
|
||||
121: last checkpoint: error_on_demand() throw runtime_error
|
||||
|
||||
===========================
|
||||
log level: log_warnings; error type: system error;
|
||||
|
||||
111: fatal error: in "error_on_demand": fatal error
|
||||
115: fatal error: in "error_on_demand": fatal error
|
||||
|
||||
===========================
|
||||
log level: log_all_errors; error type: no error;
|
||||
@ -164,18 +164,18 @@ log level: log_all_errors; error type: user warning;
|
||||
===========================
|
||||
log level: log_all_errors; error type: user non-fatal error;
|
||||
|
||||
107: error: in "error_on_demand": non-fatal error
|
||||
111: error: in "error_on_demand": non-fatal error
|
||||
|
||||
===========================
|
||||
log level: log_all_errors; error type: cpp exception;
|
||||
|
||||
0: fatal error: in "error_on_demand": std::runtime_error: test std::runtime error what() message
|
||||
117: last checkpoint: error_on_demand() throw runtime_error
|
||||
121: last checkpoint: error_on_demand() throw runtime_error
|
||||
|
||||
===========================
|
||||
log level: log_all_errors; error type: system error;
|
||||
|
||||
111: fatal error: in "error_on_demand": fatal error
|
||||
115: fatal error: in "error_on_demand": fatal error
|
||||
|
||||
===========================
|
||||
log level: log_cpp_exception_errors; error type: no error;
|
||||
@ -197,12 +197,12 @@ log level: log_cpp_exception_errors; error type: user non-fatal error;
|
||||
log level: log_cpp_exception_errors; error type: cpp exception;
|
||||
|
||||
0: fatal error: in "error_on_demand": std::runtime_error: test std::runtime error what() message
|
||||
117: last checkpoint: error_on_demand() throw runtime_error
|
||||
121: last checkpoint: error_on_demand() throw runtime_error
|
||||
|
||||
===========================
|
||||
log level: log_cpp_exception_errors; error type: system error;
|
||||
|
||||
111: fatal error: in "error_on_demand": fatal error
|
||||
115: fatal error: in "error_on_demand": fatal error
|
||||
|
||||
===========================
|
||||
log level: log_system_errors; error type: no error;
|
||||
@ -227,7 +227,7 @@ log level: log_system_errors; error type: cpp exception;
|
||||
===========================
|
||||
log level: log_system_errors; error type: system error;
|
||||
|
||||
111: fatal error: in "error_on_demand": fatal error
|
||||
115: fatal error: in "error_on_demand": fatal error
|
||||
|
||||
===========================
|
||||
log level: log_fatal_errors; error type: no error;
|
||||
@ -252,7 +252,7 @@ log level: log_fatal_errors; error type: cpp exception;
|
||||
===========================
|
||||
log level: log_fatal_errors; error type: system error;
|
||||
|
||||
111: fatal error: in "error_on_demand": fatal error
|
||||
115: fatal error: in "error_on_demand": fatal error
|
||||
|
||||
===========================
|
||||
log level: log_nothing; error type: no error;
|
||||
|
@ -21,6 +21,9 @@
|
||||
#include <boost/test/utils/nullstream.hpp>
|
||||
typedef boost::onullstream onullstream_type;
|
||||
|
||||
// BOOST
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
// STL
|
||||
#include <iostream>
|
||||
|
||||
|
@ -1,114 +0,0 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
/// @file
|
||||
/// @brief string_cast unit test
|
||||
// *****************************************************************************
|
||||
|
||||
// Boost.Test
|
||||
#define BOOST_TEST_MODULE string_cast unit test
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/utils/string_cast.hpp>
|
||||
|
||||
namespace utu = boost::unit_test::utils;
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
struct A {
|
||||
A(int i_) : i(i_) {}
|
||||
int i;
|
||||
};
|
||||
|
||||
inline std::ostream&
|
||||
operator<<(std::ostream& ostr, A const& a) { return ostr << "A{i=" << a.i << "}"; }
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
BOOST_AUTO_TEST_CASE( test_string_cast )
|
||||
{
|
||||
BOOST_TEST( utu::string_cast( 1 ) == "1" );
|
||||
BOOST_TEST( utu::string_cast( 1.1 ) == "1.1" );
|
||||
BOOST_TEST( utu::string_cast( -1 ) == "-1" );
|
||||
BOOST_TEST( utu::string_cast( 1U ) == "1" );
|
||||
BOOST_TEST( utu::string_cast( 100000000000L ) == "100000000000" );
|
||||
BOOST_TEST( utu::string_cast( 1LL << 55 ) == "36028797018963968" );
|
||||
BOOST_TEST( utu::string_cast( 'a' ) == "a" );
|
||||
BOOST_TEST( utu::string_cast( "abc" ) == "abc" );
|
||||
BOOST_TEST( utu::string_cast( A(12) ) == "A{i=12}" );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
BOOST_AUTO_TEST_CASE( test_string_as )
|
||||
{
|
||||
int ival;
|
||||
|
||||
BOOST_TEST( utu::string_as<int>( "1", ival ) );
|
||||
BOOST_TEST( ival == 1 );
|
||||
|
||||
BOOST_TEST( utu::string_as<int>( " 2", ival ) );
|
||||
BOOST_TEST( ival == 2 );
|
||||
|
||||
BOOST_TEST( utu::string_as<int>( "+3", ival ) );
|
||||
BOOST_TEST( ival == 3 );
|
||||
|
||||
BOOST_TEST( utu::string_as<int>( "-2", ival ) );
|
||||
BOOST_TEST( ival == -2 );
|
||||
|
||||
double dval;
|
||||
|
||||
BOOST_TEST( utu::string_as<double>( "0.32", dval ) );
|
||||
BOOST_TEST( dval == 0.32 );
|
||||
|
||||
BOOST_TEST( utu::string_as<double>( "-1e-3", dval ) );
|
||||
BOOST_TEST( dval == -0.001 );
|
||||
|
||||
unsigned uval;
|
||||
|
||||
BOOST_TEST( utu::string_as<unsigned>( "123", uval ) );
|
||||
BOOST_TEST( uval == 123U );
|
||||
|
||||
long lval;
|
||||
|
||||
BOOST_TEST( utu::string_as<long>( "909090", lval ) );
|
||||
BOOST_TEST( lval == 909090 );
|
||||
|
||||
long long llval;
|
||||
|
||||
BOOST_TEST( utu::string_as<long long>( "1234123412341234", llval ) );
|
||||
BOOST_TEST( llval == 1234123412341234LL );
|
||||
|
||||
std::string sval;
|
||||
|
||||
BOOST_TEST( utu::string_as<std::string>( "abc", sval ) );
|
||||
BOOST_TEST( sval == "abc" );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
BOOST_AUTO_TEST_CASE( test_string_as_validations )
|
||||
{
|
||||
int ival;
|
||||
|
||||
BOOST_TEST( !utu::string_as<int>( "1a", ival ) );
|
||||
BOOST_TEST( !utu::string_as<int>( "1 ", ival ) );
|
||||
|
||||
double dval;
|
||||
|
||||
BOOST_TEST( !utu::string_as<double>( "1e-0.1", dval ) );
|
||||
BOOST_TEST( !utu::string_as<double>( "1.001.1 ", dval ) );
|
||||
|
||||
unsigned uval;
|
||||
|
||||
BOOST_TEST( !utu::string_as<unsigned>( "1.1", uval ) );
|
||||
|
||||
std::string sval;
|
||||
|
||||
BOOST_TEST( !utu::string_as<std::string>( "a b", sval ) );
|
||||
}
|
||||
|
||||
// EOF
|
@ -134,9 +134,4 @@ BOOST_AUTO_TEST_CASE( test_lexicographic_ge )
|
||||
BOOST_TEST( b >= a, tt::lexicographic() );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( test_collction_of_collection_comp )
|
||||
{
|
||||
BOOST_TEST( std::string("abc") == std::string("abc") );
|
||||
}
|
||||
|
||||
// EOF
|
||||
|
Loading…
Reference in New Issue
Block a user