1
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
3
// Use, modification, and distribution is subject to the Boost Software
4
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5
// http://www.boost.org/LICENSE_1_0.txt)
7
// See http://www.boost.org/lib/optional for documentation.
9
// You are welcome to contact the author at:
10
// fernando_cacciola@hotmail.com
16
#define BOOST_ENABLE_ASSERT_HANDLER
18
#include "boost/optional/optional.hpp"
19
#include "boost/optional/optional_io.hpp"
20
#include "boost/none.hpp"
22
#include "boost/test/minimal.hpp"
25
#define TRACE(msg) std::cout << msg << std::endl ;
32
void assertion_failed (char const * expr, char const * func, char const * file, long )
35
string msg = string("Boost assertion failure for \"")
37
+ string("\" at file \"")
39
+ string("\" function \"")
45
throw std::logic_error(msg);
51
using namespace boost ;
54
void test2( Opt o, Opt buff )
58
const int markv = 123 ;
61
s << o << " " << markv ;
64
BOOST_ASSERT( buff == o ) ;
65
BOOST_ASSERT( mark == markv ) ;
72
test2( make_optional(v), optional<T> ());
73
test2( make_optional(v), make_optional(w));
74
test2( optional<T> () , optional<T> ());
75
test2( optional<T> () , make_optional(w));
78
int test_main( int, char* [] )
83
test(string("hello"),string("buffer"));
87
BOOST_ERROR("Unexpected Exception caught!");