From 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 20:24:20 +0200 Subject: Adding upstream version 14.2.21. Signed-off-by: Daniel Baumann --- src/boost/libs/variant/test/test5.cpp | 90 +++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 src/boost/libs/variant/test/test5.cpp (limited to 'src/boost/libs/variant/test/test5.cpp') diff --git a/src/boost/libs/variant/test/test5.cpp b/src/boost/libs/variant/test/test5.cpp new file mode 100644 index 00000000..5de06c8c --- /dev/null +++ b/src/boost/libs/variant/test/test5.cpp @@ -0,0 +1,90 @@ +//----------------------------------------------------------------------------- +// boost-libs variant/test/test5.cpp header file +// See http://www.boost.org for updates, documentation, and revision history. +//----------------------------------------------------------------------------- +// +// Copyright (c) 2003 +// Eric Friedman, Itay Maman +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include "boost/core/lightweight_test.hpp" +#include "boost/variant.hpp" + +#include "jobs.h" + +#include +#include +#include +#include + + +void run() +{ + using std::string; + using boost::variant; + using boost::apply_visitor; + + typedef variant t_var1; + typedef variant t_var2; + typedef variant t_var3; + + t_var1 v1; + t_var2 v2; + t_var2 v2_second; + t_var3 v3; + + const char c0 = 'x'; + v1 = c0; + + //v2 and v3 are holding (aka: containing) a variant + v2 = v1; + v3 = v2; + + verify(v1, spec()); + verify(v2, spec()); + verify(v3, spec()); + + + // + // assignment from const char (Converted to int) + // + v2 = c0; + v3 = c0; + + verify(v2, spec()); + verify(v3, spec()); + + + BOOST_TEST(apply_visitor(sum_int(), v2) == c0); + BOOST_TEST(apply_visitor(sum_int(), v3) == c0); + + sum_int adder; + apply_visitor(adder, v2); + apply_visitor(adder, v3); + + BOOST_TEST(adder.result() == 2*c0); + + // + // A variant holding a variant + // + typedef variant t_var4; + typedef variant t_var5; + + t_var4 v4; + t_var5 v5; + + v5 = 22.5f; + verify(v5, spec(), "[V] [V] 22.5"); +} + + + +int main() +{ + run(); + return boost::report_errors(); +} + -- cgit v1.2.3