summaryrefslogtreecommitdiff
path: root/libs/variant/test/recursive_variant_test.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2015-04-08 03:09:47 +0000
committer <>2015-05-05 14:37:32 +0000
commitf2541bb90af059680aa7036f315f052175999355 (patch)
treea5b214744b256f07e1dc2bd7273035a7808c659f /libs/variant/test/recursive_variant_test.cpp
parented232fdd34968697a68783b3195b1da4226915b5 (diff)
downloadboost-tarball-master.tar.gz
Imported from /home/lorry/working-area/delta_boost-tarball/boost_1_58_0.tar.bz2.HEADboost_1_58_0master
Diffstat (limited to 'libs/variant/test/recursive_variant_test.cpp')
-rw-r--r--libs/variant/test/recursive_variant_test.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/libs/variant/test/recursive_variant_test.cpp b/libs/variant/test/recursive_variant_test.cpp
index 8b6434801..fc9eaf2a5 100644
--- a/libs/variant/test/recursive_variant_test.cpp
+++ b/libs/variant/test/recursive_variant_test.cpp
@@ -129,6 +129,43 @@ void test_recursive_variant()
std::cout << "result1: " << result1 << '\n';
BOOST_CHECK(result1 == "( 3 5 ( 3 5 ) 7 ) ");
+ std::vector<var1_t> vec1_copy = vec1;
+ vec1_copy.erase(vec1_copy.begin() + 2);
+ vec1_copy.insert(vec1_copy.begin() + 2, vec1_copy);
+ var1 = vec1_copy;
+ result1 = printer()(var1);
+ std::cout << "result1+: " << result1 << '\n';
+ BOOST_CHECK(result1 == "( 3 5 ( 3 5 7 ) 7 ) ");
+
+ // Uses move construction on compilers with rvalue references support
+ result1 = printer()(
+ var1_t(
+ std::vector<var1_t>(vec1_copy)
+ )
+ );
+ std::cout << "result1++: " << result1 << '\n';
+ BOOST_CHECK(result1 == "( 3 5 ( 3 5 7 ) 7 ) ");
+
+
+ var1_t vec1_another_copy(vec1_copy);
+ vec1_copy[2].swap(vec1_another_copy);
+ result1 = printer()(
+ var1_t(vec1_copy)
+ );
+ std::cout << "result1+++1: " << result1 << '\n';
+ BOOST_CHECK(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 ) ");
+
+ 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 ) ");
+
typedef boost::make_recursive_variant<
boost::variant<int, double>
, std::vector<boost::recursive_variant_>
@@ -231,6 +268,36 @@ void test_recursive_variant_over()
std::cout << "result1: " << result1 << '\n';
BOOST_CHECK(result1 == "( 3 5 ( 3 5 ) 7 ) ");
+ std::vector<var1_t> vec1_copy = vec1;
+ vec1_copy.erase(vec1_copy.begin() + 2);
+ vec1_copy.insert(vec1_copy.begin() + 2, vec1_copy);
+ var1 = vec1_copy;
+ result1 = printer()(var1);
+ std::cout << "result1+: " << result1 << '\n';
+ BOOST_CHECK(result1 == "( 3 5 ( 3 5 7 ) 7 ) ");
+
+ // Uses move construction on compilers with rvalue references support
+ result1 = printer()(
+ var1_t(
+ std::vector<var1_t>(vec1_copy)
+ )
+ );
+ std::cout << "result1++: " << result1 << '\n';
+ BOOST_CHECK(result1 == "( 3 5 ( 3 5 7 ) 7 ) ");
+
+
+ var1_t vec1_another_copy(vec1_copy);
+ vec1_copy[2].swap(vec1_another_copy);
+ result1 = printer()(
+ var1_t(vec1_copy)
+ );
+ std::cout << "result1+++1: " << result1 << '\n';
+ BOOST_CHECK(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 ) ");
+
typedef boost::make_recursive_variant_over<
boost::mpl::vector<
boost::make_variant_over<boost::mpl::vector<int, double> >::type