mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 18:17:59 +02:00
seperate get/set
This commit is contained in:
@ -95,6 +95,12 @@ template <typename T> T minusOneIfDifferent(const std::vector<T> &container) {
|
||||
return static_cast<T>(-1);
|
||||
}
|
||||
|
||||
inline int minusOneIfDifferent(const std::vector<bool> &container) {
|
||||
if (allEqual(container))
|
||||
return static_cast<int>(container.front());
|
||||
return -1;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::vector<T>
|
||||
minusOneIfDifferent(const std::vector<std::vector<T>> &container) {
|
||||
|
@ -112,3 +112,14 @@ TEST_CASE("Compare a vector containing two vectors", "[support]") {
|
||||
CHECK(minusOneIfDifferent(c) == std::vector<int>{-1});
|
||||
CHECK(minusOneIfDifferent(d) == d[2]);
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("vector of bool", "[support]"){
|
||||
std::vector<bool> a{true, true, true};
|
||||
std::vector<bool> b{false, false, false};
|
||||
std::vector<bool> c{true, false, true};
|
||||
|
||||
CHECK(minusOneIfDifferent(a) == 1);
|
||||
CHECK(minusOneIfDifferent(b) == 0);
|
||||
CHECK(minusOneIfDifferent(c) == -1);
|
||||
}
|
Reference in New Issue
Block a user