Analysis Software
Documentation for
sPHENIX
simulation software
Home page
Related Pages
Modules
Namespaces
Classes
Files
Examples
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
ZipTests.cpp
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file ZipTests.cpp
1
// This file is part of the Acts project.
2
//
3
// Copyright (C) 2023 CERN for the benefit of the Acts project
4
//
5
// This Source Code Form is subject to the terms of the Mozilla Public
6
// License, v. 2.0. If a copy of the MPL was not distributed with this
7
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
9
#include <boost/test/unit_test.hpp>
10
11
#include <
Acts/Utilities/Zip.hpp
>
12
13
#include <array>
14
#include <string>
15
#include <vector>
16
17
const
std::vector<int>
vec
= {1, 2, 3, 4};
18
const
std::array<double, 4>
arr
= {2.0, 4.0, 6.0, 8.0};
19
const
std::string
str
=
"abcd"
;
20
21
BOOST_AUTO_TEST_CASE
(test_access) {
22
int
i
= 0;
23
for
(
const
auto
&[
a
,
b
,
c
] :
Acts::zip
(vec, arr,
str
)) {
24
BOOST_CHECK(
a
== vec[i]);
25
BOOST_CHECK(
b
== arr[i]);
26
BOOST_CHECK(
c
==
str
[i]);
27
++
i
;
28
}
29
}
30
31
BOOST_AUTO_TEST_CASE
(test_mutation) {
32
std::vector<int>
vec2
=
vec
;
33
std::array<double, 4> arr2 =
arr
;
34
std::string
str2 =
str
;
35
36
for
(
auto
[
a
,
b
,
c
] :
Acts::zip
(vec2, arr2, str2)) {
37
a
*= 2;
38
b
*= 2;
39
c
=
'e'
;
40
}
41
42
for
(
int
i
= 0;
i
< 4; ++
i
) {
43
BOOST_CHECK(vec2[
i
] == 2 * vec[
i
]);
44
BOOST_CHECK(arr2[i] == 2 * arr[i]);
45
}
46
47
BOOST_CHECK(str2 ==
"eeee"
);
48
}
acts
blob
sPHENIX
Tests
UnitTests
Core
Utilities
ZipTests.cpp
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:17:45
using
1.8.2 with
sPHENIX GitHub integration