mirror of
https://github.com/boostorg/variant.git
synced 2026-07-21 13:43:36 +00:00
Replace boost/test/minimal.hpp from Boost.Test with boost/core/lightweight_test.hpp
This commit is contained in:
+4
-2
@@ -1,15 +1,17 @@
|
||||
# Boost.Variant Library test Jamfile
|
||||
#
|
||||
# Copyright (C) 2003, Eric Friedman, Itay Maman.
|
||||
# Copyright (C) 2013, Antony Polukhin.
|
||||
# Copyright (C) 2013-2018, Antony Polukhin.
|
||||
#
|
||||
# Use, modification and distribution is subject to 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)
|
||||
#
|
||||
|
||||
import testing ;
|
||||
|
||||
project
|
||||
: requirements
|
||||
#<dependency>/boost/test//minimal
|
||||
<toolset>msvc:<asynch-exceptions>on
|
||||
;
|
||||
test-suite variant
|
||||
|
||||
+54
-54
@@ -3,7 +3,7 @@
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2014-2015 Antony Polukhin
|
||||
// Copyright (c) 2014-2018 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include "boost/config.hpp"
|
||||
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/variant.hpp"
|
||||
#include "boost/variant/multivisitors.hpp"
|
||||
#include "boost/lexical_cast.hpp"
|
||||
@@ -50,24 +50,24 @@ void test_has_result_type_triat() {
|
||||
using namespace has_result_type_tests;
|
||||
using boost::detail::variant::has_result_type;
|
||||
|
||||
BOOST_CHECK(has_result_type<s1>::value);
|
||||
BOOST_CHECK(has_result_type<s2>::value);
|
||||
BOOST_CHECK(has_result_type<s3>::value);
|
||||
BOOST_CHECK(!has_result_type<s4>::value);
|
||||
BOOST_CHECK(has_result_type<s5>::value);
|
||||
BOOST_CHECK(has_result_type<s6>::value);
|
||||
BOOST_CHECK(has_result_type<s7>::value);
|
||||
BOOST_CHECK(has_result_type<s8>::value);
|
||||
BOOST_CHECK(has_result_type<s9>::value);
|
||||
BOOST_TEST(has_result_type<s1>::value);
|
||||
BOOST_TEST(has_result_type<s2>::value);
|
||||
BOOST_TEST(has_result_type<s3>::value);
|
||||
BOOST_TEST(!has_result_type<s4>::value);
|
||||
BOOST_TEST(has_result_type<s5>::value);
|
||||
BOOST_TEST(has_result_type<s6>::value);
|
||||
BOOST_TEST(has_result_type<s7>::value);
|
||||
BOOST_TEST(has_result_type<s8>::value);
|
||||
BOOST_TEST(has_result_type<s9>::value);
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
BOOST_CHECK(has_result_type<s10>::value);
|
||||
BOOST_TEST(has_result_type<s10>::value);
|
||||
#endif
|
||||
BOOST_CHECK(has_result_type<s11>::value);
|
||||
BOOST_CHECK(has_result_type<s12>::value);
|
||||
BOOST_CHECK(has_result_type<s13>::value);
|
||||
BOOST_CHECK(has_result_type<s14>::value);
|
||||
BOOST_CHECK(has_result_type<s15>::value);
|
||||
BOOST_CHECK(has_result_type<s16>::value);
|
||||
BOOST_TEST(has_result_type<s11>::value);
|
||||
BOOST_TEST(has_result_type<s12>::value);
|
||||
BOOST_TEST(has_result_type<s13>::value);
|
||||
BOOST_TEST(has_result_type<s14>::value);
|
||||
BOOST_TEST(has_result_type<s15>::value);
|
||||
BOOST_TEST(has_result_type<s16>::value);
|
||||
}
|
||||
|
||||
struct lex_streamer_explicit: boost::static_visitor<std::string> {
|
||||
@@ -91,8 +91,8 @@ void run_explicit()
|
||||
lex_streamer_explicit visitor_ref;
|
||||
|
||||
// Must return instance of std::string
|
||||
BOOST_CHECK(boost::apply_visitor(visitor_ref, v2).c_str() == std::string("10"));
|
||||
BOOST_CHECK(boost::apply_visitor(visitor_ref, v2, v1).c_str() == std::string("100"));
|
||||
BOOST_TEST(boost::apply_visitor(visitor_ref, v2).c_str() == std::string("10"));
|
||||
BOOST_TEST(boost::apply_visitor(visitor_ref, v2, v1).c_str() == std::string("100"));
|
||||
}
|
||||
|
||||
|
||||
@@ -102,18 +102,18 @@ void run_explicit()
|
||||
|
||||
void run()
|
||||
{
|
||||
BOOST_CHECK(true);
|
||||
BOOST_TEST(true);
|
||||
}
|
||||
|
||||
void run2()
|
||||
{
|
||||
BOOST_CHECK(true);
|
||||
BOOST_TEST(true);
|
||||
}
|
||||
|
||||
|
||||
void run3()
|
||||
{
|
||||
BOOST_CHECK(true);
|
||||
BOOST_TEST(true);
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -189,9 +189,9 @@ struct lex_streamer2 {
|
||||
};
|
||||
|
||||
#ifndef BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
# define BOOST_CHECK_IF_HAS_VARIADIC(x) BOOST_CHECK(x)
|
||||
# define BOOST_TEST_IF_HAS_VARIADIC(x) BOOST_TEST(x)
|
||||
#else
|
||||
# define BOOST_CHECK_IF_HAS_VARIADIC(x) /**/
|
||||
# define BOOST_TEST_IF_HAS_VARIADIC(x) /**/
|
||||
#endif
|
||||
|
||||
void run()
|
||||
@@ -200,29 +200,29 @@ void run()
|
||||
variant_type v1(1), v2("10"), v3(100.0);
|
||||
lex_streamer lex_streamer_visitor;
|
||||
|
||||
BOOST_CHECK(boost::apply_visitor(lex_streamer(), v1) == "1");
|
||||
BOOST_CHECK_IF_HAS_VARIADIC(boost::apply_visitor(lex_streamer_visitor)(v1) == "1");
|
||||
BOOST_CHECK(boost::apply_visitor(lex_streamer(), v2) == "10");
|
||||
BOOST_CHECK_IF_HAS_VARIADIC(boost::apply_visitor(lex_streamer_visitor)(v2) == "10");
|
||||
BOOST_TEST(boost::apply_visitor(lex_streamer(), v1) == "1");
|
||||
BOOST_TEST_IF_HAS_VARIADIC(boost::apply_visitor(lex_streamer_visitor)(v1) == "1");
|
||||
BOOST_TEST(boost::apply_visitor(lex_streamer(), v2) == "10");
|
||||
BOOST_TEST_IF_HAS_VARIADIC(boost::apply_visitor(lex_streamer_visitor)(v2) == "10");
|
||||
|
||||
#ifndef BOOST_NO_CXX14_GENERIC_LAMBDAS
|
||||
BOOST_CHECK(boost::apply_visitor([](auto v) { return boost::lexical_cast<std::string>(v); }, v1) == "1");
|
||||
BOOST_CHECK(boost::apply_visitor([](auto v) { return boost::lexical_cast<std::string>(v); }, v2) == "10");
|
||||
BOOST_TEST(boost::apply_visitor([](auto v) { return boost::lexical_cast<std::string>(v); }, v1) == "1");
|
||||
BOOST_TEST(boost::apply_visitor([](auto v) { return boost::lexical_cast<std::string>(v); }, v2) == "10");
|
||||
|
||||
// Retun type must be the same in all instances, so this code does not compile
|
||||
//boost::variant<int, short, unsigned> v_diff_types(1);
|
||||
//BOOST_CHECK(boost::apply_visitor([](auto v) { return v; }, v_diff_types) == 1);
|
||||
//BOOST_TEST(boost::apply_visitor([](auto v) { return v; }, v_diff_types) == 1);
|
||||
|
||||
boost::apply_visitor([](auto v) { std::cout << v << std::endl; }, v1);
|
||||
boost::apply_visitor([](auto v) { std::cout << v << std::endl; }, v2);
|
||||
#endif
|
||||
|
||||
lex_streamer2 visitor_ref;
|
||||
BOOST_CHECK(boost::apply_visitor(visitor_ref, v1) == "1");
|
||||
BOOST_CHECK(boost::apply_visitor(visitor_ref, v2) == "10");
|
||||
BOOST_TEST(boost::apply_visitor(visitor_ref, v1) == "1");
|
||||
BOOST_TEST(boost::apply_visitor(visitor_ref, v2) == "10");
|
||||
#ifndef BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
std::string& ref_to_string = boost::apply_visitor(visitor_ref, v1);
|
||||
BOOST_CHECK(ref_to_string == "1");
|
||||
BOOST_TEST(ref_to_string == "1");
|
||||
#endif
|
||||
lex_streamer_void lex_streamer_void_visitor;
|
||||
boost::apply_visitor(lex_streamer_void(), v1);
|
||||
@@ -256,13 +256,13 @@ void run2()
|
||||
variant_type v1(1), v2("10"), v3(100.0);
|
||||
lex_combine lex_combine_visitor;
|
||||
|
||||
BOOST_CHECK(boost::apply_visitor(lex_combine(), v1, v2) == "1+10");
|
||||
BOOST_CHECK(boost::apply_visitor(lex_combine(), v2, v1) == "10+1");
|
||||
BOOST_CHECK_IF_HAS_VARIADIC(boost::apply_visitor(lex_combine_visitor)(v2, v1) == "10+1");
|
||||
BOOST_TEST(boost::apply_visitor(lex_combine(), v1, v2) == "1+10");
|
||||
BOOST_TEST(boost::apply_visitor(lex_combine(), v2, v1) == "10+1");
|
||||
BOOST_TEST_IF_HAS_VARIADIC(boost::apply_visitor(lex_combine_visitor)(v2, v1) == "10+1");
|
||||
|
||||
|
||||
#ifndef BOOST_NO_CXX14_GENERIC_LAMBDAS
|
||||
BOOST_CHECK(
|
||||
BOOST_TEST(
|
||||
boost::apply_visitor(
|
||||
[](auto v1, auto v2) {
|
||||
return boost::lexical_cast<std::string>(v1) + "+"
|
||||
@@ -272,7 +272,7 @@ void run2()
|
||||
, v2
|
||||
) == "1+10"
|
||||
);
|
||||
BOOST_CHECK(
|
||||
BOOST_TEST(
|
||||
boost::apply_visitor(
|
||||
[](auto v1, auto v2) {
|
||||
return boost::lexical_cast<std::string>(v1) + "+"
|
||||
@@ -289,11 +289,11 @@ void run2()
|
||||
|
||||
|
||||
lex_streamer2 visitor_ref;
|
||||
BOOST_CHECK(boost::apply_visitor(visitor_ref, v1, v2) == "1+10");
|
||||
BOOST_CHECK(boost::apply_visitor(visitor_ref, v2, v1) == "10+1");
|
||||
BOOST_TEST(boost::apply_visitor(visitor_ref, v1, v2) == "1+10");
|
||||
BOOST_TEST(boost::apply_visitor(visitor_ref, v2, v1) == "10+1");
|
||||
#ifndef BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
std::string& ref_to_string = boost::apply_visitor(visitor_ref)(v1, v2);
|
||||
BOOST_CHECK(ref_to_string == "1+10");
|
||||
BOOST_TEST(ref_to_string == "1+10");
|
||||
#endif
|
||||
|
||||
boost::apply_visitor(lex_streamer_void(), v1, v2);
|
||||
@@ -302,7 +302,7 @@ void run2()
|
||||
boost::ignore_unused(lex_combine_visitor, visitor_ref);
|
||||
}
|
||||
|
||||
#undef BOOST_CHECK_IF_HAS_VARIADIC
|
||||
#undef BOOST_TEST_IF_HAS_VARIADIC
|
||||
|
||||
void run3()
|
||||
{
|
||||
@@ -311,13 +311,13 @@ void run3()
|
||||
variant_type v1(1), v2("10"), v3(100);
|
||||
lex_combine lex_combine_visitor;
|
||||
|
||||
BOOST_CHECK(boost::apply_visitor(lex_combine(), v1, v2, v3) == "1+10+100");
|
||||
BOOST_CHECK(boost::apply_visitor(lex_combine(), v2, v1, v3) == "10+1+100");
|
||||
BOOST_CHECK(boost::apply_visitor(lex_combine_visitor)(v2, v1, v3) == "10+1+100");
|
||||
BOOST_TEST(boost::apply_visitor(lex_combine(), v1, v2, v3) == "1+10+100");
|
||||
BOOST_TEST(boost::apply_visitor(lex_combine(), v2, v1, v3) == "10+1+100");
|
||||
BOOST_TEST(boost::apply_visitor(lex_combine_visitor)(v2, v1, v3) == "10+1+100");
|
||||
|
||||
|
||||
#ifndef BOOST_NO_CXX14_GENERIC_LAMBDAS
|
||||
BOOST_CHECK(
|
||||
BOOST_TEST(
|
||||
boost::apply_visitor(
|
||||
[](auto v1, auto v2, auto v3) {
|
||||
return boost::lexical_cast<std::string>(v1) + "+"
|
||||
@@ -329,7 +329,7 @@ void run3()
|
||||
, v3
|
||||
) == "1+10+100"
|
||||
);
|
||||
BOOST_CHECK(
|
||||
BOOST_TEST(
|
||||
boost::apply_visitor(
|
||||
[](auto v1, auto v2, auto v3) {
|
||||
return boost::lexical_cast<std::string>(v1) + "+"
|
||||
@@ -354,10 +354,10 @@ void run3()
|
||||
|
||||
|
||||
lex_streamer2 visitor_ref;
|
||||
BOOST_CHECK(boost::apply_visitor(visitor_ref, v1, v2) == "1+10");
|
||||
BOOST_CHECK(boost::apply_visitor(visitor_ref)(v2, v1) == "10+1");
|
||||
BOOST_TEST(boost::apply_visitor(visitor_ref, v1, v2) == "1+10");
|
||||
BOOST_TEST(boost::apply_visitor(visitor_ref)(v2, v1) == "10+1");
|
||||
std::string& ref_to_string = boost::apply_visitor(visitor_ref, v1, v2);
|
||||
BOOST_CHECK(ref_to_string == "1+10");
|
||||
BOOST_TEST(ref_to_string == "1+10");
|
||||
|
||||
lex_streamer_void lex_streamer_void_visitor;
|
||||
boost::apply_visitor(lex_streamer_void(), v1, v2, v1);
|
||||
@@ -368,7 +368,7 @@ void run3()
|
||||
#endif
|
||||
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
run_explicit();
|
||||
run();
|
||||
@@ -376,5 +376,5 @@ int test_main(int , char* [])
|
||||
run3();
|
||||
test_has_result_type_triat();
|
||||
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "boost/config.hpp"
|
||||
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/variant.hpp"
|
||||
#include "boost/variant/apply_visitor.hpp"
|
||||
#include "boost/variant/multivisitors.hpp"
|
||||
@@ -131,21 +131,21 @@ void test_const_ref_parameter(const variant_type& test_var)
|
||||
{
|
||||
std::cout << "Testing const lvalue reference visitable\n";
|
||||
|
||||
BOOST_CHECK(boost::apply_visitor(lvalue_rvalue_detector(), test_var) == "lvalue reference");
|
||||
BOOST_TEST(boost::apply_visitor(lvalue_rvalue_detector(), test_var) == "lvalue reference");
|
||||
}
|
||||
|
||||
void test_const_ref_parameter2(const variant_type& test_var, const variant_type& test_var2)
|
||||
{
|
||||
std::cout << "Testing const lvalue reference visitable\n";
|
||||
|
||||
BOOST_CHECK(boost::apply_visitor(lvalue_rvalue_detector(), test_var, test_var2) == "lvalue reference, lvalue reference");
|
||||
BOOST_TEST(boost::apply_visitor(lvalue_rvalue_detector(), test_var, test_var2) == "lvalue reference, lvalue reference");
|
||||
}
|
||||
|
||||
void test_const_ref_parameter4(const variant_type& test_var, const variant_type& test_var2, const variant_type& test_var3, const variant_type& test_var4)
|
||||
{
|
||||
std::cout << "Testing const lvalue reference visitable with multivisitor\n";
|
||||
|
||||
BOOST_CHECK(boost::apply_visitor(lvalue_rvalue_detector(), test_var, test_var2, test_var3, test_var4)
|
||||
BOOST_TEST(boost::apply_visitor(lvalue_rvalue_detector(), test_var, test_var2, test_var3, test_var4)
|
||||
== "lvalue reference, lvalue reference, lvalue reference, lvalue reference");
|
||||
}
|
||||
|
||||
@@ -156,14 +156,14 @@ void test_rvalue_parameter(variant_type&& test_var)
|
||||
std::cout << "Testing rvalue visitable\n";
|
||||
|
||||
const auto expected_val = lcs(test_var);
|
||||
BOOST_CHECK(boost::apply_visitor(lvalue_rvalue_detector(), std::move(test_var)) == "rvalue reference");
|
||||
BOOST_TEST(boost::apply_visitor(lvalue_rvalue_detector(), std::move(test_var)) == "rvalue reference");
|
||||
}
|
||||
|
||||
void test_rvalue_parameter2(variant_type&& test_var, variant_type&& test_var2)
|
||||
{
|
||||
std::cout << "Testing rvalue visitable\n";
|
||||
|
||||
BOOST_CHECK(boost::apply_visitor(lvalue_rvalue_detector(), std::move(test_var), std::move(test_var2)) == "rvalue reference, rvalue reference");
|
||||
BOOST_TEST(boost::apply_visitor(lvalue_rvalue_detector(), std::move(test_var), std::move(test_var2)) == "rvalue reference, rvalue reference");
|
||||
}
|
||||
|
||||
void test_rvalue_parameter4(variant_type&& test_var, variant_type&& test_var2, variant_type&& test_var3, variant_type&& test_var4)
|
||||
@@ -173,7 +173,7 @@ void test_rvalue_parameter4(variant_type&& test_var, variant_type&& test_var2, v
|
||||
|
||||
auto result = boost::apply_visitor(lvalue_rvalue_detector(), std::move(test_var), std::move(test_var2), std::move(test_var3), std::move(test_var4));
|
||||
std::cout << "result: " << result << std::endl;
|
||||
BOOST_CHECK(result == "rvalue reference, rvalue reference, rvalue reference, rvalue reference");
|
||||
BOOST_TEST(result == "rvalue reference, rvalue reference, rvalue reference, rvalue reference");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -187,21 +187,21 @@ void test_cpp14_visitor(const variant_type& test_var)
|
||||
{
|
||||
std::cout << "Testing const lvalue visitable for c++14\n";
|
||||
|
||||
BOOST_CHECK(boost::apply_visitor([](auto&& v) { return lvalue_rvalue_detector()(FORWARD(v)); }, test_var) == "lvalue reference");
|
||||
BOOST_TEST(boost::apply_visitor([](auto&& v) { return lvalue_rvalue_detector()(FORWARD(v)); }, test_var) == "lvalue reference");
|
||||
}
|
||||
|
||||
void test_cpp14_mutable_visitor(const variant_type& test_var)
|
||||
{
|
||||
std::cout << "Testing const lvalue visitable for c++14 with inline mutable lambda\n";
|
||||
|
||||
BOOST_CHECK(boost::apply_visitor([](auto&& v) mutable -> auto { return lvalue_rvalue_detector()(FORWARD(v)); }, test_var) == "lvalue reference");
|
||||
BOOST_TEST(boost::apply_visitor([](auto&& v) mutable -> auto { return lvalue_rvalue_detector()(FORWARD(v)); }, test_var) == "lvalue reference");
|
||||
}
|
||||
|
||||
void test_cpp14_visitor(const variant_type& test_var, const variant_type& test_var2)
|
||||
{
|
||||
std::cout << "Testing const lvalue visitable for c++14\n";
|
||||
|
||||
BOOST_CHECK(boost::apply_visitor([](auto&& v, auto&& vv) { return lvalue_rvalue_detector()(FORWARD(v), FORWARD(vv)); }, test_var, test_var2)
|
||||
BOOST_TEST(boost::apply_visitor([](auto&& v, auto&& vv) { return lvalue_rvalue_detector()(FORWARD(v), FORWARD(vv)); }, test_var, test_var2)
|
||||
== "lvalue reference, lvalue reference");
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ void test_cpp14_visitor(const variant_type& test_var, const variant_type& test_v
|
||||
auto result = boost::apply_visitor([](auto&& v, auto&& t, auto&& p) { return lvalue_rvalue_detector()(FORWARD(v), FORWARD(t), FORWARD(p)); },
|
||||
test_var, test_var2, test_var3);
|
||||
std::cout << "result: " << result << std::endl;
|
||||
BOOST_CHECK(result == "lvalue reference, lvalue reference, lvalue reference");
|
||||
BOOST_TEST(result == "lvalue reference, lvalue reference, lvalue reference");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -221,14 +221,14 @@ void test_cpp14_visitor(variant_type&& test_var)
|
||||
{
|
||||
std::cout << "Testing rvalue visitable for c++14\n";
|
||||
|
||||
BOOST_CHECK(boost::apply_visitor([](auto&& v) { return lvalue_rvalue_detector()(FORWARD(v)); }, std::move(test_var)) == "rvalue reference");
|
||||
BOOST_TEST(boost::apply_visitor([](auto&& v) { return lvalue_rvalue_detector()(FORWARD(v)); }, std::move(test_var)) == "rvalue reference");
|
||||
}
|
||||
|
||||
void test_cpp14_visitor(variant_type&& test_var, variant_type&& test_var2)
|
||||
{
|
||||
std::cout << "Testing rvalue visitable for c++14\n";
|
||||
|
||||
BOOST_CHECK(boost::apply_visitor([](auto&& v, auto&& vv) { return lvalue_rvalue_detector()(FORWARD(v), FORWARD(vv)); }, std::move(test_var), std::move(test_var2))
|
||||
BOOST_TEST(boost::apply_visitor([](auto&& v, auto&& vv) { return lvalue_rvalue_detector()(FORWARD(v), FORWARD(vv)); }, std::move(test_var), std::move(test_var2))
|
||||
== "rvalue reference, rvalue reference");
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ void test_cpp14_visitor(variant_type&& test_var, variant_type&& test_var2, varia
|
||||
auto result = boost::apply_visitor([](auto&& v, auto&& t, auto&& p) { return lvalue_rvalue_detector()(FORWARD(v), FORWARD(t), FORWARD(p)); },
|
||||
std::move(test_var), std::move(test_var2), std::move(test_var3));
|
||||
std::cout << "result: " << result << std::endl;
|
||||
BOOST_CHECK(result == "rvalue reference, rvalue reference, rvalue reference");
|
||||
BOOST_TEST(result == "rvalue reference, rvalue reference, rvalue reference");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -273,34 +273,34 @@ void run_mixed_tests()
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
#ifndef BOOST_NO_CXX11_REF_QUALIFIERS
|
||||
std::cout << "Testing lvalue + rvalue visitable\n";
|
||||
BOOST_CHECK(boost::apply_visitor(lvalue_rvalue_detector(), v1, variant_type(10)) == "lvalue reference, rvalue reference");
|
||||
BOOST_TEST(boost::apply_visitor(lvalue_rvalue_detector(), v1, variant_type(10)) == "lvalue reference, rvalue reference");
|
||||
|
||||
std::cout << "Testing rvalue + lvalue visitable\n";
|
||||
BOOST_CHECK(boost::apply_visitor(lvalue_rvalue_detector(), variant_type(10), v1) == "rvalue reference, lvalue reference");
|
||||
BOOST_TEST(boost::apply_visitor(lvalue_rvalue_detector(), variant_type(10), v1) == "rvalue reference, lvalue reference");
|
||||
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
std::cout << "Testing rvalue + lvalue + rvalue visitable\n";
|
||||
BOOST_CHECK(boost::apply_visitor(lvalue_rvalue_detector(), variant_type(10), v1, variant_type(20)) == "rvalue reference, lvalue reference, rvalue reference");
|
||||
BOOST_TEST(boost::apply_visitor(lvalue_rvalue_detector(), variant_type(10), v1, variant_type(20)) == "rvalue reference, lvalue reference, rvalue reference");
|
||||
|
||||
std::cout << "Testing lvalue + rvalue + lvalue + rvalue visitable\n";
|
||||
BOOST_CHECK(boost::apply_visitor(lvalue_rvalue_detector(), v1, variant_type(10), v2, variant_type(20)) == "lvalue reference, rvalue reference, lvalue reference, rvalue reference");
|
||||
BOOST_TEST(boost::apply_visitor(lvalue_rvalue_detector(), v1, variant_type(10), v2, variant_type(20)) == "lvalue reference, rvalue reference, lvalue reference, rvalue reference");
|
||||
#endif
|
||||
|
||||
#endif // #ifndef BOOST_NO_CXX11_REF_QUALIFIERS
|
||||
|
||||
#else // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
std::cout << "Testing lvalue + rvalue visitable\n";
|
||||
BOOST_CHECK(boost::apply_visitor(lvalue_rvalue_detector(), v1, v1) == "lvalue reference, lvalue reference");
|
||||
BOOST_TEST(boost::apply_visitor(lvalue_rvalue_detector(), v1, v1) == "lvalue reference, lvalue reference");
|
||||
|
||||
std::cout << "Testing rvalue + lvalue visitable\n";
|
||||
BOOST_CHECK(boost::apply_visitor(lvalue_rvalue_detector(), static_cast<const variant_type&>(variant_type(10)), v1) == "lvalue reference, lvalue reference");
|
||||
BOOST_TEST(boost::apply_visitor(lvalue_rvalue_detector(), static_cast<const variant_type&>(variant_type(10)), v1) == "lvalue reference, lvalue reference");
|
||||
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
std::cout << "Testing rvalue + lvalue + rvalue visitable\n";
|
||||
BOOST_CHECK(boost::apply_visitor(lvalue_rvalue_detector(), static_cast<const variant_type&>(variant_type(10)), v1, static_cast<const variant_type&>(variant_type(20))) == "lvalue reference, lvalue reference, lvalue reference");
|
||||
BOOST_TEST(boost::apply_visitor(lvalue_rvalue_detector(), static_cast<const variant_type&>(variant_type(10)), v1, static_cast<const variant_type&>(variant_type(20))) == "lvalue reference, lvalue reference, lvalue reference");
|
||||
|
||||
std::cout << "Testing lvalue + rvalue + lvalue + rvalue visitable\n";
|
||||
BOOST_CHECK(boost::apply_visitor(lvalue_rvalue_detector(), v1, static_cast<const variant_type&>(variant_type(10)), v2, static_cast<const variant_type&>(variant_type(20))) == "lvalue reference, lvalue reference, lvalue reference, lvalue reference");
|
||||
BOOST_TEST(boost::apply_visitor(lvalue_rvalue_detector(), v1, static_cast<const variant_type&>(variant_type(10)), v2, static_cast<const variant_type&>(variant_type(20))) == "lvalue reference, lvalue reference, lvalue reference, lvalue reference");
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
@@ -311,20 +311,20 @@ void run_cpp14_mixed_tests()
|
||||
variant_type v1(1), v2(2);
|
||||
|
||||
std::cout << "Testing lvalue + rvalue visitable\n";
|
||||
BOOST_CHECK(boost::apply_visitor([](auto&& v, auto&& t) { return lvalue_rvalue_detector()(FORWARD(v), FORWARD(t)); },
|
||||
BOOST_TEST(boost::apply_visitor([](auto&& v, auto&& t) { return lvalue_rvalue_detector()(FORWARD(v), FORWARD(t)); },
|
||||
v1, variant_type(10)) == "lvalue reference, rvalue reference");
|
||||
|
||||
std::cout << "Testing rvalue + lvalue visitable\n";
|
||||
BOOST_CHECK(boost::apply_visitor([](auto&& v, auto&& t) { return lvalue_rvalue_detector()(FORWARD(v), FORWARD(t)); },
|
||||
BOOST_TEST(boost::apply_visitor([](auto&& v, auto&& t) { return lvalue_rvalue_detector()(FORWARD(v), FORWARD(t)); },
|
||||
variant_type(10), v1) == "rvalue reference, lvalue reference");
|
||||
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
std::cout << "Testing rvalue + lvalue + lvalue visitable\n";
|
||||
BOOST_CHECK(boost::apply_visitor([](auto&& v, auto&& t, auto&& p) { return lvalue_rvalue_detector()(FORWARD(v), FORWARD(t), FORWARD(p)); },
|
||||
BOOST_TEST(boost::apply_visitor([](auto&& v, auto&& t, auto&& p) { return lvalue_rvalue_detector()(FORWARD(v), FORWARD(t), FORWARD(p)); },
|
||||
variant_type(10), v1, v2) == "rvalue reference, lvalue reference, lvalue reference");
|
||||
|
||||
std::cout << "Testing lvalue + rvalue + lvalue visitable\n";
|
||||
BOOST_CHECK(boost::apply_visitor([](auto&& v, auto&& t, auto&& p) { return lvalue_rvalue_detector()(FORWARD(v), FORWARD(t), FORWARD(p)); },
|
||||
BOOST_TEST(boost::apply_visitor([](auto&& v, auto&& t, auto&& p) { return lvalue_rvalue_detector()(FORWARD(v), FORWARD(t), FORWARD(p)); },
|
||||
v1, variant_type(10), v2) == "lvalue reference, rvalue reference, lvalue reference");
|
||||
#endif
|
||||
#endif
|
||||
@@ -350,7 +350,7 @@ void run_cpp14_tests()
|
||||
|
||||
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
run_const_lvalue_ref_tests();
|
||||
run_rvalue_ref_tests();
|
||||
@@ -358,5 +358,5 @@ int test_main(int , char* [])
|
||||
run_cpp14_mixed_tests();
|
||||
run_cpp14_tests();
|
||||
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "boost/config.hpp"
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) && !defined(BOOST_NO_CXX11_HDR_UNORDERED_SET)
|
||||
// Test is based on reported issues:
|
||||
@@ -48,15 +48,15 @@ void run()
|
||||
int_t i = 3;
|
||||
value_t v = i;
|
||||
auto emplace_result = s.emplace(v); // raises error above
|
||||
BOOST_CHECK(emplace_result.second);
|
||||
BOOST_TEST(emplace_result.second);
|
||||
v = s;
|
||||
const set_t& check_set = boost::get<set_t>(v);
|
||||
BOOST_CHECK(!check_set.empty());
|
||||
BOOST_TEST(!check_set.empty());
|
||||
for (const auto& check_v : check_set) {
|
||||
BOOST_CHECK(s.find(check_v) != s.end());
|
||||
BOOST_TEST(s.find(check_v) != s.end());
|
||||
}
|
||||
for (const auto& check_v : s) {
|
||||
BOOST_CHECK(check_set.find(check_v) != check_set.end());
|
||||
BOOST_TEST(check_set.find(check_v) != check_set.end());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,9 +65,9 @@ void run()
|
||||
void run() {}
|
||||
#endif
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
run();
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
+12
-12
@@ -1,11 +1,11 @@
|
||||
// Copyright (c) 2011-2014
|
||||
// Copyright (c) 2011-2018
|
||||
// Antony Polukhin
|
||||
//
|
||||
// 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/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/variant.hpp"
|
||||
#include "boost/functional/hash/hash.hpp"
|
||||
|
||||
@@ -21,18 +21,18 @@ void run()
|
||||
variant_type char_variant2 = '\2';
|
||||
variant_type uint_variant = static_cast<unsigned int>(1);
|
||||
|
||||
BOOST_CHECK(hasher(bool_variant1) != hasher(bool_variant2));
|
||||
BOOST_CHECK(hasher(bool_variant1) == hasher(bool_variant1));
|
||||
BOOST_CHECK(hasher(int_variant) != hasher(uint_variant));
|
||||
BOOST_CHECK(hasher(char_variant1) != hasher(uint_variant));
|
||||
BOOST_CHECK(hasher(char_variant1) != hasher(char_variant2));
|
||||
BOOST_CHECK(hasher(char_variant1) == hasher(char_variant1));
|
||||
BOOST_CHECK(hasher(char_variant2) == hasher(char_variant2));
|
||||
BOOST_TEST(hasher(bool_variant1) != hasher(bool_variant2));
|
||||
BOOST_TEST(hasher(bool_variant1) == hasher(bool_variant1));
|
||||
BOOST_TEST(hasher(int_variant) != hasher(uint_variant));
|
||||
BOOST_TEST(hasher(char_variant1) != hasher(uint_variant));
|
||||
BOOST_TEST(hasher(char_variant1) != hasher(char_variant2));
|
||||
BOOST_TEST(hasher(char_variant1) == hasher(char_variant1));
|
||||
BOOST_TEST(hasher(char_variant2) == hasher(char_variant2));
|
||||
}
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
run();
|
||||
return 0;
|
||||
run();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -244,14 +244,14 @@ inline void verify(VariantType& var, spec<S>, std::string str = "")
|
||||
{
|
||||
const VariantType& cvar = var;
|
||||
|
||||
BOOST_CHECK(boost::apply_visitor(total_sizeof(), cvar) == sizeof(S));
|
||||
BOOST_CHECK(cvar.type() == boost::typeindex::type_id<S>());
|
||||
BOOST_TEST(boost::apply_visitor(total_sizeof(), cvar) == sizeof(S));
|
||||
BOOST_TEST(cvar.type() == boost::typeindex::type_id<S>());
|
||||
|
||||
//
|
||||
// Check get<>()
|
||||
//
|
||||
BOOST_CHECK(boost::get<S>(&var));
|
||||
BOOST_CHECK(boost::get<S>(&cvar));
|
||||
BOOST_TEST(boost::get<S>(&var));
|
||||
BOOST_TEST(boost::get<S>(&cvar));
|
||||
|
||||
const S* ptr1 = 0;
|
||||
const S* ptr2 = 0;
|
||||
@@ -275,7 +275,7 @@ inline void verify(VariantType& var, spec<S>, std::string str = "")
|
||||
BOOST_ERROR( "get<S> const failed unexpectedly" );
|
||||
}
|
||||
|
||||
BOOST_CHECK(ptr1 != 0 && ptr2 == ptr1);
|
||||
BOOST_TEST(ptr1 != 0 && ptr2 == ptr1);
|
||||
|
||||
//
|
||||
// Check string content
|
||||
@@ -284,7 +284,7 @@ inline void verify(VariantType& var, spec<S>, std::string str = "")
|
||||
{
|
||||
std::string temp = boost::apply_visitor(to_text(), cvar);
|
||||
std::cout << "temp = " << temp << ", str = " << str << std::endl;
|
||||
BOOST_CHECK(temp == str);
|
||||
BOOST_TEST(temp == str);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,13 +294,13 @@ inline void verify_not(VariantType& var, spec<S>)
|
||||
{
|
||||
const VariantType& cvar = var;
|
||||
|
||||
BOOST_CHECK(cvar.type() != boost::typeindex::type_id<S>());
|
||||
BOOST_TEST(cvar.type() != boost::typeindex::type_id<S>());
|
||||
|
||||
//
|
||||
// Check get<>()
|
||||
//
|
||||
BOOST_CHECK(!boost::get<S>(&var));
|
||||
BOOST_CHECK(!boost::get<S>(&cvar));
|
||||
BOOST_TEST(!boost::get<S>(&var));
|
||||
BOOST_TEST(!boost::get<S>(&cvar));
|
||||
|
||||
const S* ptr1 = 0;
|
||||
const S* ptr2 = 0;
|
||||
@@ -328,7 +328,7 @@ inline void verify_not(VariantType& var, spec<S>)
|
||||
// do nothing except pass-through
|
||||
}
|
||||
|
||||
BOOST_CHECK(ptr1 == 0 && ptr2 == 0);
|
||||
BOOST_TEST(ptr1 == 0 && ptr2 == 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+30
-30
@@ -3,7 +3,7 @@
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2016 Antony Polukhin
|
||||
// Copyright (c) 2016-2018 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
#include "boost/variant/variant.hpp"
|
||||
#include "boost/variant/recursive_variant.hpp"
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
@@ -37,10 +37,10 @@ bool foo(const boost::variant<C, D>& ) {
|
||||
|
||||
void test_overload_selection_variant_constructor() {
|
||||
D d;
|
||||
BOOST_CHECK(foo(d));
|
||||
BOOST_TEST(foo(d));
|
||||
|
||||
boost::variant<B, A> v;
|
||||
BOOST_CHECK(!foo(v));
|
||||
BOOST_TEST(!foo(v));
|
||||
}
|
||||
|
||||
// Pre msvc-14.0 could not dustinguish between multiple assignment operators:
|
||||
@@ -51,7 +51,7 @@ void test_overload_selection_variant_constructor() {
|
||||
#if (defined(__GNUC__) && (__GNUC__ < 4)) || (defined(_MSC_VER) && _MSC_VER < 1900)
|
||||
|
||||
void test_overload_selection_variant_assignment() {
|
||||
BOOST_CHECK(true);
|
||||
BOOST_TEST(true);
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -66,13 +66,13 @@ void test_overload_selection_variant_assignment() {
|
||||
assignment_tester tester;
|
||||
tester = a;
|
||||
const int which0 = static_cast< boost::variant<B, A>& >(tester).which();
|
||||
BOOST_CHECK(which0 == 1);
|
||||
BOOST_TEST(which0 == 1);
|
||||
|
||||
boost::variant<A, B> b;
|
||||
b = B();
|
||||
tester = b;
|
||||
const int which1 = static_cast< boost::variant<B, A>& >(tester).which();
|
||||
BOOST_CHECK(which1 == 0);
|
||||
BOOST_TEST(which1 == 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -88,7 +88,7 @@ struct convertible {
|
||||
void test_implicit_conversion_operator() {
|
||||
// https://svn.boost.org/trac/boost/ticket/8555
|
||||
my_variant y = convertible();
|
||||
BOOST_CHECK(y.which() == 0);
|
||||
BOOST_TEST(y.which() == 0);
|
||||
}
|
||||
|
||||
struct X: boost::variant< int > {};
|
||||
@@ -100,27 +100,27 @@ void test_derived_from_variant_construction() {
|
||||
// https://svn.boost.org/trac/boost/ticket/7120
|
||||
X x;
|
||||
boost::variant<X> y(x);
|
||||
BOOST_CHECK(y.which() == 0);
|
||||
BOOST_TEST(y.which() == 0);
|
||||
|
||||
// https://svn.boost.org/trac/boost/ticket/10278
|
||||
boost::variant<V1, std::string> v2 = V1();
|
||||
BOOST_CHECK(v2.which() == 0);
|
||||
BOOST_TEST(v2.which() == 0);
|
||||
|
||||
// https://svn.boost.org/trac/boost/ticket/12155
|
||||
AB ab;
|
||||
boost::variant<AB, C> ab_c(ab);
|
||||
BOOST_CHECK(ab_c.which() == 0);
|
||||
BOOST_TEST(ab_c.which() == 0);
|
||||
|
||||
boost::variant<A, B> a_b(ab);
|
||||
BOOST_CHECK(a_b.which() == 0);
|
||||
BOOST_TEST(a_b.which() == 0);
|
||||
|
||||
boost::variant<B, C, A> b_c_a1(static_cast<boost::variant<A, B>& >(ab));
|
||||
BOOST_CHECK(b_c_a1.which() == 2);
|
||||
BOOST_TEST(b_c_a1.which() == 2);
|
||||
|
||||
|
||||
// Following conversion seems harmful as it may lead to slicing:
|
||||
// boost::variant<B, C, A> b_c_a(ab);
|
||||
// BOOST_CHECK(b_c_a.which() == 2);
|
||||
// BOOST_TEST(b_c_a.which() == 2);
|
||||
}
|
||||
|
||||
void test_derived_from_variant_assignment() {
|
||||
@@ -128,32 +128,32 @@ void test_derived_from_variant_assignment() {
|
||||
X x;
|
||||
boost::variant<X> y;
|
||||
y = x;
|
||||
BOOST_CHECK(y.which() == 0);
|
||||
BOOST_TEST(y.which() == 0);
|
||||
|
||||
// https://svn.boost.org/trac/boost/ticket/10278
|
||||
boost::variant<V1, std::string> v2;
|
||||
v2 = V1();
|
||||
BOOST_CHECK(v2.which() == 0);
|
||||
BOOST_TEST(v2.which() == 0);
|
||||
|
||||
// https://svn.boost.org/trac/boost/ticket/12155
|
||||
AB ab;
|
||||
boost::variant<AB, C> ab_c;
|
||||
ab_c = ab;
|
||||
BOOST_CHECK(ab_c.which() == 0);
|
||||
BOOST_TEST(ab_c.which() == 0);
|
||||
|
||||
boost::variant<A, B> a_b;
|
||||
a_b = ab;
|
||||
BOOST_CHECK(a_b.which() == 0);
|
||||
BOOST_TEST(a_b.which() == 0);
|
||||
|
||||
boost::variant<B, C, A> b_c_a1;
|
||||
b_c_a1 = static_cast<boost::variant<A, B>& >(ab);
|
||||
BOOST_CHECK(b_c_a1.which() == 2);
|
||||
BOOST_TEST(b_c_a1.which() == 2);
|
||||
|
||||
|
||||
// Following conversion seems harmful as it may lead to slicing:
|
||||
// boost::variant<B, C, A> b_c_a;
|
||||
// b_c_a = ab;
|
||||
// BOOST_CHECK(b_c_a.which() == 2);
|
||||
// BOOST_TEST(b_c_a.which() == 2);
|
||||
}
|
||||
|
||||
|
||||
@@ -175,34 +175,34 @@ struct info {
|
||||
inline void test_on_incomplete_types() {
|
||||
info i0;
|
||||
i0.v = "Hello";
|
||||
BOOST_CHECK(i0.v.which() == 1);
|
||||
BOOST_TEST(i0.v.which() == 1);
|
||||
|
||||
info::value_type v0 = "Hello";
|
||||
BOOST_CHECK(v0.which() == 1);
|
||||
BOOST_TEST(v0.which() == 1);
|
||||
|
||||
info::value_type v1("Hello");
|
||||
BOOST_CHECK(v1.which() == 1);
|
||||
BOOST_TEST(v1.which() == 1);
|
||||
|
||||
info::value_type v2 = i0;
|
||||
BOOST_CHECK(v2.which() == 2);
|
||||
BOOST_TEST(v2.which() == 2);
|
||||
|
||||
info::value_type v3(i0);
|
||||
BOOST_CHECK(v3.which() == 2);
|
||||
BOOST_TEST(v3.which() == 2);
|
||||
|
||||
v0 = v3;
|
||||
BOOST_CHECK(v0.which() == 2);
|
||||
BOOST_TEST(v0.which() == 2);
|
||||
|
||||
v3 = v1;
|
||||
BOOST_CHECK(v3.which() == 1);
|
||||
BOOST_TEST(v3.which() == 1);
|
||||
|
||||
v3 = nil_();
|
||||
BOOST_CHECK(v3.which() == 0);
|
||||
BOOST_TEST(v3.which() == 0);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
test_overload_selection_variant_constructor();
|
||||
test_overload_selection_variant_assignment();
|
||||
@@ -211,5 +211,5 @@ int test_main(int , char* [])
|
||||
test_derived_from_variant_assignment();
|
||||
info().test_on_incomplete_types();
|
||||
|
||||
return boost::exit_success;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2003 Eric Friedman, Itay Maman
|
||||
// Copyright (c) 2013 Antony Polukhin
|
||||
// Copyright (c) 2013-2018 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -18,27 +18,8 @@
|
||||
// 2) variant_noexcept_test that tests Boost.Variant ability to compile
|
||||
// and work with disabled exceptions
|
||||
|
||||
#ifdef BOOST_NO_EXCEPTIONS
|
||||
// `boost/test/minimal.hpp` cannot work with exceptions disabled,
|
||||
// so we need the following workarounds for that case:
|
||||
namespace boost {
|
||||
int exit_success = 0;
|
||||
}
|
||||
|
||||
int test_main(int , char* []);
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
return test_main(argc, argv);
|
||||
}
|
||||
|
||||
#include <stdlib.h>
|
||||
#define BOOST_CHECK(exp) if (!(exp)) exit(EXIT_FAILURE)
|
||||
|
||||
#else // BOOST_NO_EXCEPTIONS
|
||||
# include "boost/test/minimal.hpp"
|
||||
#endif // BOOST_NO_EXCEPTIONS
|
||||
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
|
||||
#include "boost/variant.hpp"
|
||||
#include "boost/mpl/vector.hpp"
|
||||
@@ -128,7 +109,7 @@ void test_recursive_variant()
|
||||
std::string result1( printer()(var1) );
|
||||
|
||||
std::cout << "result1: " << result1 << '\n';
|
||||
BOOST_CHECK(result1 == "( 3 5 ( 3 5 ) 7 ) ");
|
||||
BOOST_TEST(result1 == "( 3 5 ( 3 5 ) 7 ) ");
|
||||
|
||||
std::vector<var1_t> vec1_copy = vec1;
|
||||
vec1_copy.erase(vec1_copy.begin() + 2);
|
||||
@@ -136,7 +117,7 @@ void test_recursive_variant()
|
||||
var1 = vec1_copy;
|
||||
result1 = printer()(var1);
|
||||
std::cout << "result1+: " << result1 << '\n';
|
||||
BOOST_CHECK(result1 == "( 3 5 ( 3 5 7 ) 7 ) ");
|
||||
BOOST_TEST(result1 == "( 3 5 ( 3 5 7 ) 7 ) ");
|
||||
|
||||
// Uses move construction on compilers with rvalue references support
|
||||
result1 = printer()(
|
||||
@@ -145,7 +126,7 @@ void test_recursive_variant()
|
||||
)
|
||||
);
|
||||
std::cout << "result1++: " << result1 << '\n';
|
||||
BOOST_CHECK(result1 == "( 3 5 ( 3 5 7 ) 7 ) ");
|
||||
BOOST_TEST(result1 == "( 3 5 ( 3 5 7 ) 7 ) ");
|
||||
|
||||
|
||||
var1_t vec1_another_copy(vec1_copy);
|
||||
@@ -154,18 +135,18 @@ void test_recursive_variant()
|
||||
var1_t(vec1_copy)
|
||||
);
|
||||
std::cout << "result1+++1: " << result1 << '\n';
|
||||
BOOST_CHECK(result1 == "( 3 5 ( 3 5 ( 3 5 7 ) 7 ) 7 ) ");
|
||||
BOOST_TEST(result1 == "( 3 5 ( 3 5 ( 3 5 7 ) 7 ) 7 ) ");
|
||||
|
||||
result1 = printer()(vec1_another_copy);
|
||||
std::cout << "result1++2: " << result1 << '\n';
|
||||
BOOST_CHECK(result1 == "( 3 5 7 ) ");
|
||||
BOOST_TEST(result1 == "( 3 5 7 ) ");
|
||||
|
||||
vec1_copy[2].swap(vec1_copy[2]);
|
||||
result1 = printer()(
|
||||
var1_t(vec1_copy)
|
||||
);
|
||||
std::cout << "result1.2: " << result1 << '\n';
|
||||
BOOST_CHECK(result1 == "( 3 5 ( 3 5 ( 3 5 7 ) 7 ) 7 ) ");
|
||||
BOOST_TEST(result1 == "( 3 5 ( 3 5 ( 3 5 7 ) 7 ) 7 ) ");
|
||||
|
||||
typedef boost::make_recursive_variant<
|
||||
boost::variant<int, double>
|
||||
@@ -182,7 +163,7 @@ void test_recursive_variant()
|
||||
std::string result2( printer()(var2) );
|
||||
|
||||
std::cout << "result2: " << result2 << '\n';
|
||||
BOOST_CHECK(result2 == "( 3 3.5 ( 3 3.5 ) 7 ) ");
|
||||
BOOST_TEST(result2 == "( 3 3.5 ( 3 3.5 ) 7 ) ");
|
||||
|
||||
typedef boost::make_recursive_variant<
|
||||
int
|
||||
@@ -209,7 +190,7 @@ void test_recursive_variant()
|
||||
std::string result3( printer()(var4) );
|
||||
|
||||
std::cout << "result2: " << result3 << '\n';
|
||||
BOOST_CHECK(result3 == "( 3 5 ( 3.5 ( 3 5 ) ) 7 ) ");
|
||||
BOOST_TEST(result3 == "( 3 5 ( 3.5 ( 3 5 ) ) 7 ) ");
|
||||
|
||||
typedef boost::make_recursive_variant<
|
||||
double,
|
||||
@@ -224,7 +205,7 @@ void test_recursive_variant()
|
||||
std::string result5( printer()(vec5) );
|
||||
|
||||
std::cout << "result5: " << result5 << '\n';
|
||||
BOOST_CHECK(result5 == "( 3.5 ( 3 5 ( 3 5 ) 7 ) 17.25 ) ");
|
||||
BOOST_TEST(result5 == "( 3.5 ( 3 5 ( 3 5 ) 7 ) 17.25 ) ");
|
||||
|
||||
typedef boost::make_recursive_variant<
|
||||
int,
|
||||
@@ -244,7 +225,7 @@ void test_recursive_variant()
|
||||
std::string result7( printer()(var7) );
|
||||
|
||||
std::cout << "result7: " << result7 << '\n';
|
||||
BOOST_CHECK(result7 == "( 2 ( 1 0 ) ) ");
|
||||
BOOST_TEST(result7 == "( 2 ( 1 0 ) ) ");
|
||||
#endif // !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
}
|
||||
|
||||
@@ -267,7 +248,7 @@ void test_recursive_variant_over()
|
||||
std::string result1( printer()(var1) );
|
||||
|
||||
std::cout << "result1: " << result1 << '\n';
|
||||
BOOST_CHECK(result1 == "( 3 5 ( 3 5 ) 7 ) ");
|
||||
BOOST_TEST(result1 == "( 3 5 ( 3 5 ) 7 ) ");
|
||||
|
||||
std::vector<var1_t> vec1_copy = vec1;
|
||||
vec1_copy.erase(vec1_copy.begin() + 2);
|
||||
@@ -275,7 +256,7 @@ void test_recursive_variant_over()
|
||||
var1 = vec1_copy;
|
||||
result1 = printer()(var1);
|
||||
std::cout << "result1+: " << result1 << '\n';
|
||||
BOOST_CHECK(result1 == "( 3 5 ( 3 5 7 ) 7 ) ");
|
||||
BOOST_TEST(result1 == "( 3 5 ( 3 5 7 ) 7 ) ");
|
||||
|
||||
// Uses move construction on compilers with rvalue references support
|
||||
result1 = printer()(
|
||||
@@ -284,7 +265,7 @@ void test_recursive_variant_over()
|
||||
)
|
||||
);
|
||||
std::cout << "result1++: " << result1 << '\n';
|
||||
BOOST_CHECK(result1 == "( 3 5 ( 3 5 7 ) 7 ) ");
|
||||
BOOST_TEST(result1 == "( 3 5 ( 3 5 7 ) 7 ) ");
|
||||
|
||||
|
||||
var1_t vec1_another_copy(vec1_copy);
|
||||
@@ -293,11 +274,11 @@ void test_recursive_variant_over()
|
||||
var1_t(vec1_copy)
|
||||
);
|
||||
std::cout << "result1+++1: " << result1 << '\n';
|
||||
BOOST_CHECK(result1 == "( 3 5 ( 3 5 ( 3 5 7 ) 7 ) 7 ) ");
|
||||
BOOST_TEST(result1 == "( 3 5 ( 3 5 ( 3 5 7 ) 7 ) 7 ) ");
|
||||
|
||||
result1 = printer()(vec1_another_copy);
|
||||
std::cout << "result1++2: " << result1 << '\n';
|
||||
BOOST_CHECK(result1 == "( 3 5 7 ) ");
|
||||
BOOST_TEST(result1 == "( 3 5 7 ) ");
|
||||
|
||||
typedef boost::make_recursive_variant_over<
|
||||
boost::mpl::vector<
|
||||
@@ -316,7 +297,7 @@ void test_recursive_variant_over()
|
||||
std::string result2( printer()(var2) );
|
||||
|
||||
std::cout << "result2: " << result2 << '\n';
|
||||
BOOST_CHECK(result2 == "( 3 3.5 ( 3 3.5 ) 7 ) ");
|
||||
BOOST_TEST(result2 == "( 3 3.5 ( 3 3.5 ) 7 ) ");
|
||||
|
||||
typedef boost::make_recursive_variant_over<
|
||||
boost::mpl::vector<
|
||||
@@ -354,7 +335,7 @@ void test_recursive_variant_over()
|
||||
std::string result3( printer()(var3) );
|
||||
|
||||
std::cout << "result2: " << result3 << '\n';
|
||||
BOOST_CHECK(result3 == "( 3 5 ( 3.5 ( 3 5 ) ) 7 ) ");
|
||||
BOOST_TEST(result3 == "( 3 5 ( 3.5 ( 3 5 ) ) 7 ) ");
|
||||
|
||||
typedef boost::make_recursive_variant_over<
|
||||
boost::mpl::vector<
|
||||
@@ -371,13 +352,13 @@ void test_recursive_variant_over()
|
||||
std::string result5( printer()(vec5) );
|
||||
|
||||
std::cout << "result5: " << result5 << '\n';
|
||||
BOOST_CHECK(result5 == "( 3.5 ( 3 5 ( 3 5 ) 7 ) 17.25 ) ");
|
||||
BOOST_TEST(result5 == "( 3.5 ( 3 5 ( 3 5 ) 7 ) 17.25 ) ");
|
||||
}
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
test_recursive_variant();
|
||||
test_recursive_variant_over();
|
||||
|
||||
return boost::exit_success;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "boost/config.hpp"
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
|
||||
#ifdef __cpp_inheriting_constructors
|
||||
// Test is based on reported issue:
|
||||
@@ -70,9 +70,9 @@ void run() {
|
||||
void run() {}
|
||||
#endif
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
run();
|
||||
return 0;
|
||||
run();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
+41
-41
@@ -3,7 +3,7 @@
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2012-2014 Antony Polukhin
|
||||
// Copyright (c) 2012-2018 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include "boost/config.hpp"
|
||||
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/variant.hpp"
|
||||
#include "boost/type_traits/is_nothrow_move_assignable.hpp"
|
||||
#include "boost/mpl/bool.hpp"
|
||||
@@ -84,23 +84,23 @@ void run()
|
||||
|
||||
void run1()
|
||||
{
|
||||
BOOST_CHECK(true);
|
||||
BOOST_TEST(true);
|
||||
}
|
||||
|
||||
void run_move_only()
|
||||
{
|
||||
BOOST_CHECK(true);
|
||||
BOOST_TEST(true);
|
||||
}
|
||||
|
||||
void run_moves_are_noexcept()
|
||||
{
|
||||
BOOST_CHECK(true);
|
||||
BOOST_TEST(true);
|
||||
}
|
||||
|
||||
|
||||
void run_const_rvalues()
|
||||
{
|
||||
BOOST_CHECK(true);
|
||||
BOOST_TEST(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -113,12 +113,12 @@ void run()
|
||||
variant_I_type v1, v2;
|
||||
|
||||
// Assuring that `move_copy_conting_class` was not created
|
||||
BOOST_CHECK(move_copy_conting_class::copy_count == 0);
|
||||
BOOST_CHECK(move_copy_conting_class::moves_count == 0);
|
||||
BOOST_TEST(move_copy_conting_class::copy_count == 0);
|
||||
BOOST_TEST(move_copy_conting_class::moves_count == 0);
|
||||
|
||||
v1 = move_copy_conting_class();
|
||||
// Assuring that `move_copy_conting_class` was moved at least once
|
||||
BOOST_CHECK(move_copy_conting_class::moves_count != 0);
|
||||
BOOST_TEST(move_copy_conting_class::moves_count != 0);
|
||||
|
||||
unsigned int total_count = move_copy_conting_class::moves_count + move_copy_conting_class::copy_count;
|
||||
move_copy_conting_class var;
|
||||
@@ -127,28 +127,28 @@ void run()
|
||||
move_copy_conting_class::copy_count = 0;
|
||||
v1 = var;
|
||||
// Assuring that move assignment operator moves/copyes value not more times than copy assignment operator
|
||||
BOOST_CHECK(total_count <= move_copy_conting_class::moves_count + move_copy_conting_class::copy_count);
|
||||
BOOST_TEST(total_count <= move_copy_conting_class::moves_count + move_copy_conting_class::copy_count);
|
||||
|
||||
move_copy_conting_class::moves_count = 0;
|
||||
move_copy_conting_class::copy_count = 0;
|
||||
v2 = boost::move(v1);
|
||||
// Assuring that `move_copy_conting_class` in v1 was moved at least once and was not copied
|
||||
BOOST_CHECK(move_copy_conting_class::moves_count != 0);
|
||||
BOOST_CHECK(move_copy_conting_class::copy_count == 0);
|
||||
BOOST_TEST(move_copy_conting_class::moves_count != 0);
|
||||
BOOST_TEST(move_copy_conting_class::copy_count == 0);
|
||||
|
||||
v1 = move_copy_conting_class();
|
||||
move_copy_conting_class::moves_count = 0;
|
||||
move_copy_conting_class::copy_count = 0;
|
||||
v2 = boost::move(v1);
|
||||
// Assuring that `move_copy_conting_class` in v1 was moved at least once and was not copied
|
||||
BOOST_CHECK(move_copy_conting_class::moves_count != 0);
|
||||
BOOST_CHECK(move_copy_conting_class::copy_count == 0);
|
||||
BOOST_TEST(move_copy_conting_class::moves_count != 0);
|
||||
BOOST_TEST(move_copy_conting_class::copy_count == 0);
|
||||
total_count = move_copy_conting_class::moves_count + move_copy_conting_class::copy_count;
|
||||
move_copy_conting_class::moves_count = 0;
|
||||
move_copy_conting_class::copy_count = 0;
|
||||
v1 = v2;
|
||||
// Assuring that move assignment operator moves/copyes value not more times than copy assignment operator
|
||||
BOOST_CHECK(total_count <= move_copy_conting_class::moves_count + move_copy_conting_class::copy_count);
|
||||
BOOST_TEST(total_count <= move_copy_conting_class::moves_count + move_copy_conting_class::copy_count);
|
||||
|
||||
|
||||
typedef boost::variant<move_copy_conting_class, int> variant_II_type;
|
||||
@@ -157,27 +157,27 @@ void run()
|
||||
move_copy_conting_class::copy_count = 0;
|
||||
v1 = boost::move(v3);
|
||||
// Assuring that `move_copy_conting_class` in v3 was moved at least once (v1 and v3 have different types)
|
||||
BOOST_CHECK(move_copy_conting_class::moves_count != 0);
|
||||
BOOST_TEST(move_copy_conting_class::moves_count != 0);
|
||||
|
||||
move_copy_conting_class::moves_count = 0;
|
||||
move_copy_conting_class::copy_count = 0;
|
||||
v2 = boost::move(v1);
|
||||
// Assuring that `move_copy_conting_class` in v1 was moved at least once (v1 and v3 have different types)
|
||||
BOOST_CHECK(move_copy_conting_class::moves_count != 0);
|
||||
BOOST_TEST(move_copy_conting_class::moves_count != 0);
|
||||
|
||||
move_copy_conting_class::moves_count = 0;
|
||||
move_copy_conting_class::copy_count = 0;
|
||||
variant_I_type v5(boost::move(v1));
|
||||
// Assuring that `move_copy_conting_class` in v1 was moved at least once and was not copied
|
||||
BOOST_CHECK(move_copy_conting_class::moves_count != 0);
|
||||
BOOST_CHECK(move_copy_conting_class::copy_count == 0);
|
||||
BOOST_TEST(move_copy_conting_class::moves_count != 0);
|
||||
BOOST_TEST(move_copy_conting_class::copy_count == 0);
|
||||
|
||||
total_count = move_copy_conting_class::moves_count + move_copy_conting_class::copy_count;
|
||||
move_copy_conting_class::moves_count = 0;
|
||||
move_copy_conting_class::copy_count = 0;
|
||||
variant_I_type v6(v1);
|
||||
// Assuring that move constructor moves/copyes value not more times than copy constructor
|
||||
BOOST_CHECK(total_count <= move_copy_conting_class::moves_count + move_copy_conting_class::copy_count);
|
||||
BOOST_TEST(total_count <= move_copy_conting_class::moves_count + move_copy_conting_class::copy_count);
|
||||
}
|
||||
|
||||
void run1()
|
||||
@@ -190,8 +190,8 @@ void run1()
|
||||
variant_I_type v1(boost::move(c1));
|
||||
|
||||
// Assuring that `move_copy_conting_class` was not copyied
|
||||
BOOST_CHECK(move_copy_conting_class::copy_count == 0);
|
||||
BOOST_CHECK(move_copy_conting_class::moves_count > 0);
|
||||
BOOST_TEST(move_copy_conting_class::copy_count == 0);
|
||||
BOOST_TEST(move_copy_conting_class::moves_count > 0);
|
||||
}
|
||||
|
||||
struct move_only_structure {
|
||||
@@ -215,26 +215,26 @@ void run_move_only()
|
||||
{
|
||||
move_only_structure mo;
|
||||
boost::variant<int, move_only_structure > vi, vi2(static_cast<move_only_structure&&>(mo));
|
||||
BOOST_CHECK(vi.which() == 0);
|
||||
BOOST_CHECK(vi2.which() == 1);
|
||||
BOOST_TEST(vi.which() == 0);
|
||||
BOOST_TEST(vi2.which() == 1);
|
||||
|
||||
vi = 10;
|
||||
vi2 = 10;
|
||||
BOOST_CHECK(vi.which() == 0);
|
||||
BOOST_CHECK(vi2.which() == 0);
|
||||
BOOST_TEST(vi.which() == 0);
|
||||
BOOST_TEST(vi2.which() == 0);
|
||||
|
||||
vi = static_cast<move_only_structure&&>(mo);
|
||||
vi2 = static_cast<move_only_structure&&>(mo);
|
||||
BOOST_CHECK(vi.which() == 1);
|
||||
BOOST_TEST(vi.which() == 1);
|
||||
|
||||
boost::variant<move_only_structure, int > rvi (1);
|
||||
BOOST_CHECK(rvi.which() == 1);
|
||||
BOOST_TEST(rvi.which() == 1);
|
||||
rvi = static_cast<move_only_structure&&>(mo);
|
||||
BOOST_CHECK(rvi.which() == 0);
|
||||
BOOST_TEST(rvi.which() == 0);
|
||||
rvi = 1;
|
||||
BOOST_CHECK(rvi.which() == 1);
|
||||
BOOST_TEST(rvi.which() == 1);
|
||||
rvi = static_cast<boost::variant<int, move_only_structure >&&>(vi2);
|
||||
BOOST_CHECK(rvi.which() == 0);
|
||||
BOOST_TEST(rvi.which() == 0);
|
||||
|
||||
move_only_structure from_visitor = boost::apply_visitor(visitor_returning_move_only_type(), vi);
|
||||
(void)from_visitor;
|
||||
@@ -243,12 +243,12 @@ void run_move_only()
|
||||
void run_moves_are_noexcept() {
|
||||
#if !defined(BOOST_NO_CXX11_NOEXCEPT) && (!defined(__GNUC__) || defined(__clang__) || __GNUC__ > 4 || __GNUC_MINOR__ >= 8)
|
||||
typedef boost::variant<int, short, double> variant_noexcept_t;
|
||||
BOOST_CHECK(boost::is_nothrow_move_assignable<variant_noexcept_t>::value);
|
||||
BOOST_CHECK(boost::is_nothrow_move_constructible<variant_noexcept_t>::value);
|
||||
BOOST_TEST(boost::is_nothrow_move_assignable<variant_noexcept_t>::value);
|
||||
BOOST_TEST(boost::is_nothrow_move_constructible<variant_noexcept_t>::value);
|
||||
|
||||
typedef boost::variant<int, short, double, move_only_structure> variant_except_t;
|
||||
BOOST_CHECK(!boost::is_nothrow_move_assignable<variant_except_t>::value);
|
||||
BOOST_CHECK(!boost::is_nothrow_move_constructible<variant_except_t>::value);
|
||||
BOOST_TEST(!boost::is_nothrow_move_assignable<variant_except_t>::value);
|
||||
BOOST_TEST(!boost::is_nothrow_move_constructible<variant_except_t>::value);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -304,12 +304,12 @@ struct is_container<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
|
||||
|
||||
void run_is_container_compilation_test()
|
||||
{
|
||||
BOOST_CHECK((!is_container<boost::variant<double, int> >::value));
|
||||
BOOST_CHECK((!is_container<boost::variant<double, int, char> >::value));
|
||||
BOOST_CHECK((!is_container<boost::variant<double, int, char, float> >::value));
|
||||
BOOST_TEST((!is_container<boost::variant<double, int> >::value));
|
||||
BOOST_TEST((!is_container<boost::variant<double, int, char> >::value));
|
||||
BOOST_TEST((!is_container<boost::variant<double, int, char, float> >::value));
|
||||
}
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
swap_ambiguouty_test_ns::swap_ambiguouty_test();
|
||||
run();
|
||||
@@ -322,11 +322,11 @@ int test_main(int , char* [])
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ > 6)
|
||||
# ifdef BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
BOOST_CHECK(false &&
|
||||
BOOST_TEST(false &&
|
||||
"Something wrong with macro definitions. GCC-4.7+ is known to work with variadic templates"
|
||||
);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
+7
-7
@@ -16,7 +16,7 @@
|
||||
#pragma warning(disable:4244) // conversion from const int to const short
|
||||
#endif
|
||||
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/variant.hpp"
|
||||
|
||||
#include "class_a.h"
|
||||
@@ -121,11 +121,11 @@ void run()
|
||||
v1 = 3.4f;
|
||||
apply_visitor(ts, v1);
|
||||
|
||||
BOOST_CHECK(ts.result() == sizeof(int) + sizeof(double)*2);
|
||||
BOOST_TEST(ts.result() == sizeof(int) + sizeof(double)*2);
|
||||
|
||||
v11 = 5;
|
||||
string res_s = apply_visitor(int_printer(), v11);
|
||||
BOOST_CHECK(res_s == "5");
|
||||
BOOST_TEST(res_s == "5");
|
||||
|
||||
//
|
||||
// A variant object holding an std::vector
|
||||
@@ -138,13 +138,13 @@ void run()
|
||||
|
||||
v11 = int_vec_1;
|
||||
res_s = apply_visitor(int_printer(), v11);
|
||||
BOOST_CHECK(res_s == ",512,256,128,64");
|
||||
BOOST_TEST(res_s == ",512,256,128,64");
|
||||
}
|
||||
|
||||
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
run();
|
||||
return 0;
|
||||
run();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
+4
-4
@@ -16,7 +16,7 @@
|
||||
#pragma warning(disable:4244) // conversion from 'const int' to 'const short'
|
||||
#endif
|
||||
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/variant.hpp"
|
||||
|
||||
#include "jobs.h"
|
||||
@@ -141,9 +141,9 @@ void run()
|
||||
}
|
||||
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
run();
|
||||
return 0;
|
||||
run();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -10,7 +10,7 @@
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/variant.hpp"
|
||||
|
||||
#include <iostream>
|
||||
@@ -113,7 +113,7 @@ struct Calculator : boost::static_visitor<int>
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
int test_main(int, char* [])
|
||||
int main()
|
||||
{
|
||||
|
||||
int n = 13;
|
||||
@@ -122,13 +122,13 @@ int test_main(int, char* [])
|
||||
std::ostringstream e1_str;
|
||||
e1_str << e1;
|
||||
|
||||
BOOST_CHECK(e1.type() == boost::typeindex::type_id<Add>());
|
||||
BOOST_CHECK(e1_str.str() == "(13+((40+2)-(10+4)))");
|
||||
BOOST_TEST(e1.type() == boost::typeindex::type_id<Add>());
|
||||
BOOST_TEST(e1_str.str() == "(13+((40+2)-(10+4)))");
|
||||
|
||||
//Evaluate expression
|
||||
int res = boost::apply_visitor(Calculator(), e1);
|
||||
BOOST_CHECK(res == n + 28);
|
||||
BOOST_TEST(res == n + 28);
|
||||
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -16,7 +16,7 @@
|
||||
#pragma warning(disable:4244) // conversion from 'const int' to 'const short'
|
||||
#endif
|
||||
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/variant.hpp"
|
||||
|
||||
#include "jobs.h"
|
||||
@@ -32,7 +32,7 @@ typedef variant<std::string, class_a, short> var_type_2;
|
||||
|
||||
#include "class_a.h"
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
using namespace boost;
|
||||
|
||||
@@ -53,5 +53,5 @@ int test_main(int , char* [])
|
||||
v2 = 5;
|
||||
v1 = v2;
|
||||
|
||||
return boost::exit_success;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
+6
-6
@@ -10,7 +10,7 @@
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/variant.hpp"
|
||||
|
||||
#include "jobs.h"
|
||||
@@ -58,14 +58,14 @@ void run()
|
||||
verify(v3, spec<int>());
|
||||
|
||||
|
||||
BOOST_CHECK(apply_visitor(sum_int(), v2) == c0);
|
||||
BOOST_CHECK(apply_visitor(sum_int(), v3) == c0);
|
||||
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_CHECK(adder.result() == 2*c0);
|
||||
BOOST_TEST(adder.result() == 2*c0);
|
||||
|
||||
//
|
||||
// A variant holding a variant
|
||||
@@ -82,9 +82,9 @@ void run()
|
||||
|
||||
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
run();
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -10,7 +10,7 @@
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/variant.hpp"
|
||||
|
||||
#include <iostream>
|
||||
@@ -66,9 +66,9 @@ void run()
|
||||
|
||||
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
run();
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
+8
-8
@@ -16,7 +16,7 @@
|
||||
#pragma warning(disable:4244) // conversion from 'const int' to 'const short'
|
||||
#endif
|
||||
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/variant.hpp"
|
||||
|
||||
#include "jobs.h"
|
||||
@@ -69,8 +69,8 @@ struct Tracker
|
||||
static void remove(const jas& j)
|
||||
{
|
||||
iterator_type iter = s_this_to_sn_.find(&j);
|
||||
BOOST_CHECK(iter != s_this_to_sn_.end());
|
||||
BOOST_CHECK( ((*iter).second) == j.sn_);
|
||||
BOOST_TEST(iter != s_this_to_sn_.end());
|
||||
BOOST_TEST( ((*iter).second) == j.sn_);
|
||||
|
||||
int sn = (*iter).second;
|
||||
if(sn != j.sn_)
|
||||
@@ -79,7 +79,7 @@ struct Tracker
|
||||
<< ", other: this = " << &j << ", j.sn_ = " << j.sn_ << endl;
|
||||
}
|
||||
|
||||
BOOST_CHECK(sn == j.sn_);
|
||||
BOOST_TEST(sn == j.sn_);
|
||||
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ struct Tracker
|
||||
|
||||
static void check()
|
||||
{
|
||||
BOOST_CHECK(s_this_to_sn_.empty());
|
||||
BOOST_TEST(s_this_to_sn_.empty());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -214,7 +214,7 @@ void var_compare(const VariantType& v, ExpectedType expected)
|
||||
compare_helper<ExpectedType> ch(expected);
|
||||
|
||||
bool checks = boost::apply_visitor(ch, v);
|
||||
BOOST_CHECK(checks);
|
||||
BOOST_TEST(checks);
|
||||
}
|
||||
|
||||
|
||||
@@ -245,11 +245,11 @@ void run()
|
||||
}
|
||||
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
run();
|
||||
Tracker::check();
|
||||
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
+11
-11
@@ -10,7 +10,7 @@
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/variant.hpp"
|
||||
|
||||
#include <iostream>
|
||||
@@ -40,12 +40,12 @@ struct int_sum : static_visitor<>
|
||||
template <typename T, typename Variant>
|
||||
T& check_pass(Variant& v, T value)
|
||||
{
|
||||
BOOST_CHECK(get<T>(&v));
|
||||
BOOST_TEST(get<T>(&v));
|
||||
|
||||
try
|
||||
{
|
||||
T& r = get<T>(v);
|
||||
BOOST_CHECK(r == value);
|
||||
BOOST_TEST(r == value);
|
||||
return r;
|
||||
}
|
||||
catch(boost::bad_get&)
|
||||
@@ -57,21 +57,21 @@ T& check_pass(Variant& v, T value)
|
||||
template <typename T, typename Variant>
|
||||
void check_fail(Variant& v)
|
||||
{
|
||||
BOOST_CHECK(!relaxed_get<T>(&v));
|
||||
BOOST_TEST(!relaxed_get<T>(&v));
|
||||
|
||||
try
|
||||
{
|
||||
T& r = relaxed_get<T>(v);
|
||||
(void)r; // suppress warning about r not being used
|
||||
BOOST_CHECK(false && relaxed_get<T>(&v)); // should never reach
|
||||
BOOST_TEST(false && relaxed_get<T>(&v)); // should never reach
|
||||
}
|
||||
catch(const boost::bad_get& e)
|
||||
{
|
||||
BOOST_CHECK(!!e.what()); // make sure that what() is const qualified and returnes something
|
||||
BOOST_TEST(!!e.what()); // make sure that what() is const qualified and returnes something
|
||||
}
|
||||
}
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
int_sum acc;
|
||||
t_var1 v1 = 800;
|
||||
@@ -87,12 +87,12 @@ int test_main(int , char* [])
|
||||
check_fail<const short>(v1);
|
||||
|
||||
apply_visitor(acc, v1);
|
||||
BOOST_CHECK(acc.result_ == 800);
|
||||
BOOST_TEST(acc.result_ == 800);
|
||||
|
||||
r1 = 920; // NOTE: modifies content of v1
|
||||
apply_visitor(acc, v1);
|
||||
BOOST_CHECK(cr1 == 920);
|
||||
BOOST_CHECK(acc.result_ == 800 + 920);
|
||||
BOOST_TEST(cr1 == 920);
|
||||
BOOST_TEST(acc.result_ == 800 + 920);
|
||||
}
|
||||
|
||||
// check const correctness:
|
||||
@@ -108,6 +108,6 @@ int test_main(int , char* [])
|
||||
//check_fail<short>(c);
|
||||
}
|
||||
|
||||
return boost::exit_success;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2016 Antony Polukhin
|
||||
// Copyright (c) 2016-2018 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2003 Eric Friedman, Itay Maman
|
||||
// Copyright (c) 2014 Antony Polukhin
|
||||
// Copyright (c) 2014-2018 Antony Polukhin
|
||||
//
|
||||
// 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/variant/variant.hpp"
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
@@ -31,38 +31,38 @@ void assert_equality_comparable(
|
||||
)
|
||||
{
|
||||
// identity check
|
||||
BOOST_CHECK( !(&x == &y) || (x == y) );
|
||||
BOOST_CHECK( !(&x == &z) || (x == z) );
|
||||
BOOST_CHECK( !(&y == &z) || (y == z) );
|
||||
BOOST_CHECK( !(&x == &y) || !(x != y) );
|
||||
BOOST_CHECK( !(&x == &z) || !(x != z) );
|
||||
BOOST_CHECK( !(&y == &z) || !(y != z) );
|
||||
BOOST_TEST( !(&x == &y) || (x == y) );
|
||||
BOOST_TEST( !(&x == &z) || (x == z) );
|
||||
BOOST_TEST( !(&y == &z) || (y == z) );
|
||||
BOOST_TEST( !(&x == &y) || !(x != y) );
|
||||
BOOST_TEST( !(&x == &z) || !(x != z) );
|
||||
BOOST_TEST( !(&y == &z) || !(y != z) );
|
||||
|
||||
// reflexivity check
|
||||
BOOST_CHECK( (x == x) );
|
||||
BOOST_CHECK( (y == y) );
|
||||
BOOST_CHECK( (z == z) );
|
||||
BOOST_TEST( (x == x) );
|
||||
BOOST_TEST( (y == y) );
|
||||
BOOST_TEST( (z == z) );
|
||||
|
||||
// symmetry check
|
||||
BOOST_CHECK( !(x == y) || (y == x) );
|
||||
BOOST_CHECK( !(y == x) || (x == y) );
|
||||
BOOST_CHECK( (x != y) || (y == x) );
|
||||
BOOST_CHECK( (y != x) || (x == y) );
|
||||
BOOST_TEST( !(x == y) || (y == x) );
|
||||
BOOST_TEST( !(y == x) || (x == y) );
|
||||
BOOST_TEST( (x != y) || (y == x) );
|
||||
BOOST_TEST( (y != x) || (x == y) );
|
||||
|
||||
BOOST_CHECK( !(x == z) || (z == x) );
|
||||
BOOST_CHECK( !(z == x) || (x == z) );
|
||||
BOOST_CHECK( (x != z) || (z == x) );
|
||||
BOOST_CHECK( (z != x) || (x == z) );
|
||||
BOOST_TEST( !(x == z) || (z == x) );
|
||||
BOOST_TEST( !(z == x) || (x == z) );
|
||||
BOOST_TEST( (x != z) || (z == x) );
|
||||
BOOST_TEST( (z != x) || (x == z) );
|
||||
|
||||
BOOST_CHECK( !(y == z) || (z == y) );
|
||||
BOOST_CHECK( !(z == y) || (y == z) );
|
||||
BOOST_CHECK( (y != z) || (z == y) );
|
||||
BOOST_CHECK( (z != y) || (y == z) );
|
||||
BOOST_TEST( !(y == z) || (z == y) );
|
||||
BOOST_TEST( !(z == y) || (y == z) );
|
||||
BOOST_TEST( (y != z) || (z == y) );
|
||||
BOOST_TEST( (z != y) || (y == z) );
|
||||
|
||||
// transitivity check
|
||||
BOOST_CHECK( !(x == y && y == z) || (x == z) );
|
||||
BOOST_CHECK( !(x == z && z == y) || (x == y) );
|
||||
BOOST_CHECK( !(y == z && z == x) || (y == x) );
|
||||
BOOST_TEST( !(x == y && y == z) || (x == z) );
|
||||
BOOST_TEST( !(x == z && z == y) || (x == y) );
|
||||
BOOST_TEST( !(y == z && z == x) || (y == x) );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -71,41 +71,41 @@ void assert_less_than_comparable(
|
||||
)
|
||||
{
|
||||
// irreflexivity check
|
||||
BOOST_CHECK( !(x < x) );
|
||||
BOOST_CHECK( !(y < y) );
|
||||
BOOST_CHECK( !(z < z) );
|
||||
BOOST_CHECK( !(x > x) );
|
||||
BOOST_CHECK( !(y > y) );
|
||||
BOOST_CHECK( !(z > z) );
|
||||
BOOST_TEST( !(x < x) );
|
||||
BOOST_TEST( !(y < y) );
|
||||
BOOST_TEST( !(z < z) );
|
||||
BOOST_TEST( !(x > x) );
|
||||
BOOST_TEST( !(y > y) );
|
||||
BOOST_TEST( !(z > z) );
|
||||
|
||||
BOOST_CHECK( (x <= x) );
|
||||
BOOST_CHECK( (y <= y) );
|
||||
BOOST_CHECK( (z <= z) );
|
||||
BOOST_CHECK( (x >= x) );
|
||||
BOOST_CHECK( (y >= y) );
|
||||
BOOST_CHECK( (z >= z) );
|
||||
BOOST_TEST( (x <= x) );
|
||||
BOOST_TEST( (y <= y) );
|
||||
BOOST_TEST( (z <= z) );
|
||||
BOOST_TEST( (x >= x) );
|
||||
BOOST_TEST( (y >= y) );
|
||||
BOOST_TEST( (z >= z) );
|
||||
|
||||
// transitivity check
|
||||
BOOST_CHECK( (x < y) );
|
||||
BOOST_CHECK( (y < z) );
|
||||
BOOST_CHECK( (x < z) );
|
||||
BOOST_TEST( (x < y) );
|
||||
BOOST_TEST( (y < z) );
|
||||
BOOST_TEST( (x < z) );
|
||||
|
||||
BOOST_CHECK( (x <= y) );
|
||||
BOOST_CHECK( (y <= z) );
|
||||
BOOST_CHECK( (x <= z) );
|
||||
BOOST_TEST( (x <= y) );
|
||||
BOOST_TEST( (y <= z) );
|
||||
BOOST_TEST( (x <= z) );
|
||||
|
||||
BOOST_CHECK( (z > y) );
|
||||
BOOST_CHECK( (y > x) );
|
||||
BOOST_CHECK( (z > x) );
|
||||
BOOST_TEST( (z > y) );
|
||||
BOOST_TEST( (y > x) );
|
||||
BOOST_TEST( (z > x) );
|
||||
|
||||
BOOST_CHECK( (z >= y) );
|
||||
BOOST_CHECK( (y >= x) );
|
||||
BOOST_CHECK( (z >= x) );
|
||||
BOOST_TEST( (z >= y) );
|
||||
BOOST_TEST( (y >= x) );
|
||||
BOOST_TEST( (z >= x) );
|
||||
|
||||
// antisymmetry check
|
||||
BOOST_CHECK( !(y < x) );
|
||||
BOOST_CHECK( !(z < y) );
|
||||
BOOST_CHECK( !(z < x) );
|
||||
BOOST_TEST( !(y < x) );
|
||||
BOOST_TEST( !(z < y) );
|
||||
BOOST_TEST( !(z < x) );
|
||||
}
|
||||
|
||||
template <typename It>
|
||||
@@ -122,7 +122,7 @@ std::string print_range(It first, It last)
|
||||
return result.str();
|
||||
}
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
typedef boost::variant<int, std::string> var_t;
|
||||
|
||||
@@ -146,13 +146,13 @@ int test_main(int , char* [])
|
||||
std::sort(vec.begin(), vec.end());
|
||||
|
||||
std::string sort_result( print_range(vec.begin(), vec.end()) );
|
||||
BOOST_CHECK( sort_result == "3 5 goodbye hello " );
|
||||
BOOST_TEST( sort_result == "3 5 goodbye hello " );
|
||||
|
||||
// https://svn.boost.org/trac/boost/ticket/11751
|
||||
int a = 0, b = 0;
|
||||
|
||||
boost::variant< int& > v (a), u (b);
|
||||
BOOST_CHECK(v == u);
|
||||
BOOST_TEST(v == u);
|
||||
|
||||
return boost::exit_success;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
+95
-95
@@ -3,7 +3,7 @@
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2014-2017 Antony Polukhin
|
||||
// Copyright (c) 2014-2018 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "boost/variant/variant.hpp"
|
||||
#include "boost/variant/polymorphic_get.hpp"
|
||||
#include "boost/variant/recursive_wrapper.hpp"
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
|
||||
struct base {
|
||||
int trash;
|
||||
@@ -63,32 +63,32 @@ inline void check_polymorphic_get_on_types_impl_single_type(V* v)
|
||||
const bool ref_same = !!boost::is_same<TypeInVariant, ref_test_t>::value;
|
||||
|
||||
if (exact_same || ref_same) {
|
||||
BOOST_CHECK(boost::polymorphic_get<TestType>(v));
|
||||
BOOST_CHECK(boost::polymorphic_get<const TestType>(v));
|
||||
BOOST_CHECK(boost::polymorphic_strict_get<TestType>(v));
|
||||
BOOST_CHECK(boost::polymorphic_strict_get<const TestType>(v));
|
||||
BOOST_CHECK(boost::polymorphic_relaxed_get<TestType>(v));
|
||||
BOOST_CHECK(boost::polymorphic_relaxed_get<const TestType>(v));
|
||||
BOOST_TEST(boost::polymorphic_get<TestType>(v));
|
||||
BOOST_TEST(boost::polymorphic_get<const TestType>(v));
|
||||
BOOST_TEST(boost::polymorphic_strict_get<TestType>(v));
|
||||
BOOST_TEST(boost::polymorphic_strict_get<const TestType>(v));
|
||||
BOOST_TEST(boost::polymorphic_relaxed_get<TestType>(v));
|
||||
BOOST_TEST(boost::polymorphic_relaxed_get<const TestType>(v));
|
||||
|
||||
BOOST_CHECK(boost::polymorphic_get<cref_test_t>(v));
|
||||
BOOST_CHECK(boost::polymorphic_strict_get<cref_test_t>(v));
|
||||
BOOST_CHECK(boost::polymorphic_relaxed_get<cref_test_t>(v));
|
||||
BOOST_TEST(boost::polymorphic_get<cref_test_t>(v));
|
||||
BOOST_TEST(boost::polymorphic_strict_get<cref_test_t>(v));
|
||||
BOOST_TEST(boost::polymorphic_relaxed_get<cref_test_t>(v));
|
||||
|
||||
if (ref_same) {
|
||||
BOOST_CHECK(boost::polymorphic_get<ref_test_t>(v));
|
||||
BOOST_CHECK(boost::polymorphic_get<cref_test_t>(v));
|
||||
BOOST_CHECK(boost::polymorphic_strict_get<ref_test_t>(v));
|
||||
BOOST_CHECK(boost::polymorphic_strict_get<cref_test_t>(v));
|
||||
BOOST_CHECK(boost::polymorphic_relaxed_get<ref_test_t>(v));
|
||||
BOOST_CHECK(boost::polymorphic_relaxed_get<cref_test_t>(v));
|
||||
BOOST_TEST(boost::polymorphic_get<ref_test_t>(v));
|
||||
BOOST_TEST(boost::polymorphic_get<cref_test_t>(v));
|
||||
BOOST_TEST(boost::polymorphic_strict_get<ref_test_t>(v));
|
||||
BOOST_TEST(boost::polymorphic_strict_get<cref_test_t>(v));
|
||||
BOOST_TEST(boost::polymorphic_relaxed_get<ref_test_t>(v));
|
||||
BOOST_TEST(boost::polymorphic_relaxed_get<cref_test_t>(v));
|
||||
}
|
||||
} else {
|
||||
BOOST_CHECK(!boost::polymorphic_get<TestType>(v));
|
||||
BOOST_CHECK(!boost::polymorphic_get<const TestType>(v));
|
||||
BOOST_CHECK(!boost::polymorphic_strict_get<TestType>(v));
|
||||
BOOST_CHECK(!boost::polymorphic_strict_get<const TestType>(v));
|
||||
BOOST_CHECK(!boost::polymorphic_relaxed_get<TestType>(v));
|
||||
BOOST_CHECK(!boost::polymorphic_relaxed_get<const TestType>(v));
|
||||
BOOST_TEST(!boost::polymorphic_get<TestType>(v));
|
||||
BOOST_TEST(!boost::polymorphic_get<const TestType>(v));
|
||||
BOOST_TEST(!boost::polymorphic_strict_get<TestType>(v));
|
||||
BOOST_TEST(!boost::polymorphic_strict_get<const TestType>(v));
|
||||
BOOST_TEST(!boost::polymorphic_relaxed_get<TestType>(v));
|
||||
BOOST_TEST(!boost::polymorphic_relaxed_get<const TestType>(v));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,32 +101,32 @@ inline void check_get_on_types_impl_single_type(V* v)
|
||||
const bool ref_same = !!boost::is_same<T, ref_test_t>::value;
|
||||
|
||||
if (exact_same || ref_same) {
|
||||
BOOST_CHECK(boost::get<TestType>(v));
|
||||
BOOST_CHECK(boost::get<const TestType>(v));
|
||||
BOOST_CHECK(boost::strict_get<TestType>(v));
|
||||
BOOST_CHECK(boost::strict_get<const TestType>(v));
|
||||
BOOST_CHECK(boost::relaxed_get<TestType>(v));
|
||||
BOOST_CHECK(boost::relaxed_get<const TestType>(v));
|
||||
BOOST_TEST(boost::get<TestType>(v));
|
||||
BOOST_TEST(boost::get<const TestType>(v));
|
||||
BOOST_TEST(boost::strict_get<TestType>(v));
|
||||
BOOST_TEST(boost::strict_get<const TestType>(v));
|
||||
BOOST_TEST(boost::relaxed_get<TestType>(v));
|
||||
BOOST_TEST(boost::relaxed_get<const TestType>(v));
|
||||
|
||||
BOOST_CHECK(boost::get<cref_test_t>(v));
|
||||
BOOST_CHECK(boost::strict_get<cref_test_t>(v));
|
||||
BOOST_CHECK(boost::relaxed_get<cref_test_t>(v));
|
||||
BOOST_TEST(boost::get<cref_test_t>(v));
|
||||
BOOST_TEST(boost::strict_get<cref_test_t>(v));
|
||||
BOOST_TEST(boost::relaxed_get<cref_test_t>(v));
|
||||
|
||||
if (ref_same) {
|
||||
BOOST_CHECK(boost::get<ref_test_t>(v));
|
||||
BOOST_CHECK(boost::get<cref_test_t>(v));
|
||||
BOOST_CHECK(boost::strict_get<ref_test_t>(v));
|
||||
BOOST_CHECK(boost::strict_get<cref_test_t>(v));
|
||||
BOOST_CHECK(boost::relaxed_get<ref_test_t>(v));
|
||||
BOOST_CHECK(boost::relaxed_get<cref_test_t>(v));
|
||||
BOOST_TEST(boost::get<ref_test_t>(v));
|
||||
BOOST_TEST(boost::get<cref_test_t>(v));
|
||||
BOOST_TEST(boost::strict_get<ref_test_t>(v));
|
||||
BOOST_TEST(boost::strict_get<cref_test_t>(v));
|
||||
BOOST_TEST(boost::relaxed_get<ref_test_t>(v));
|
||||
BOOST_TEST(boost::relaxed_get<cref_test_t>(v));
|
||||
}
|
||||
} else {
|
||||
BOOST_CHECK(!boost::get<TestType>(v));
|
||||
BOOST_CHECK(!boost::get<const TestType>(v));
|
||||
BOOST_CHECK(!boost::strict_get<TestType>(v));
|
||||
BOOST_CHECK(!boost::strict_get<const TestType>(v));
|
||||
BOOST_CHECK(!boost::relaxed_get<TestType>(v));
|
||||
BOOST_CHECK(!boost::relaxed_get<const TestType>(v));
|
||||
BOOST_TEST(!boost::get<TestType>(v));
|
||||
BOOST_TEST(!boost::get<const TestType>(v));
|
||||
BOOST_TEST(!boost::strict_get<TestType>(v));
|
||||
BOOST_TEST(!boost::strict_get<const TestType>(v));
|
||||
BOOST_TEST(!boost::relaxed_get<TestType>(v));
|
||||
BOOST_TEST(!boost::relaxed_get<const TestType>(v));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,19 +148,19 @@ inline void check_get_on_types_impl(V* v)
|
||||
check_polymorphic_get_on_types_impl_single_type<T, V, std::string>(v);
|
||||
|
||||
// Never exist in here
|
||||
BOOST_CHECK(!boost::relaxed_get<short>(v));
|
||||
BOOST_CHECK(!boost::relaxed_get<const short>(v));
|
||||
BOOST_CHECK(!boost::relaxed_get<char>(v));
|
||||
BOOST_CHECK(!boost::relaxed_get<char*>(v));
|
||||
BOOST_CHECK(!boost::relaxed_get<bool>(v));
|
||||
BOOST_CHECK(!boost::relaxed_get<const bool>(v));
|
||||
BOOST_TEST(!boost::relaxed_get<short>(v));
|
||||
BOOST_TEST(!boost::relaxed_get<const short>(v));
|
||||
BOOST_TEST(!boost::relaxed_get<char>(v));
|
||||
BOOST_TEST(!boost::relaxed_get<char*>(v));
|
||||
BOOST_TEST(!boost::relaxed_get<bool>(v));
|
||||
BOOST_TEST(!boost::relaxed_get<const bool>(v));
|
||||
|
||||
BOOST_CHECK(!boost::polymorphic_relaxed_get<short>(v));
|
||||
BOOST_CHECK(!boost::polymorphic_relaxed_get<const short>(v));
|
||||
BOOST_CHECK(!boost::polymorphic_relaxed_get<char>(v));
|
||||
BOOST_CHECK(!boost::polymorphic_relaxed_get<char*>(v));
|
||||
BOOST_CHECK(!boost::polymorphic_relaxed_get<bool>(v));
|
||||
BOOST_CHECK(!boost::polymorphic_relaxed_get<const bool>(v));
|
||||
BOOST_TEST(!boost::polymorphic_relaxed_get<short>(v));
|
||||
BOOST_TEST(!boost::polymorphic_relaxed_get<const short>(v));
|
||||
BOOST_TEST(!boost::polymorphic_relaxed_get<char>(v));
|
||||
BOOST_TEST(!boost::polymorphic_relaxed_get<char*>(v));
|
||||
BOOST_TEST(!boost::polymorphic_relaxed_get<bool>(v));
|
||||
BOOST_TEST(!boost::polymorphic_relaxed_get<const bool>(v));
|
||||
|
||||
boost::get<T>(*v); // Must compile
|
||||
boost::get<const T>(*v); // Must compile
|
||||
@@ -271,20 +271,20 @@ inline void get_cref_test()
|
||||
{
|
||||
int i = 0;
|
||||
var_cref_t v(i);
|
||||
BOOST_CHECK(boost::get<const int>(&v));
|
||||
BOOST_CHECK(boost::get<const int&>(&v));
|
||||
BOOST_CHECK(!boost::get<const base>(&v));
|
||||
BOOST_TEST(boost::get<const int>(&v));
|
||||
BOOST_TEST(boost::get<const int&>(&v));
|
||||
BOOST_TEST(!boost::get<const base>(&v));
|
||||
|
||||
base b;
|
||||
var_cref_t v1(b);
|
||||
BOOST_CHECK(boost::get<const base>(&v1));
|
||||
BOOST_CHECK(!boost::get<const derived1>(&v1));
|
||||
BOOST_CHECK(!boost::get<const int>(&v1));
|
||||
BOOST_TEST(boost::get<const base>(&v1));
|
||||
BOOST_TEST(!boost::get<const derived1>(&v1));
|
||||
BOOST_TEST(!boost::get<const int>(&v1));
|
||||
|
||||
std::string s("Hello");
|
||||
const var_cref_t v4 = s;
|
||||
BOOST_CHECK(boost::get<const std::string>(&v4));
|
||||
BOOST_CHECK(!boost::get<const int>(&v4));
|
||||
BOOST_TEST(boost::get<const std::string>(&v4));
|
||||
BOOST_TEST(!boost::get<const int>(&v4));
|
||||
}
|
||||
|
||||
inline void get_recursive_test()
|
||||
@@ -314,45 +314,45 @@ inline void check_that_does_not_exist_impl()
|
||||
{
|
||||
using namespace boost::detail::variant;
|
||||
|
||||
BOOST_CHECK((holds_element<T, const int>::value));
|
||||
BOOST_CHECK((!holds_element<T, short>::value));
|
||||
BOOST_CHECK((!holds_element<T, short>::value));
|
||||
BOOST_CHECK((!holds_element<T, const short>::value));
|
||||
BOOST_CHECK((!holds_element<T, char*>::value));
|
||||
BOOST_CHECK((!holds_element<T, const char*>::value));
|
||||
BOOST_CHECK((!holds_element<T, char[5]>::value));
|
||||
BOOST_CHECK((!holds_element<T, const char[5]>::value));
|
||||
BOOST_CHECK((!holds_element<T, bool>::value));
|
||||
BOOST_CHECK((!holds_element<T, const bool>::value));
|
||||
BOOST_TEST((holds_element<T, const int>::value));
|
||||
BOOST_TEST((!holds_element<T, short>::value));
|
||||
BOOST_TEST((!holds_element<T, short>::value));
|
||||
BOOST_TEST((!holds_element<T, const short>::value));
|
||||
BOOST_TEST((!holds_element<T, char*>::value));
|
||||
BOOST_TEST((!holds_element<T, const char*>::value));
|
||||
BOOST_TEST((!holds_element<T, char[5]>::value));
|
||||
BOOST_TEST((!holds_element<T, const char[5]>::value));
|
||||
BOOST_TEST((!holds_element<T, bool>::value));
|
||||
BOOST_TEST((!holds_element<T, const bool>::value));
|
||||
|
||||
BOOST_CHECK((!holds_element<T, boost::recursive_wrapper<int> >::value));
|
||||
BOOST_CHECK((!holds_element<T, boost::recursive_wrapper<short> >::value));
|
||||
BOOST_CHECK((!holds_element<T, boost::detail::reference_content<short> >::value));
|
||||
BOOST_TEST((!holds_element<T, boost::recursive_wrapper<int> >::value));
|
||||
BOOST_TEST((!holds_element<T, boost::recursive_wrapper<short> >::value));
|
||||
BOOST_TEST((!holds_element<T, boost::detail::reference_content<short> >::value));
|
||||
|
||||
|
||||
BOOST_CHECK((holds_element_polymorphic<T, const int>::value));
|
||||
BOOST_CHECK((!holds_element_polymorphic<T, short>::value));
|
||||
BOOST_CHECK((!holds_element_polymorphic<T, short>::value));
|
||||
BOOST_CHECK((!holds_element_polymorphic<T, const short>::value));
|
||||
BOOST_CHECK((!holds_element_polymorphic<T, char*>::value));
|
||||
BOOST_CHECK((!holds_element_polymorphic<T, const char*>::value));
|
||||
BOOST_CHECK((!holds_element_polymorphic<T, char[5]>::value));
|
||||
BOOST_CHECK((!holds_element_polymorphic<T, const char[5]>::value));
|
||||
BOOST_CHECK((!holds_element_polymorphic<T, bool>::value));
|
||||
BOOST_CHECK((!holds_element_polymorphic<T, const bool>::value));
|
||||
BOOST_TEST((holds_element_polymorphic<T, const int>::value));
|
||||
BOOST_TEST((!holds_element_polymorphic<T, short>::value));
|
||||
BOOST_TEST((!holds_element_polymorphic<T, short>::value));
|
||||
BOOST_TEST((!holds_element_polymorphic<T, const short>::value));
|
||||
BOOST_TEST((!holds_element_polymorphic<T, char*>::value));
|
||||
BOOST_TEST((!holds_element_polymorphic<T, const char*>::value));
|
||||
BOOST_TEST((!holds_element_polymorphic<T, char[5]>::value));
|
||||
BOOST_TEST((!holds_element_polymorphic<T, const char[5]>::value));
|
||||
BOOST_TEST((!holds_element_polymorphic<T, bool>::value));
|
||||
BOOST_TEST((!holds_element_polymorphic<T, const bool>::value));
|
||||
|
||||
BOOST_CHECK((!holds_element_polymorphic<T, boost::recursive_wrapper<int> >::value));
|
||||
BOOST_CHECK((!holds_element_polymorphic<T, boost::recursive_wrapper<short> >::value));
|
||||
BOOST_CHECK((!holds_element_polymorphic<T, boost::detail::reference_content<short> >::value));
|
||||
BOOST_TEST((!holds_element_polymorphic<T, boost::recursive_wrapper<int> >::value));
|
||||
BOOST_TEST((!holds_element_polymorphic<T, boost::recursive_wrapper<short> >::value));
|
||||
BOOST_TEST((!holds_element_polymorphic<T, boost::detail::reference_content<short> >::value));
|
||||
}
|
||||
|
||||
inline void check_that_does_not_exist()
|
||||
{
|
||||
using namespace boost::detail::variant;
|
||||
|
||||
BOOST_CHECK((holds_element<var_t, int>::value));
|
||||
BOOST_CHECK((holds_element<var_ref_t, int>::value));
|
||||
BOOST_CHECK((!holds_element<var_cref_t, int>::value));
|
||||
BOOST_TEST((holds_element<var_t, int>::value));
|
||||
BOOST_TEST((holds_element<var_ref_t, int>::value));
|
||||
BOOST_TEST((!holds_element<var_cref_t, int>::value));
|
||||
|
||||
check_that_does_not_exist_impl<var_t>();
|
||||
check_that_does_not_exist_impl<var_ref_t>();
|
||||
@@ -399,7 +399,7 @@ inline void get_rvref_test()
|
||||
}
|
||||
#endif // BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
get_test();
|
||||
get_test_no_fallback();
|
||||
@@ -412,5 +412,5 @@ int test_main(int , char* [])
|
||||
get_rvref_test();
|
||||
#endif
|
||||
|
||||
return boost::exit_success;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2013-2015 Antony Polukhin
|
||||
// Copyright (c) 2013-2018 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "boost/variant/multivisitors.hpp"
|
||||
#include "boost/variant.hpp"
|
||||
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
|
||||
struct my_noncopyable : boost::noncopyable {
|
||||
my_noncopyable(){}
|
||||
@@ -32,59 +32,59 @@ struct test_visitor: boost::static_visitor<> {
|
||||
template <class T1, class T2, class T3>
|
||||
void operator()(T1&, T2&, T3&) const
|
||||
{
|
||||
BOOST_CHECK(false);
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
|
||||
template <class T1, class T2, class T3, class T4>
|
||||
void operator()(T1&, T2&, T3&, T4&) const
|
||||
{
|
||||
BOOST_CHECK(false);
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
|
||||
template <class T1, class T2, class T3, class T4, class T5>
|
||||
void operator()(T1&, T2&, T3&, T4&, T5&) const
|
||||
{
|
||||
BOOST_CHECK(false);
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
|
||||
// operators that are OK to call
|
||||
void operator()(char v0, unsigned char v1, signed char v2) const
|
||||
{
|
||||
BOOST_CHECK(v0 == 0);
|
||||
BOOST_CHECK(v1 == 1);
|
||||
BOOST_CHECK(v2 == 2);
|
||||
BOOST_TEST(v0 == 0);
|
||||
BOOST_TEST(v1 == 1);
|
||||
BOOST_TEST(v2 == 2);
|
||||
}
|
||||
|
||||
void operator()(char v0, unsigned char v1, signed char v2, unsigned short v3) const
|
||||
{
|
||||
BOOST_CHECK(v0 == 0);
|
||||
BOOST_CHECK(v1 == 1);
|
||||
BOOST_CHECK(v2 == 2);
|
||||
BOOST_CHECK(v3 == 3);
|
||||
BOOST_TEST(v0 == 0);
|
||||
BOOST_TEST(v1 == 1);
|
||||
BOOST_TEST(v2 == 2);
|
||||
BOOST_TEST(v3 == 3);
|
||||
}
|
||||
|
||||
void operator()(char v0, unsigned char v1, signed char v2, unsigned short v3, int v4) const
|
||||
{
|
||||
BOOST_CHECK(v0 == 0);
|
||||
BOOST_CHECK(v1 == 1);
|
||||
BOOST_CHECK(v2 == 2);
|
||||
BOOST_CHECK(v3 == 3);
|
||||
BOOST_CHECK(v4 == 4);
|
||||
BOOST_TEST(v0 == 0);
|
||||
BOOST_TEST(v1 == 1);
|
||||
BOOST_TEST(v2 == 2);
|
||||
BOOST_TEST(v3 == 3);
|
||||
BOOST_TEST(v4 == 4);
|
||||
}
|
||||
|
||||
|
||||
// Noncopyables
|
||||
void operator()(my_noncopyable&, my_noncopyable&, my_noncopyable&) const {
|
||||
BOOST_CHECK(true);
|
||||
BOOST_TEST(true);
|
||||
}
|
||||
void operator()(my_noncopyable&, my_noncopyable&, my_noncopyable&, my_noncopyable&) const {
|
||||
BOOST_CHECK(true);
|
||||
BOOST_TEST(true);
|
||||
}
|
||||
void operator()(my_noncopyable&, my_noncopyable&, my_noncopyable&, my_noncopyable&, my_noncopyable&) const {
|
||||
BOOST_CHECK(true);
|
||||
BOOST_TEST(true);
|
||||
}
|
||||
void operator()(my_noncopyable&, my_noncopyable&, my_noncopyable&, my_noncopyable&, my_noncopyable&, my_noncopyable&) const {
|
||||
BOOST_CHECK(true);
|
||||
BOOST_TEST(true);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -103,7 +103,7 @@ struct if_visitor: public boost::static_visitor<arithmetics_t> {
|
||||
};
|
||||
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
test_visitor v;
|
||||
|
||||
@@ -130,7 +130,7 @@ int test_main(int , char* [])
|
||||
|
||||
bool_like_t v0(1), v1(true), v2(1.0);
|
||||
|
||||
BOOST_CHECK(
|
||||
BOOST_TEST(
|
||||
boost::apply_visitor(if_visitor(), v0, v1, v2)
|
||||
==
|
||||
arithmetics_t(true)
|
||||
@@ -138,7 +138,7 @@ int test_main(int , char* [])
|
||||
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
if_visitor if_vis;
|
||||
BOOST_CHECK(
|
||||
BOOST_TEST(
|
||||
boost::apply_visitor(if_vis)(v0, v1, v2)
|
||||
==
|
||||
arithmetics_t(true)
|
||||
@@ -155,5 +155,5 @@ int test_main(int , char* [])
|
||||
boost::apply_visitor(test_visitor(), vnonc[0], vnonc[1], vnonc[2], vnonc[3], vnonc[4], vnonc[5]);
|
||||
#endif
|
||||
|
||||
return boost::exit_success;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2014 Antony Polukhin
|
||||
// Copyright (c) 2014-2018 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#include "boost/variant/variant.hpp"
|
||||
#include "boost/variant/get.hpp"
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include <stdexcept>
|
||||
|
||||
struct exception_on_assignment : std::exception {};
|
||||
@@ -197,21 +197,21 @@ inline void check_1_impl(int helper)
|
||||
boost::variant<throwing_class, Nonthrowing> v;
|
||||
try {
|
||||
v = throwing_class(helper);
|
||||
BOOST_CHECK(!v.which());
|
||||
BOOST_CHECK(boost::get<throwing_class>(&v));
|
||||
BOOST_TEST(!v.which());
|
||||
BOOST_TEST(boost::get<throwing_class>(&v));
|
||||
} catch (const exception_on_assignment& /*e*/) {
|
||||
BOOST_CHECK(!v.which());
|
||||
BOOST_CHECK(boost::get<throwing_class>(&v));
|
||||
BOOST_TEST(!v.which());
|
||||
BOOST_TEST(boost::get<throwing_class>(&v));
|
||||
}
|
||||
|
||||
try {
|
||||
throwing_class tc(helper);
|
||||
v = tc;
|
||||
BOOST_CHECK(!v.which());
|
||||
BOOST_CHECK(boost::get<throwing_class>(&v));
|
||||
BOOST_TEST(!v.which());
|
||||
BOOST_TEST(boost::get<throwing_class>(&v));
|
||||
} catch (const exception_on_assignment& /*e*/) {
|
||||
BOOST_CHECK(!v.which());
|
||||
BOOST_CHECK(boost::get<throwing_class>(&v));
|
||||
BOOST_TEST(!v.which());
|
||||
BOOST_TEST(boost::get<throwing_class>(&v));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,21 +230,21 @@ inline void check_2_impl(int helper)
|
||||
boost::variant<Nonthrowing, throwing_class> v;
|
||||
try {
|
||||
v = throwing_class(helper);
|
||||
BOOST_CHECK(v.which() == 1);
|
||||
BOOST_CHECK(boost::get<throwing_class>(&v));
|
||||
BOOST_TEST(v.which() == 1);
|
||||
BOOST_TEST(boost::get<throwing_class>(&v));
|
||||
} catch (const exception_on_assignment& /*e*/) {
|
||||
BOOST_CHECK(!v.which());
|
||||
BOOST_CHECK(boost::get<Nonthrowing>(&v));
|
||||
BOOST_TEST(!v.which());
|
||||
BOOST_TEST(boost::get<Nonthrowing>(&v));
|
||||
}
|
||||
|
||||
try {
|
||||
throwing_class cl(helper);
|
||||
v = cl;
|
||||
BOOST_CHECK(v.which() == 1);
|
||||
BOOST_CHECK(boost::get<throwing_class>(&v));
|
||||
BOOST_TEST(v.which() == 1);
|
||||
BOOST_TEST(boost::get<throwing_class>(&v));
|
||||
} catch (const exception_on_assignment& /*e*/) {
|
||||
BOOST_CHECK(!v.which());
|
||||
BOOST_CHECK(boost::get<Nonthrowing>(&v));
|
||||
BOOST_TEST(!v.which());
|
||||
BOOST_TEST(boost::get<Nonthrowing>(&v));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,30 +265,30 @@ inline void check_3_impl(int helper)
|
||||
swap(v1, v2);
|
||||
try {
|
||||
v1 = throwing_class(helper);
|
||||
BOOST_CHECK(v1.which() == 1);
|
||||
BOOST_CHECK(boost::get<throwing_class>(&v1));
|
||||
BOOST_TEST(v1.which() == 1);
|
||||
BOOST_TEST(boost::get<throwing_class>(&v1));
|
||||
} catch (const exception_on_assignment& /*e*/) {
|
||||
BOOST_CHECK(!v1.which());
|
||||
BOOST_CHECK(boost::get<Nonthrowing>(&v1));
|
||||
BOOST_TEST(!v1.which());
|
||||
BOOST_TEST(boost::get<Nonthrowing>(&v1));
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
v2 = throwing_class(helper);
|
||||
BOOST_CHECK(v2.which() == 1);
|
||||
BOOST_CHECK(boost::get<throwing_class>(&v2));
|
||||
BOOST_TEST(v2.which() == 1);
|
||||
BOOST_TEST(boost::get<throwing_class>(&v2));
|
||||
} catch (const exception_on_assignment& /*e*/) {
|
||||
BOOST_CHECK(!v2.which());
|
||||
BOOST_CHECK(boost::get<Nonthrowing>(&v2));
|
||||
BOOST_TEST(!v2.which());
|
||||
BOOST_TEST(boost::get<Nonthrowing>(&v2));
|
||||
}
|
||||
|
||||
|
||||
if (!v1.which() && !v2.which()) {
|
||||
swap(v1, v2); // Make sure that two backup holders swap well
|
||||
BOOST_CHECK(!v1.which());
|
||||
BOOST_CHECK(boost::get<Nonthrowing>(&v1));
|
||||
BOOST_CHECK(!v2.which());
|
||||
BOOST_CHECK(boost::get<Nonthrowing>(&v2));
|
||||
BOOST_TEST(!v1.which());
|
||||
BOOST_TEST(boost::get<Nonthrowing>(&v1));
|
||||
BOOST_TEST(!v2.which());
|
||||
BOOST_TEST(boost::get<Nonthrowing>(&v2));
|
||||
|
||||
v1 = v2;
|
||||
}
|
||||
@@ -311,29 +311,29 @@ inline void check_4(int helper = 1)
|
||||
swap(v1, v2);
|
||||
try {
|
||||
v1 = throwing_class(helper);
|
||||
BOOST_CHECK(v1.which() == 1);
|
||||
BOOST_CHECK(boost::get<throwing_class>(&v1));
|
||||
BOOST_TEST(v1.which() == 1);
|
||||
BOOST_TEST(boost::get<throwing_class>(&v1));
|
||||
} catch (const exception_on_assignment& /*e*/) {
|
||||
BOOST_CHECK(!v1.which());
|
||||
BOOST_CHECK(boost::get<int>(&v1));
|
||||
BOOST_TEST(!v1.which());
|
||||
BOOST_TEST(boost::get<int>(&v1));
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
v2 = throwing_class(helper);
|
||||
BOOST_CHECK(v2.which() == 1);
|
||||
BOOST_CHECK(boost::get<throwing_class>(&v2));
|
||||
BOOST_TEST(v2.which() == 1);
|
||||
BOOST_TEST(boost::get<throwing_class>(&v2));
|
||||
} catch (const exception_on_assignment& /*e*/) {
|
||||
BOOST_CHECK(!v2.which());
|
||||
BOOST_CHECK(boost::get<int>(&v2));
|
||||
BOOST_TEST(!v2.which());
|
||||
BOOST_TEST(boost::get<int>(&v2));
|
||||
}
|
||||
|
||||
if (!v1.which() && !v2.which()) {
|
||||
swap(v1, v2);
|
||||
BOOST_CHECK(!v1.which());
|
||||
BOOST_CHECK(boost::get<int>(&v1));
|
||||
BOOST_CHECK(!v2.which());
|
||||
BOOST_CHECK(boost::get<int>(&v2));
|
||||
BOOST_TEST(!v1.which());
|
||||
BOOST_TEST(boost::get<int>(&v1));
|
||||
BOOST_TEST(!v2.which());
|
||||
BOOST_TEST(boost::get<int>(&v2));
|
||||
|
||||
v1 = v2;
|
||||
}
|
||||
@@ -353,11 +353,11 @@ inline void check_5_impl(int helper)
|
||||
|
||||
try {
|
||||
v1 = throwing_class(helper);
|
||||
BOOST_CHECK(v1.which() == 1);
|
||||
BOOST_CHECK(boost::get<throwing_class>(&v1));
|
||||
BOOST_TEST(v1.which() == 1);
|
||||
BOOST_TEST(boost::get<throwing_class>(&v1));
|
||||
} catch (const exception_on_assignment& /*e*/) {
|
||||
BOOST_CHECK(v1.which() == 1);
|
||||
BOOST_CHECK(boost::get<throwing_class>(&v1));
|
||||
BOOST_TEST(v1.which() == 1);
|
||||
BOOST_TEST(boost::get<throwing_class>(&v1));
|
||||
}
|
||||
|
||||
boost::get<throwing_class>(v1).trash = throwing_class::do_not_throw;
|
||||
@@ -366,22 +366,22 @@ inline void check_5_impl(int helper)
|
||||
v2 = Nonthrowing();
|
||||
try {
|
||||
v1 = throwing_class(helper);
|
||||
BOOST_CHECK(v1.which() == 1);
|
||||
BOOST_CHECK(boost::get<throwing_class>(&v1));
|
||||
BOOST_TEST(v1.which() == 1);
|
||||
BOOST_TEST(boost::get<throwing_class>(&v1));
|
||||
} catch (const exception_on_assignment& /*e*/) {
|
||||
BOOST_CHECK(v1.which() == 0);
|
||||
BOOST_CHECK(boost::get<Nonthrowing>(&v1));
|
||||
BOOST_TEST(v1.which() == 0);
|
||||
BOOST_TEST(boost::get<Nonthrowing>(&v1));
|
||||
}
|
||||
|
||||
int v1_type = v1.which();
|
||||
int v2_type = v2.which();
|
||||
try {
|
||||
swap(v1, v2); // Make sure that backup holders swap well
|
||||
BOOST_CHECK(v1.which() == v2_type);
|
||||
BOOST_CHECK(v2.which() == v1_type);
|
||||
BOOST_TEST(v1.which() == v2_type);
|
||||
BOOST_TEST(v2.which() == v1_type);
|
||||
} catch (const exception_on_assignment& /*e*/) {
|
||||
BOOST_CHECK(v1.which() == v1_type);
|
||||
BOOST_CHECK(v2.which() == v2_type);
|
||||
BOOST_TEST(v1.which() == v1_type);
|
||||
BOOST_TEST(v2.which() == v2_type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -418,18 +418,18 @@ inline void check_6_impl(int helper)
|
||||
throwing_class tc;
|
||||
tc.trash = helper;
|
||||
v1 = tc;
|
||||
BOOST_CHECK(v1.which() == 1);
|
||||
BOOST_CHECK(boost::get<throwing_class>(&v1));
|
||||
BOOST_TEST(v1.which() == 1);
|
||||
BOOST_TEST(boost::get<throwing_class>(&v1));
|
||||
} catch (const exception_on_assignment& /*e*/) {
|
||||
BOOST_CHECK(v1.which() == 0);
|
||||
BOOST_TEST(v1.which() == 0);
|
||||
}
|
||||
|
||||
v2 = Nonthrowing();
|
||||
try {
|
||||
v2 = 2;
|
||||
BOOST_CHECK(false);
|
||||
BOOST_TEST(false);
|
||||
} catch (const exception_on_assignment& /*e*/) {
|
||||
BOOST_CHECK(v2.which() == 0);
|
||||
BOOST_TEST(v2.which() == 0);
|
||||
}
|
||||
|
||||
// Probably the most significant test:
|
||||
@@ -439,9 +439,9 @@ inline void check_6_impl(int helper)
|
||||
try {
|
||||
swap(v1, v2);
|
||||
} catch (const exception_on_assignment& /*e*/) {
|
||||
BOOST_CHECK(v1.which() == 1);
|
||||
BOOST_CHECK(v2.which() == 0);
|
||||
BOOST_CHECK(boost::get<throwing_class>(v1).trash == helper);
|
||||
BOOST_TEST(v1.which() == 1);
|
||||
BOOST_TEST(v2.which() == 0);
|
||||
BOOST_TEST(boost::get<throwing_class>(v1).trash == helper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -455,7 +455,7 @@ inline void check_6(int helper = 1)
|
||||
check_6_impl<boost::blank>(helper);
|
||||
}
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
// throwing_class::throw_after_1 + 1 => throw on first assignment/construction
|
||||
// throwing_class::throw_after_1 => throw on second assignment/construction
|
||||
@@ -470,5 +470,5 @@ int test_main(int , char* [])
|
||||
check_6(i);
|
||||
}
|
||||
|
||||
return boost::exit_success;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "boost/config.hpp"
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
|
||||
#include "boost/variant.hpp"
|
||||
#include "boost/mpl/joint_view.hpp"
|
||||
@@ -22,9 +22,9 @@ template<class T, class Variant>
|
||||
void check_exception_on_get(Variant& v) {
|
||||
try {
|
||||
boost::get<T>(v);
|
||||
BOOST_FAIL("Expected exception boost::bad_get, but got nothing.");
|
||||
BOOST_ERROR("Expected exception boost::bad_get, but got nothing.");
|
||||
} catch (boost::bad_get&) { //okay it is expected behaviour
|
||||
} catch (...) { BOOST_FAIL("Expected exception boost::bad_get, but got something else."); }
|
||||
} catch (...) { BOOST_ERROR("Expected exception boost::bad_get, but got something else."); }
|
||||
}
|
||||
|
||||
void test_joint_view() {
|
||||
@@ -35,11 +35,11 @@ void test_joint_view() {
|
||||
v1 a = 1;
|
||||
v2 b = "2";
|
||||
v3 c = a;
|
||||
BOOST_CHECK(boost::get<int>(c) == 1);
|
||||
BOOST_CHECK(c.which() == 0);
|
||||
BOOST_TEST(boost::get<int>(c) == 1);
|
||||
BOOST_TEST(c.which() == 0);
|
||||
v3 d = b;
|
||||
BOOST_CHECK(boost::get<std::string>(d) == "2");
|
||||
BOOST_CHECK(d.which() == 1);
|
||||
BOOST_TEST(boost::get<std::string>(d) == "2");
|
||||
BOOST_TEST(d.which() == 1);
|
||||
check_exception_on_get<std::string>(c);
|
||||
check_exception_on_get<int>(d);
|
||||
}
|
||||
@@ -49,16 +49,16 @@ void test_set() {
|
||||
typedef boost::make_variant_over< types >::type v;
|
||||
|
||||
v a = 1;
|
||||
BOOST_CHECK(boost::get<int>(a) == 1);
|
||||
BOOST_TEST(boost::get<int>(a) == 1);
|
||||
check_exception_on_get<std::string>(a);
|
||||
a = "2";
|
||||
BOOST_CHECK(boost::get<std::string>(a) == "2");
|
||||
BOOST_TEST(boost::get<std::string>(a) == "2");
|
||||
check_exception_on_get<int>(a);
|
||||
}
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
test_joint_view();
|
||||
test_set();
|
||||
return 0;
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2003 Eric Friedman
|
||||
// Copyright (c) 2013-2014 Antony Polukhin
|
||||
// Copyright (c) 2013-2018 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "boost/variant/apply_visitor.hpp"
|
||||
#include "boost/variant/static_visitor.hpp"
|
||||
#include "boost/variant/polymorphic_get.hpp"
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
|
||||
struct base {int trash;};
|
||||
struct derived1 : base{};
|
||||
@@ -29,53 +29,53 @@ template <class T, class Variant>
|
||||
inline void check_throws(Variant& v) {
|
||||
try {
|
||||
boost::polymorphic_get<T>(v);
|
||||
BOOST_CHECK(false);
|
||||
BOOST_TEST(false);
|
||||
} catch (const boost::bad_polymorphic_get& e) {
|
||||
BOOST_CHECK(!!e.what());
|
||||
BOOST_CHECK(std::string(e.what()) != boost::bad_get().what());
|
||||
BOOST_TEST(!!e.what());
|
||||
BOOST_TEST(std::string(e.what()) != boost::bad_get().what());
|
||||
}
|
||||
}
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
typedef boost::variant<int, base, derived1, derived2> var_t;
|
||||
|
||||
var_t var1;
|
||||
BOOST_CHECK(!boost::polymorphic_get<base>(&var1));
|
||||
BOOST_TEST(!boost::polymorphic_get<base>(&var1));
|
||||
check_throws<base>(var1);
|
||||
BOOST_CHECK(!boost::polymorphic_get<const base>(&var1));
|
||||
BOOST_TEST(!boost::polymorphic_get<const base>(&var1));
|
||||
check_throws<base, const var_t>(var1);
|
||||
|
||||
var1 = derived1();
|
||||
BOOST_CHECK(boost::polymorphic_get<base>(&var1));
|
||||
BOOST_CHECK(boost::polymorphic_get<const base>(&var1));
|
||||
BOOST_TEST(boost::polymorphic_get<base>(&var1));
|
||||
BOOST_TEST(boost::polymorphic_get<const base>(&var1));
|
||||
|
||||
derived2 d;
|
||||
d.trash = 777;
|
||||
var_t var2 = d;
|
||||
BOOST_CHECK(boost::polymorphic_get<base>(var2).trash == 777);
|
||||
BOOST_CHECK(boost::polymorphic_get<const base>(var2).trash == 777);
|
||||
BOOST_TEST(boost::polymorphic_get<base>(var2).trash == 777);
|
||||
BOOST_TEST(boost::polymorphic_get<const base>(var2).trash == 777);
|
||||
|
||||
var2 = 777;
|
||||
BOOST_CHECK(!boost::polymorphic_get<base>(&var2));
|
||||
BOOST_TEST(!boost::polymorphic_get<base>(&var2));
|
||||
check_throws<base>(var2);
|
||||
BOOST_CHECK(!boost::polymorphic_get<const base>(&var2));
|
||||
BOOST_TEST(!boost::polymorphic_get<const base>(&var2));
|
||||
check_throws<base, const var_t>(var2);
|
||||
BOOST_CHECK(boost::polymorphic_get<int>(var2) == 777);
|
||||
BOOST_CHECK(boost::polymorphic_get<const int>(var2) == 777);
|
||||
BOOST_TEST(boost::polymorphic_get<int>(var2) == 777);
|
||||
BOOST_TEST(boost::polymorphic_get<const int>(var2) == 777);
|
||||
|
||||
typedef boost::variant<int, vbase, vderived1, vderived2, vderived3> vvar_t;
|
||||
|
||||
vvar_t v = vderived3();
|
||||
boost::polymorphic_get<vderived3>(v).trash = 777;
|
||||
const vvar_t& cv = v;
|
||||
BOOST_CHECK(boost::polymorphic_get<vbase>(cv).trash == 777);
|
||||
BOOST_CHECK(boost::polymorphic_get<const vbase>(cv).trash == 777);
|
||||
BOOST_TEST(boost::polymorphic_get<vbase>(cv).trash == 777);
|
||||
BOOST_TEST(boost::polymorphic_get<const vbase>(cv).trash == 777);
|
||||
|
||||
BOOST_CHECK(boost::polymorphic_get<vbase>(cv).foo() == 3);
|
||||
BOOST_CHECK(boost::polymorphic_get<vbase>(v).foo() == 3);
|
||||
BOOST_CHECK(boost::polymorphic_get<const vbase>(cv).foo() == 3);
|
||||
BOOST_CHECK(boost::polymorphic_get<const vbase>(v).foo() == 3);
|
||||
BOOST_TEST(boost::polymorphic_get<vbase>(cv).foo() == 3);
|
||||
BOOST_TEST(boost::polymorphic_get<vbase>(v).foo() == 3);
|
||||
BOOST_TEST(boost::polymorphic_get<const vbase>(cv).foo() == 3);
|
||||
BOOST_TEST(boost::polymorphic_get<const vbase>(v).foo() == 3);
|
||||
|
||||
return boost::exit_success;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "boost/variant.hpp"
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
|
||||
#include "boost/mpl/bool.hpp"
|
||||
#include "boost/type_traits/add_reference.hpp"
|
||||
@@ -55,37 +55,37 @@ wknd_get(boost::variant<T>& var, int)
|
||||
template <typename T>
|
||||
void test_reference_content(T& t, const T& value1, const T& value2)
|
||||
{
|
||||
BOOST_CHECK( !(value1 == value2) );
|
||||
BOOST_TEST( !(value1 == value2) );
|
||||
|
||||
/////
|
||||
|
||||
boost::variant< T& > var(t);
|
||||
BOOST_CHECK(( boost::get<T>(&var) == &t ));
|
||||
BOOST_TEST(( boost::get<T>(&var) == &t ));
|
||||
|
||||
t = value1;
|
||||
BOOST_CHECK(( boost::get<T>(var) == value1 ));
|
||||
BOOST_TEST(( boost::get<T>(var) == value1 ));
|
||||
|
||||
/////
|
||||
|
||||
boost::variant< T > var2(var);
|
||||
BOOST_CHECK(( boost::get<T>(var2) == value1 ));
|
||||
BOOST_TEST(( boost::get<T>(var2) == value1 ));
|
||||
|
||||
t = value2;
|
||||
BOOST_CHECK(( boost::get<T>(var2) == value1 ));
|
||||
BOOST_TEST(( boost::get<T>(var2) == value1 ));
|
||||
}
|
||||
|
||||
template <typename Base, typename Derived>
|
||||
void base_derived_test(Derived d)
|
||||
{
|
||||
Base b(d);
|
||||
BOOST_CHECK((check_base_derived(
|
||||
BOOST_TEST((check_base_derived(
|
||||
b
|
||||
, d
|
||||
, 1L
|
||||
)));
|
||||
|
||||
boost::variant<Base> base_var(d);
|
||||
BOOST_CHECK((check_base_derived(
|
||||
BOOST_TEST((check_base_derived(
|
||||
wknd_get(base_var, 1L)
|
||||
, d
|
||||
, 1L
|
||||
@@ -93,14 +93,14 @@ void base_derived_test(Derived d)
|
||||
|
||||
boost::variant<Derived> derived_var(d);
|
||||
boost::variant<Base> base_from_derived_var(derived_var);
|
||||
BOOST_CHECK((check_base_derived(
|
||||
BOOST_TEST((check_base_derived(
|
||||
wknd_get(base_from_derived_var, 1L)
|
||||
, wknd_get(derived_var, 1L)
|
||||
, 1L
|
||||
)));
|
||||
}
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
int i = 0;
|
||||
test_reference_content(i, 1, 2);
|
||||
@@ -112,5 +112,5 @@ int test_main(int , char* [])
|
||||
base_derived_test< base_t*,derived_t* >(&d);
|
||||
base_derived_test< base_t&,derived_t& >(d);
|
||||
|
||||
return boost::exit_success;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include "boost/variant/get.hpp"
|
||||
#include "boost/variant/variant.hpp"
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
|
||||
#include <boost/move/move.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
@@ -36,8 +36,8 @@ inline void run()
|
||||
#endif
|
||||
}
|
||||
|
||||
int test_main(int /*argc*/, char* /*argv*/ [])
|
||||
int main()
|
||||
{
|
||||
run();
|
||||
return boost::exit_success;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
+20
-20
@@ -4,13 +4,13 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2009 ArtVPS Ltd.
|
||||
// Copyright (c) 2013 Antony Polukhin.
|
||||
// Copyright (c) 2013-2018 Antony Polukhin.
|
||||
//
|
||||
// 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/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/variant.hpp"
|
||||
|
||||
#include <vector>
|
||||
@@ -24,13 +24,13 @@ void run1()
|
||||
std::vector<int> vec;
|
||||
t_var v0(23), v1(&vec);
|
||||
|
||||
BOOST_REQUIRE(v0.which() == 0);
|
||||
BOOST_REQUIRE(v1.which() == 1);
|
||||
BOOST_TEST(v0.which() == 0);
|
||||
BOOST_TEST(v1.which() == 1);
|
||||
|
||||
swap(v0, v1);
|
||||
|
||||
BOOST_CHECK(v0.which() == 1);
|
||||
BOOST_CHECK(v1.which() == 0);
|
||||
BOOST_TEST(v0.which() == 1);
|
||||
BOOST_TEST(v1.which() == 0);
|
||||
}
|
||||
|
||||
void run2()
|
||||
@@ -43,18 +43,18 @@ void run2()
|
||||
std::vector<double> vec2;
|
||||
t_var v0(vec1), v1(vec2);
|
||||
|
||||
BOOST_REQUIRE(v0.which() == 0);
|
||||
BOOST_REQUIRE(v1.which() == 1);
|
||||
BOOST_TEST(v0.which() == 0);
|
||||
BOOST_TEST(v1.which() == 1);
|
||||
|
||||
swap(v0, v1);
|
||||
|
||||
BOOST_CHECK(v0.which() == 1);
|
||||
BOOST_CHECK(v1.which() == 0);
|
||||
BOOST_TEST(v0.which() == 1);
|
||||
BOOST_TEST(v1.which() == 0);
|
||||
|
||||
v0.swap(v1);
|
||||
|
||||
BOOST_CHECK(v0.which() == 0);
|
||||
BOOST_CHECK(v1.which() == 1);
|
||||
BOOST_TEST(v0.which() == 0);
|
||||
BOOST_TEST(v1.which() == 1);
|
||||
}
|
||||
|
||||
void run3()
|
||||
@@ -65,26 +65,26 @@ void run3()
|
||||
|
||||
t_var v0(1), v1(2.0);
|
||||
|
||||
BOOST_REQUIRE(v0.which() == 0);
|
||||
BOOST_REQUIRE(v1.which() == 1);
|
||||
BOOST_TEST(v0.which() == 0);
|
||||
BOOST_TEST(v1.which() == 1);
|
||||
|
||||
swap(v0, v1);
|
||||
|
||||
BOOST_CHECK(v0.which() == 1);
|
||||
BOOST_CHECK(v1.which() == 0);
|
||||
BOOST_TEST(v0.which() == 1);
|
||||
BOOST_TEST(v1.which() == 0);
|
||||
|
||||
v0.swap(v1);
|
||||
|
||||
BOOST_CHECK(v0.which() == 0);
|
||||
BOOST_CHECK(v1.which() == 1);
|
||||
BOOST_TEST(v0.which() == 0);
|
||||
BOOST_TEST(v1.which() == 1);
|
||||
}
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
run1();
|
||||
run2();
|
||||
run3();
|
||||
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
+13
-13
@@ -13,7 +13,7 @@
|
||||
#include "boost/variant/variant.hpp"
|
||||
#include "boost/variant/apply_visitor.hpp"
|
||||
#include "boost/variant/static_visitor.hpp"
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
|
||||
#include "boost/mpl/bool.hpp"
|
||||
#include "boost/mpl/and.hpp"
|
||||
@@ -70,14 +70,14 @@ inline void unary_test(Variant& var, Checker* = 0)
|
||||
|
||||
// standard tests
|
||||
|
||||
BOOST_CHECK( boost::apply_visitor(checker, var) );
|
||||
BOOST_CHECK( boost::apply_visitor(const_checker, var) );
|
||||
BOOST_CHECK( boost::apply_visitor(Checker(), var) );
|
||||
BOOST_TEST( boost::apply_visitor(checker, var) );
|
||||
BOOST_TEST( boost::apply_visitor(const_checker, var) );
|
||||
BOOST_TEST( boost::apply_visitor(Checker(), var) );
|
||||
|
||||
// delayed tests
|
||||
|
||||
BOOST_CHECK( boost::apply_visitor(checker)(var) );
|
||||
BOOST_CHECK( boost::apply_visitor(const_checker)(var) );
|
||||
BOOST_TEST( boost::apply_visitor(checker)(var) );
|
||||
BOOST_TEST( boost::apply_visitor(const_checker)(var) );
|
||||
}
|
||||
|
||||
template <typename Checker, typename Variant1, typename Variant2>
|
||||
@@ -88,17 +88,17 @@ inline void binary_test(Variant1& var1, Variant2& var2, Checker* = 0)
|
||||
|
||||
// standard tests
|
||||
|
||||
BOOST_CHECK( boost::apply_visitor(checker, var1, var2) );
|
||||
BOOST_CHECK( boost::apply_visitor(const_checker, var1, var2) );
|
||||
BOOST_CHECK( boost::apply_visitor(Checker(), var1, var2) );
|
||||
BOOST_TEST( boost::apply_visitor(checker, var1, var2) );
|
||||
BOOST_TEST( boost::apply_visitor(const_checker, var1, var2) );
|
||||
BOOST_TEST( boost::apply_visitor(Checker(), var1, var2) );
|
||||
|
||||
// delayed tests
|
||||
|
||||
BOOST_CHECK( boost::apply_visitor(checker)(var1, var2) );
|
||||
BOOST_CHECK( boost::apply_visitor(const_checker)(var1, var2) );
|
||||
BOOST_TEST( boost::apply_visitor(checker)(var1, var2) );
|
||||
BOOST_TEST( boost::apply_visitor(const_checker)(var1, var2) );
|
||||
}
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
typedef boost::variant<udt1,udt2> var_t;
|
||||
udt1 u1;
|
||||
@@ -139,5 +139,5 @@ int test_main(int , char* [])
|
||||
binary_test< check21_t >(var2,var1);
|
||||
binary_test< check21_const_t >(cvar2,cvar1);
|
||||
|
||||
return boost::exit_success;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user