1 | // Copyright (C) 2003, Fernando Luis Cacciola Carballal. |
---|
2 | // |
---|
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) |
---|
6 | // |
---|
7 | // See http://www.boost.org/lib/optional for documentation. |
---|
8 | // |
---|
9 | // You are welcome to contact the author at: |
---|
10 | // fernando_cacciola@hotmail.com |
---|
11 | // |
---|
12 | #include<iostream> |
---|
13 | #include<stdexcept> |
---|
14 | #include<string> |
---|
15 | |
---|
16 | #define BOOST_ENABLE_ASSERT_HANDLER |
---|
17 | |
---|
18 | #include "boost/optional.hpp" |
---|
19 | #include "boost/tuple/tuple.hpp" |
---|
20 | |
---|
21 | #ifdef __BORLANDC__ |
---|
22 | #pragma hdrstop |
---|
23 | #endif |
---|
24 | |
---|
25 | #include "boost/test/minimal.hpp" |
---|
26 | |
---|
27 | #include "optional_test_common.cpp" |
---|
28 | |
---|
29 | // Test boost::tie() interoperabiliy. |
---|
30 | int test_main( int, char* [] ) |
---|
31 | { |
---|
32 | typedef X T ; |
---|
33 | |
---|
34 | try |
---|
35 | { |
---|
36 | TRACE( std::endl << BOOST_CURRENT_FUNCTION ); |
---|
37 | |
---|
38 | T z(0); |
---|
39 | T a(1); |
---|
40 | T b(2); |
---|
41 | |
---|
42 | optional<T> oa, ob ; |
---|
43 | |
---|
44 | // T::T( T const& x ) is used |
---|
45 | set_pending_dtor( ARG(T) ) ; |
---|
46 | set_pending_copy( ARG(T) ) ; |
---|
47 | boost::tie(oa,ob) = std::make_pair(a,b) ; |
---|
48 | check_is_not_pending_dtor( ARG(T) ) ; |
---|
49 | check_is_not_pending_copy( ARG(T) ) ; |
---|
50 | check_initialized(oa); |
---|
51 | check_initialized(ob); |
---|
52 | check_value(oa,a,z); |
---|
53 | check_value(ob,b,z); |
---|
54 | |
---|
55 | } |
---|
56 | catch ( ... ) |
---|
57 | { |
---|
58 | BOOST_ERROR("Unexpected Exception caught!"); |
---|
59 | } |
---|
60 | |
---|
61 | return 0; |
---|
62 | } |
---|
63 | |
---|
64 | |
---|