From 049e98dd57d74127870466702a50b43094af6e36 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 10 Jan 2025 03:30:57 +0200 Subject: [PATCH] Add array_init_test.cpp --- test/Jamfile.v2 | 1 + test/array_init_test.cpp | 70 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 test/array_init_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 91cb6af..79d76ce 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -30,6 +30,7 @@ run array_hash.cpp run array_typedef_test.cpp ; run array_elems_test.cpp ; +run array_init_test.cpp ; # diff --git a/test/array_init_test.cpp b/test/array_init_test.cpp new file mode 100644 index 0000000..faaa7f4 --- /dev/null +++ b/test/array_init_test.cpp @@ -0,0 +1,70 @@ +// 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 a = {{}}; + + for( std::size_t i = 0; i < N; ++i ) + { + BOOST_TEST_EQ( a[i], T() ); + } +} + +template void test2() +{ + boost::array a = {}; + + for( std::size_t i = 0; i < N; ++i ) + { + BOOST_TEST_EQ( a[i], T() ); + } +} + +template void test3() +{ + boost::array a = {{ 1, 2, 3, 4 }}; + T b[ 4 ] = { 1, 2, 3, 4 }; + + BOOST_TEST_ALL_EQ( a.begin(), a.end(), b + 0, b + 4 ); +} + +template void test4() +{ + boost::array a = { 1, 2, 3, 4 }; + T b[ 4 ] = { 1, 2, 3, 4 }; + + BOOST_TEST_ALL_EQ( a.begin(), a.end(), b + 0, b + 4 ); +} + +int main() +{ + // test1(); + test1(); + test1(); + + // test1(); + test1(); + test1(); + + test2(); + test2(); + test2(); + + // test2(); + test2(); + test2(); + + test3(); + test3(); + + test4(); + test4(); + + return boost::report_errors(); +}