File indexing completed on 2025-01-18 09:13:00
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/unit_test.hpp>
0010
0011 #include <Acts/Utilities/Zip.hpp>
0012
0013 #include <array>
0014 #include <string>
0015 #include <vector>
0016
0017 const std::vector<int> vec = {1, 2, 3, 4};
0018 const std::array<double, 4> arr = {2.0, 4.0, 6.0, 8.0};
0019 const std::string str = "abcd";
0020
0021 BOOST_AUTO_TEST_CASE(test_access) {
0022 int i = 0;
0023 for (const auto &[a, b, c] : Acts::zip(vec, arr, str)) {
0024 BOOST_CHECK_EQUAL(a, vec[i]);
0025 BOOST_CHECK_EQUAL(b, arr[i]);
0026 BOOST_CHECK_EQUAL(c, str[i]);
0027 ++i;
0028 }
0029 }
0030
0031 BOOST_AUTO_TEST_CASE(test_mutation) {
0032 std::vector<int> vec2 = vec;
0033 std::array<double, 4> arr2 = arr;
0034 std::string str2 = str;
0035
0036 for (auto [a, b, c] : Acts::zip(vec2, arr2, str2)) {
0037 a *= 2;
0038 b *= 2;
0039 c = 'e';
0040 }
0041
0042 for (int i = 0; i < 4; ++i) {
0043 BOOST_CHECK_EQUAL(vec2[i], 2 * vec[i]);
0044 BOOST_CHECK_EQUAL(arr2[i], 2 * arr[i]);
0045 }
0046
0047 BOOST_CHECK_EQUAL(str2, "eeee");
0048 }