Update contrib.
1 //-----------------------------------------------------------------------------
2 // boost-libs variant/test/test5.cpp header file
3 // See http://www.boost.org for updates, documentation, and revision history.
4 //-----------------------------------------------------------------------------
7 // Eric Friedman, Itay Maman
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)
13 * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
16 #include "boost/test/minimal.hpp"
17 #include "boost/variant.hpp"
26 #include "std_log_result.h"
27 #define LOG_FILENAME_LINE __FILE__, __LINE__
33 using boost::apply_visitor;
35 typedef variant<int, float, unsigned short, unsigned char> t_var1;
36 typedef variant<int, t_var1, unsigned short, unsigned char> t_var2;
37 typedef variant<string, int, t_var2> t_var3;
47 //v2 and v3 are holding (aka: containing) a variant
51 verify(v1, spec<int>());
52 verify(v2, spec<t_var1>());
53 verify(v3, spec<t_var2>());
57 // assignment from const char (Converted to int)
62 verify(v2, spec<int>());
63 verify(v3, spec<int>());
66 BOOST_CHECK(apply_visitor(sum_int(), v2) == c0);
67 BOOST_CHECK(apply_visitor(sum_int(), v3) == c0);
70 apply_visitor(adder, v2);
71 apply_visitor(adder, v3);
73 BOOST_CHECK(adder.result() == 2*c0);
76 // A variant holding a variant
78 typedef variant<unsigned char, float> t_var4;
79 typedef variant<string, t_var4> t_var5;
85 verify(v5, spec<t_var4>(), "[V] [V] 22.5");
90 int test_main(int , char* [])
92 std_log(LOG_FILENAME_LINE,"[Test Case for test5]");
95 testResultXml("test5");