From 51fbc208d9d69b56cbe6f5dc77c09f4c579add7e Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 10 Jan 2025 03:49:09 +0200 Subject: [PATCH] Add array_copy_test.cpp --- test/Jamfile.v2 | 1 + test/array_copy_test.cpp | 65 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 test/array_copy_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 79d76ce..a2add77 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -31,6 +31,7 @@ run array_hash.cpp run array_typedef_test.cpp ; run array_elems_test.cpp ; run array_init_test.cpp ; +run array_copy_test.cpp ; # diff --git a/test/array_copy_test.cpp b/test/array_copy_test.cpp new file mode 100644 index 0000000..bcb29a4 --- /dev/null +++ b/test/array_copy_test.cpp @@ -0,0 +1,65 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include + +template void test1() +{ + boost::array a1 = {{}}; + boost::array a2 = a1; + + BOOST_TEST_ALL_EQ( a1.begin(), a1.end(), a2.begin(), a2.end() ); +} + +template void test2() +{ + boost::array a1 = {{}}; + + boost::array a2; + a2 = a1; + + BOOST_TEST_ALL_EQ( a1.begin(), a1.end(), a2.begin(), a2.end() ); +} + +template void test3() +{ + boost::array a1 = {{ 1, 2, 3, 4 }}; + boost::array a2 = a1; + + BOOST_TEST_ALL_EQ( a1.begin(), a1.end(), a2.begin(), a2.end() ); +} + +template void test4() +{ + boost::array a1 = { 1, 2, 3, 4 }; + + boost::array a2; + a2 = a1; + + BOOST_TEST_ALL_EQ( a1.begin(), a1.end(), a2.begin(), a2.end() ); +} + +int main() +{ + // test1(); + test1(); + test1(); + + // test1(); + test1(); + test1(); + + // test2(); + test2(); + test2(); + + test3(); + test3(); + + test4(); + + return boost::report_errors(); +}