diff options
Diffstat (limited to 'libs/optional/test/optional_test_inplace_fail.cpp')
-rw-r--r-- | libs/optional/test/optional_test_inplace_fail.cpp | 67 |
1 files changed, 30 insertions, 37 deletions
diff --git a/libs/optional/test/optional_test_inplace_fail.cpp b/libs/optional/test/optional_test_inplace_fail.cpp index c6ba1d62e..bb7c26f6c 100644 --- a/libs/optional/test/optional_test_inplace_fail.cpp +++ b/libs/optional/test/optional_test_inplace_fail.cpp @@ -1,4 +1,5 @@ // Copyright (C) 2003, Fernando Luis Cacciola Carballal. +// Copyright (C) 2015 Andrzej Krzemienski. // // Use, modification, and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -8,53 +9,45 @@ // // You are welcome to contact the author at: // fernando_cacciola@hotmail.com -// -#include<iostream> -#include<stdexcept> -#include<string> - -#define BOOST_ENABLE_ASSERT_HANDLER +#include<string> #include "boost/optional/optional.hpp" -#ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT -#include "boost/utility/in_place_factory.hpp" -#endif - #ifdef __BORLANDC__ #pragma hdrstop #endif -#include "boost/test/minimal.hpp" - -#include "optional_test_common.cpp" - #ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT -struct A -{ - A ( double a0, std::string a1 ) : m_a0(a0), m_a1(a1) {} - - friend bool operator == ( A const& x, A const& y ) - { return x.m_a0 == y.m_a0 && x.m_a1 == y.m_a1 ; } +#include "boost/utility/in_place_factory.hpp" +#include "boost/utility/typed_in_place_factory.hpp" +#endif - double m_a0 ; - std::string m_a1 ; -} ; +#include "boost/core/lightweight_test.hpp" +#include "boost/none.hpp" -int test_main( int, char* [] ) +struct Guard { - int invalid_extra_parameter ; - boost::optional<A> opt2 ( boost::in_place(3.14,"pi",invalid_extra_parameter) ) ; - - return 0; -} -#else -int test_main( int, char* [] ) + double num; + std::string str; + Guard() : num() {} + Guard(double num_, std::string str_) : num(num_), str(str_) {} + + friend bool operator==(const Guard& lhs, const Guard& rhs) { return lhs.num == rhs.num && lhs.str == rhs.str; } + friend bool operator!=(const Guard& lhs, const Guard& rhs) { return !(lhs == rhs); } + +private: + Guard(const Guard&); + Guard& operator=(const Guard&); +}; + + +int main() { - int invalid_extra_parameter ; - boost::optional<A> opt2 ( A(3.14,"pi",invalid_extra_parameter) ) ; - - return 0; -} +#ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT + int excessive_param = 2; + boost::optional<Guard> og1 ( boost::in_place(1.0, "one", excessive_param) ); +#else + NOTHING_TO_TEST_SO_JUST_FAIL #endif - + return 0; +}
\ No newline at end of file |