1 | //----------------------------------------------------------------------------- |
---|
2 | // boost-libs variant/test/test4.cpp source file |
---|
3 | // See http://www.boost.org for updates, documentation, and revision history. |
---|
4 | //----------------------------------------------------------------------------- |
---|
5 | // |
---|
6 | // Copyright (c) 2003 |
---|
7 | // Eric Friedman, Itay Maman |
---|
8 | // |
---|
9 | // Distributed under the Boost Software License, Version 1.0. (See |
---|
10 | // accompanying file LICENSE_1_0.txt or copy at |
---|
11 | // http://www.boost.org/LICENSE_1_0.txt) |
---|
12 | |
---|
13 | #include "boost/test/minimal.hpp" |
---|
14 | #include "boost/variant.hpp" |
---|
15 | |
---|
16 | #include "jobs.h" |
---|
17 | |
---|
18 | #include <string> |
---|
19 | |
---|
20 | struct class_a; |
---|
21 | |
---|
22 | using boost::variant; |
---|
23 | |
---|
24 | typedef variant<std::string, class_a, float> var_type_1; |
---|
25 | typedef variant<std::string, class_a, short> var_type_2; |
---|
26 | |
---|
27 | #include "class_a.h" |
---|
28 | |
---|
29 | int test_main(int , char* []) |
---|
30 | { |
---|
31 | using namespace boost; |
---|
32 | |
---|
33 | var_type_1 v1; |
---|
34 | var_type_2 v2; |
---|
35 | |
---|
36 | v1 = class_a(); |
---|
37 | verify(v1, spec<class_a>(), "[V] class_a(5511)"); |
---|
38 | |
---|
39 | verify(v2, spec<std::string>(), "[V] "); |
---|
40 | |
---|
41 | v2 = "abcde"; |
---|
42 | verify(v2, spec<std::string>(), "[V] abcde"); |
---|
43 | |
---|
44 | v2 = v1; |
---|
45 | verify(v2, spec<class_a>(), "[V] class_a(5511)"); |
---|
46 | |
---|
47 | v2 = 5; |
---|
48 | v1 = v2; |
---|
49 | |
---|
50 | return boost::exit_success; |
---|
51 | } |
---|