mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-04 00:50:42 +02:00
renamed FixedCap.. to StaticVector
This commit is contained in:
parent
e6deccc2c6
commit
0dd5a099c8
@ -2164,12 +2164,12 @@ void Module::setReceiverDbitList(const std::vector<int> &list) {
|
||||
"Dbit list value must be between 0 and 63\n");
|
||||
}
|
||||
}
|
||||
sls::FixedCapacityContainer<int, MAX_RX_DBIT> arg = list;
|
||||
sls::StaticVector<int, MAX_RX_DBIT> arg = list;
|
||||
sendToReceiver(F_SET_RECEIVER_DBIT_LIST, arg, nullptr);
|
||||
}
|
||||
|
||||
std::vector<int> Module::getReceiverDbitList() const {
|
||||
return sendToReceiver<sls::FixedCapacityContainer<int, MAX_RX_DBIT>>(
|
||||
return sendToReceiver<sls::StaticVector<int, MAX_RX_DBIT>>(
|
||||
F_GET_RECEIVER_DBIT_LIST);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "ClientSocket.h"
|
||||
#include "FixedCapacityContainer.h"
|
||||
#include "SharedMemory.h"
|
||||
#include "StaticVector.h"
|
||||
#include "logger.h"
|
||||
#include "network_utils.h"
|
||||
#include "sls_detector_defs.h"
|
||||
@ -51,7 +51,7 @@ struct sharedSlsDetector {
|
||||
char settingsDir[MAX_STR_LENGTH];
|
||||
|
||||
/** list of the energies at which the detector has been trimmed */
|
||||
sls::FixedCapacityContainer<int, MAX_TRIMEN> trimEnergies;
|
||||
sls::StaticVector<int, MAX_TRIMEN> trimEnergies;
|
||||
|
||||
/** number of channels per chip in one direction */
|
||||
slsDetectorDefs::xy nChan;
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "ClientInterface.h"
|
||||
#include "FixedCapacityContainer.h"
|
||||
#include "ServerSocket.h"
|
||||
#include "StaticVector.h"
|
||||
#include "ToString.h"
|
||||
#include "sls_detector_exceptions.h"
|
||||
#include "string_utils.h"
|
||||
@ -335,39 +335,39 @@ int ClientInterface::get_version(Interface &socket) {
|
||||
int ClientInterface::setup_receiver(Interface &socket) {
|
||||
auto arg = socket.Receive<rxParameters>();
|
||||
LOG(logDEBUG) << "detType:" << arg.detType << std::endl
|
||||
<< "multiSize.x:" << arg.multiSize.x << std::endl
|
||||
<< "multiSize.y:" << arg.multiSize.y << std::endl
|
||||
<< "detId:" << arg.detId << std::endl
|
||||
<< "hostname:" << arg.hostname << std::endl
|
||||
<< "udpInterfaces:" << arg.udpInterfaces << std::endl
|
||||
<< "udp_dstport:" << arg.udp_dstport << std::endl
|
||||
<< "udp_dstip:" << sls::IpAddr(arg.udp_dstip) << std::endl
|
||||
<< "udp_dstmac:" << sls::MacAddr(arg.udp_dstmac) << std::endl
|
||||
<< "udp_dstport2:" << arg.udp_dstport2 << std::endl
|
||||
<< "udp_dstip2:" << sls::IpAddr(arg.udp_dstip2) << std::endl
|
||||
<< "udp_dstmac2:" << sls::MacAddr(arg.udp_dstmac2)
|
||||
<< std::endl
|
||||
<< "frames:" << arg.frames << std::endl
|
||||
<< "triggers:" << arg.triggers << std::endl
|
||||
<< "bursts:" << arg.bursts << std::endl
|
||||
<< "analogSamples:" << arg.analogSamples << std::endl
|
||||
<< "digitalSamples:" << arg.digitalSamples << std::endl
|
||||
<< "expTimeNs:" << arg.expTimeNs << std::endl
|
||||
<< "periodNs:" << arg.periodNs << std::endl
|
||||
<< "subExpTimeNs:" << arg.subExpTimeNs << std::endl
|
||||
<< "subDeadTimeNs:" << arg.subDeadTimeNs << std::endl
|
||||
<< "activate:" << arg.activate << std::endl
|
||||
<< "quad:" << arg.quad << std::endl
|
||||
<< "dynamicRange:" << arg.dynamicRange << std::endl
|
||||
<< "timMode:" << arg.timMode << std::endl
|
||||
<< "tenGiga:" << arg.tenGiga << std::endl
|
||||
<< "roMode:" << arg.roMode << std::endl
|
||||
<< "adcMask:" << arg.adcMask << std::endl
|
||||
<< "adc10gMask:" << arg.adc10gMask << std::endl
|
||||
<< "roi.xmin:" << arg.roi.xmin << std::endl
|
||||
<< "roi.xmax:" << arg.roi.xmax << std::endl
|
||||
<< "countermask:" << arg.countermask << std::endl
|
||||
<< "burstType:" << arg.burstType << std::endl;
|
||||
<< "multiSize.x:" << arg.multiSize.x << std::endl
|
||||
<< "multiSize.y:" << arg.multiSize.y << std::endl
|
||||
<< "detId:" << arg.detId << std::endl
|
||||
<< "hostname:" << arg.hostname << std::endl
|
||||
<< "udpInterfaces:" << arg.udpInterfaces << std::endl
|
||||
<< "udp_dstport:" << arg.udp_dstport << std::endl
|
||||
<< "udp_dstip:" << sls::IpAddr(arg.udp_dstip) << std::endl
|
||||
<< "udp_dstmac:" << sls::MacAddr(arg.udp_dstmac) << std::endl
|
||||
<< "udp_dstport2:" << arg.udp_dstport2 << std::endl
|
||||
<< "udp_dstip2:" << sls::IpAddr(arg.udp_dstip2) << std::endl
|
||||
<< "udp_dstmac2:" << sls::MacAddr(arg.udp_dstmac2)
|
||||
<< std::endl
|
||||
<< "frames:" << arg.frames << std::endl
|
||||
<< "triggers:" << arg.triggers << std::endl
|
||||
<< "bursts:" << arg.bursts << std::endl
|
||||
<< "analogSamples:" << arg.analogSamples << std::endl
|
||||
<< "digitalSamples:" << arg.digitalSamples << std::endl
|
||||
<< "expTimeNs:" << arg.expTimeNs << std::endl
|
||||
<< "periodNs:" << arg.periodNs << std::endl
|
||||
<< "subExpTimeNs:" << arg.subExpTimeNs << std::endl
|
||||
<< "subDeadTimeNs:" << arg.subDeadTimeNs << std::endl
|
||||
<< "activate:" << arg.activate << std::endl
|
||||
<< "quad:" << arg.quad << std::endl
|
||||
<< "dynamicRange:" << arg.dynamicRange << std::endl
|
||||
<< "timMode:" << arg.timMode << std::endl
|
||||
<< "tenGiga:" << arg.tenGiga << std::endl
|
||||
<< "roMode:" << arg.roMode << std::endl
|
||||
<< "adcMask:" << arg.adcMask << std::endl
|
||||
<< "adc10gMask:" << arg.adc10gMask << std::endl
|
||||
<< "roi.xmin:" << arg.roi.xmin << std::endl
|
||||
<< "roi.xmax:" << arg.roi.xmax << std::endl
|
||||
<< "countermask:" << arg.countermask << std::endl
|
||||
<< "burstType:" << arg.burstType << std::endl;
|
||||
|
||||
// if object exists, verify unlocked and idle, else only verify lock
|
||||
// (connecting first time)
|
||||
@ -388,15 +388,15 @@ int ClientInterface::setup_receiver(Interface &socket) {
|
||||
// update retvals only if detmac is not the same as in detector
|
||||
sls::MacAddr retvals[2];
|
||||
if (arg.udp_dstip != 0) {
|
||||
sls::MacAddr r = setUdpIp(sls::IpAddr(arg.udp_dstip));
|
||||
sls::MacAddr detMac{arg.udp_dstmac};
|
||||
sls::MacAddr r = setUdpIp(sls::IpAddr(arg.udp_dstip));
|
||||
sls::MacAddr detMac{arg.udp_dstmac};
|
||||
if (detMac != r) {
|
||||
retvals[0] = r;
|
||||
}
|
||||
}
|
||||
if (arg.udp_dstip2 != 0) {
|
||||
sls::MacAddr r = setUdpIp2(sls::IpAddr(arg.udp_dstip2));
|
||||
sls::MacAddr detMac{arg.udp_dstmac2};
|
||||
sls::MacAddr r = setUdpIp2(sls::IpAddr(arg.udp_dstip2));
|
||||
sls::MacAddr detMac{arg.udp_dstmac2};
|
||||
if (detMac != r) {
|
||||
retvals[1] = r;
|
||||
}
|
||||
@ -1399,7 +1399,7 @@ int ClientInterface::set_adc_mask(Interface &socket) {
|
||||
}
|
||||
|
||||
int ClientInterface::set_dbit_list(Interface &socket) {
|
||||
sls::FixedCapacityContainer<int, MAX_RX_DBIT> args;
|
||||
sls::StaticVector<int, MAX_RX_DBIT> args;
|
||||
socket.Receive(args);
|
||||
if (myDetectorType != CHIPTESTBOARD)
|
||||
functionNotImplemented();
|
||||
@ -1416,7 +1416,7 @@ int ClientInterface::set_dbit_list(Interface &socket) {
|
||||
int ClientInterface::get_dbit_list(Interface &socket) {
|
||||
if (myDetectorType != CHIPTESTBOARD)
|
||||
functionNotImplemented();
|
||||
sls::FixedCapacityContainer<int, MAX_RX_DBIT> retval;
|
||||
sls::StaticVector<int, MAX_RX_DBIT> retval;
|
||||
retval = impl()->getDbitList();
|
||||
LOG(logDEBUG1) << "Dbit list size retval:" << retval.size();
|
||||
return socket.sendResult(retval);
|
||||
|
@ -28,7 +28,7 @@ set(PUBLICHEADERS
|
||||
include/ServerSocket.h
|
||||
include/ServerInterface.h
|
||||
include/network_utils.h
|
||||
include/FixedCapacityContainer.h
|
||||
include/StaticVector.h
|
||||
include/ToString.h
|
||||
include/TimeHelper.h
|
||||
include/TypeTraits.h
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <vector>
|
||||
|
||||
namespace sls {
|
||||
template <typename T, size_t Capacity> class FixedCapacityContainer {
|
||||
template <typename T, size_t Capacity> class StaticVector {
|
||||
|
||||
public:
|
||||
using size_type = typename std::array<T, Capacity>::size_type;
|
||||
@ -20,10 +20,9 @@ template <typename T, size_t Capacity> class FixedCapacityContainer {
|
||||
std::array<T, Capacity> data_;
|
||||
|
||||
public:
|
||||
FixedCapacityContainer() = default;
|
||||
StaticVector() = default;
|
||||
|
||||
explicit FixedCapacityContainer(std::initializer_list<T> l)
|
||||
: current_size(l.size()) {
|
||||
explicit StaticVector(std::initializer_list<T> l) : current_size(l.size()) {
|
||||
size_check(l.size());
|
||||
std::copy(l.begin(), l.end(), data_.begin());
|
||||
}
|
||||
@ -33,15 +32,14 @@ template <typename T, size_t Capacity> class FixedCapacityContainer {
|
||||
typename = typename std::enable_if<
|
||||
is_container<V>::value &&
|
||||
std::is_same<T, typename V::value_type>::value>::type>
|
||||
FixedCapacityContainer(const V &v) : current_size(v.size()) {
|
||||
StaticVector(const V &v) : current_size(v.size()) {
|
||||
size_check(v.size());
|
||||
std::copy(v.begin(), v.end(), data_.begin());
|
||||
}
|
||||
|
||||
/** copy assignment from another container */
|
||||
template <typename V>
|
||||
typename std::enable_if<is_container<V>::value,
|
||||
FixedCapacityContainer &>::type
|
||||
typename std::enable_if<is_container<V>::value, StaticVector &>::type
|
||||
operator=(const V &other) {
|
||||
size_check(other.size());
|
||||
std::copy(other.begin(), other.end(), data_.begin());
|
||||
@ -49,7 +47,7 @@ template <typename T, size_t Capacity> class FixedCapacityContainer {
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** Compare FixedCapacityContainer with any other container*/
|
||||
/** Compare StaticVector with any other container*/
|
||||
// template <typename V>
|
||||
// typename std::enable_if<is_container<V>::value, bool>::type
|
||||
// operator==(const V &other) const noexcept {
|
||||
@ -143,66 +141,66 @@ template <typename T, size_t Capacity> class FixedCapacityContainer {
|
||||
} __attribute__((packed));
|
||||
|
||||
template <typename T, size_t CapacityLhs, typename V, size_t CapacityRhs>
|
||||
bool operator==(const FixedCapacityContainer<T, CapacityLhs> &lhs,
|
||||
const FixedCapacityContainer<V, CapacityRhs> &rhs) {
|
||||
bool operator==(const StaticVector<T, CapacityLhs> &lhs,
|
||||
const StaticVector<V, CapacityRhs> &rhs) {
|
||||
return lhs.is_equal(rhs);
|
||||
}
|
||||
|
||||
template <typename T, size_t CapacityLhs, typename V, size_t CapacityRhs>
|
||||
bool operator!=(const FixedCapacityContainer<T, CapacityLhs> &lhs,
|
||||
const FixedCapacityContainer<V, CapacityRhs> &rhs) {
|
||||
bool operator!=(const StaticVector<T, CapacityLhs> &lhs,
|
||||
const StaticVector<V, CapacityRhs> &rhs) {
|
||||
return !(lhs.is_equal(rhs));
|
||||
}
|
||||
|
||||
// Compare with array
|
||||
|
||||
template <typename T, size_t CapacityLhs, typename V, size_t Size>
|
||||
bool operator==(const FixedCapacityContainer<T, CapacityLhs> &lhs,
|
||||
bool operator==(const StaticVector<T, CapacityLhs> &lhs,
|
||||
const std::array<V, Size> &rhs) {
|
||||
return lhs.is_equal(rhs);
|
||||
}
|
||||
|
||||
template <typename T, size_t Size, typename V, size_t CapacityRhs>
|
||||
bool operator==(const std::array<T, Size> &lhs,
|
||||
const FixedCapacityContainer<V, CapacityRhs> &rhs) {
|
||||
const StaticVector<V, CapacityRhs> &rhs) {
|
||||
return rhs.is_equal(lhs);
|
||||
}
|
||||
|
||||
template <typename T, size_t CapacityLhs, typename V, size_t Size>
|
||||
bool operator!=(const FixedCapacityContainer<T, CapacityLhs> &lhs,
|
||||
bool operator!=(const StaticVector<T, CapacityLhs> &lhs,
|
||||
const std::array<V, Size> &rhs) {
|
||||
return !lhs.is_equal(rhs);
|
||||
}
|
||||
|
||||
template <typename T, size_t Size, typename V, size_t CapacityRhs>
|
||||
bool operator!=(const std::array<T, Size> &lhs,
|
||||
const FixedCapacityContainer<V, CapacityRhs> &rhs) {
|
||||
const StaticVector<V, CapacityRhs> &rhs) {
|
||||
return !rhs.is_equal(lhs);
|
||||
}
|
||||
|
||||
// Compare with vector
|
||||
|
||||
template <typename T, size_t CapacityLhs, typename V>
|
||||
bool operator==(const FixedCapacityContainer<T, CapacityLhs> &lhs,
|
||||
bool operator==(const StaticVector<T, CapacityLhs> &lhs,
|
||||
const std::vector<V> &rhs) {
|
||||
return lhs.is_equal(rhs);
|
||||
}
|
||||
|
||||
template <typename T, typename V, size_t CapacityRhs>
|
||||
bool operator==(const std::vector<T> &lhs,
|
||||
const FixedCapacityContainer<V, CapacityRhs> &rhs) {
|
||||
const StaticVector<V, CapacityRhs> &rhs) {
|
||||
return rhs.is_equal(lhs);
|
||||
}
|
||||
|
||||
template <typename T, size_t CapacityLhs, typename V>
|
||||
bool operator!=(const FixedCapacityContainer<T, CapacityLhs> &lhs,
|
||||
bool operator!=(const StaticVector<T, CapacityLhs> &lhs,
|
||||
const std::vector<V> &rhs) {
|
||||
return !lhs.is_equal(rhs);
|
||||
}
|
||||
|
||||
template <typename T, typename V, size_t CapacityRhs>
|
||||
bool operator!=(const std::vector<T> &lhs,
|
||||
const FixedCapacityContainer<V, CapacityRhs> &rhs) {
|
||||
const StaticVector<V, CapacityRhs> &rhs) {
|
||||
return !rhs.is_equal(lhs);
|
||||
}
|
||||
|
||||
@ -210,7 +208,7 @@ bool operator!=(const std::vector<T> &lhs,
|
||||
// template <typename T, size_t Capacity, typename C>
|
||||
// typename std::enable_if<is_container<C>::value, bool>::type operator==(
|
||||
// const C &container,
|
||||
// const FixedCapacityContainer<T, Capacity> &fixed_container) noexcept {
|
||||
// const StaticVector<T, Capacity> &fixed_container) noexcept {
|
||||
// return fixed_container.operator==(container);
|
||||
// }
|
||||
|
||||
@ -218,7 +216,7 @@ bool operator!=(const std::vector<T> &lhs,
|
||||
// template <typename T, size_t Capacity, typename C>
|
||||
// typename std::enable_if<is_container<C>::value, bool>::type operator!=(
|
||||
// const C &container,
|
||||
// const FixedCapacityContainer<T, Capacity> &fixed_container) noexcept {
|
||||
// const StaticVector<T, Capacity> &fixed_container) noexcept {
|
||||
// return fixed_container.operator!=(container);
|
||||
// }
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "FixedCapacityContainer.h"
|
||||
#include "StaticVector.h"
|
||||
#include "TimeHelper.h"
|
||||
#include "TypeTraits.h"
|
||||
#include "sls_detector_defs.h"
|
||||
@ -42,7 +42,7 @@ std::ostream &operator<<(std::ostream &os, const slsDetectorDefs::ROI &roi);
|
||||
|
||||
template <typename T, size_t Capacity>
|
||||
std::ostream &operator<<(std::ostream &os,
|
||||
const sls::FixedCapacityContainer<T, Capacity> &c) {
|
||||
const sls::StaticVector<T, Capacity> &c) {
|
||||
return os << ToString(c);
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ target_sources(tests PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test-Timer.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test-sls_detector_defs.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test-Sockets.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test-FixedCapacityContainer.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test-StaticVector.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test-ToString.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test-TypeTraits.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test-UdpRxSocket.cpp
|
||||
|
@ -1,19 +1,19 @@
|
||||
#include "FixedCapacityContainer.h"
|
||||
#include "StaticVector.h"
|
||||
#include "TypeTraits.h"
|
||||
#include "catch.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
using sls::FixedCapacityContainer;
|
||||
using sls::StaticVector;
|
||||
|
||||
TEST_CASE("FixedCapacityContainer is a container") {
|
||||
REQUIRE(sls::is_container<FixedCapacityContainer<int, 7>>::value == true);
|
||||
TEST_CASE("StaticVector is a container") {
|
||||
REQUIRE(sls::is_container<StaticVector<int, 7>>::value == true);
|
||||
}
|
||||
|
||||
TEST_CASE("Comparing FixedCapacity containers") {
|
||||
FixedCapacityContainer<int, 5> a{0, 1, 2};
|
||||
FixedCapacityContainer<int, 5> b{0, 1, 2};
|
||||
FixedCapacityContainer<int, 5> c{0, 1, 2, 4};
|
||||
TEST_CASE("Comparing StaticVector containers") {
|
||||
StaticVector<int, 5> a{0, 1, 2};
|
||||
StaticVector<int, 5> b{0, 1, 2};
|
||||
StaticVector<int, 5> c{0, 1, 2, 4};
|
||||
|
||||
REQUIRE(a == b);
|
||||
REQUIRE_FALSE(a != b);
|
||||
@ -27,7 +27,7 @@ TEST_CASE("Comparing FixedCapacity containers") {
|
||||
TEST_CASE("Compare array and fixed capacity container") {
|
||||
std::array<int, 3> arr{1, 2, 3};
|
||||
std::array<int, 3> arr2{1, 7, 3};
|
||||
FixedCapacityContainer<int, 7> fcc{1, 2, 3};
|
||||
StaticVector<int, 7> fcc{1, 2, 3};
|
||||
REQUIRE(fcc == arr);
|
||||
REQUIRE(arr == fcc);
|
||||
REQUIRE_FALSE(fcc != arr);
|
||||
@ -39,7 +39,7 @@ TEST_CASE("Compare array and fixed capacity container") {
|
||||
TEST_CASE("Compare vector and fixed capacity container") {
|
||||
std::vector<int> vec{1, 2, 3};
|
||||
std::vector<int> vec2{10, 2, 3};
|
||||
FixedCapacityContainer<int, 7> fcc{1, 2, 3};
|
||||
StaticVector<int, 7> fcc{1, 2, 3};
|
||||
REQUIRE(fcc == vec);
|
||||
REQUIRE(vec == fcc);
|
||||
REQUIRE_FALSE(fcc != vec);
|
||||
@ -50,51 +50,51 @@ TEST_CASE("Compare vector and fixed capacity container") {
|
||||
|
||||
TEST_CASE("Construct from vector") {
|
||||
std::vector<int> vec{1, 2, 3};
|
||||
FixedCapacityContainer<int, 5> fcc{vec};
|
||||
StaticVector<int, 5> fcc{vec};
|
||||
REQUIRE(fcc == vec);
|
||||
}
|
||||
|
||||
TEST_CASE("Copy construct from vector") {
|
||||
std::vector<int> vec{1, 2, 3};
|
||||
FixedCapacityContainer<int, 5> fcc = vec;
|
||||
StaticVector<int, 5> fcc = vec;
|
||||
REQUIRE(fcc == vec);
|
||||
}
|
||||
|
||||
TEST_CASE("Copy assignment from vector") {
|
||||
std::vector<int> vec{1, 2, 3};
|
||||
FixedCapacityContainer<int, 5> fcc;
|
||||
StaticVector<int, 5> fcc;
|
||||
fcc = vec;
|
||||
REQUIRE(fcc == vec);
|
||||
}
|
||||
|
||||
TEST_CASE("Construct from array") {
|
||||
std::array<int, 3> arr{1, 2, 3};
|
||||
FixedCapacityContainer<int, 5> fcc{arr};
|
||||
StaticVector<int, 5> fcc{arr};
|
||||
REQUIRE(fcc == arr);
|
||||
}
|
||||
|
||||
TEST_CASE("Copy assign from array") {
|
||||
std::array<int, 3> arr{1, 2, 3};
|
||||
FixedCapacityContainer<int, 5> fcc;
|
||||
StaticVector<int, 5> fcc;
|
||||
fcc = arr;
|
||||
REQUIRE(fcc == arr);
|
||||
}
|
||||
|
||||
TEST_CASE("Copy construct from array") {
|
||||
std::array<int, 3> arr{1, 2, 3};
|
||||
FixedCapacityContainer<int, 5> fcc = arr;
|
||||
StaticVector<int, 5> fcc = arr;
|
||||
REQUIRE(fcc == arr);
|
||||
}
|
||||
|
||||
TEST_CASE("Free function and method gives the same iterators") {
|
||||
FixedCapacityContainer<int, 3> fcc{1, 2, 3};
|
||||
StaticVector<int, 3> fcc{1, 2, 3};
|
||||
REQUIRE(std::begin(fcc) == fcc.begin());
|
||||
}
|
||||
SCENARIO("FixedCapacityContainers can be sized and resized", "[support]") {
|
||||
SCENARIO("StaticVectors can be sized and resized", "[support]") {
|
||||
|
||||
GIVEN("A default constructed container") {
|
||||
constexpr size_t n_elem = 5;
|
||||
FixedCapacityContainer<int, n_elem> vec;
|
||||
StaticVector<int, n_elem> vec;
|
||||
|
||||
REQUIRE(vec.empty());
|
||||
REQUIRE(vec.size() == 0); // NOLINT
|
||||
@ -131,8 +131,8 @@ SCENARIO("FixedCapacityContainers can be sized and resized", "[support]") {
|
||||
}
|
||||
}
|
||||
|
||||
GIVEN("A FixedCapacityContainer constructed form a std::initializer list") {
|
||||
FixedCapacityContainer<int, 10> vec{23, 52, 11};
|
||||
GIVEN("A StaticVector constructed form a std::initializer list") {
|
||||
StaticVector<int, 10> vec{23, 52, 11};
|
||||
REQUIRE(vec.size() == 3);
|
||||
REQUIRE(vec.capacity() == 10);
|
||||
REQUIRE(vec[0] == 23);
|
||||
@ -174,7 +174,7 @@ SCENARIO("FixedCapacityContainers can be sized and resized", "[support]") {
|
||||
GIVEN("An std::vector of size 3") {
|
||||
std::vector<int> standard_vector{5, 2, 1};
|
||||
WHEN("we construct a fixed capacity container from it") {
|
||||
FixedCapacityContainer<int, 5> vec(standard_vector);
|
||||
StaticVector<int, 5> vec(standard_vector);
|
||||
THEN("size and data matches") {
|
||||
REQUIRE(vec.size() == 3);
|
||||
REQUIRE(vec[0] == 5);
|
||||
@ -188,10 +188,10 @@ SCENARIO("FixedCapacityContainers can be sized and resized", "[support]") {
|
||||
}
|
||||
}
|
||||
|
||||
SCENARIO("Comparison of FixedCapacityContainers", "[support]") {
|
||||
SCENARIO("Comparison of StaticVectors", "[support]") {
|
||||
GIVEN("Two containers containers that are equal at the start") {
|
||||
FixedCapacityContainer<int, 5> a{0, 1, 2};
|
||||
FixedCapacityContainer<int, 5> b{0, 1, 2};
|
||||
StaticVector<int, 5> a{0, 1, 2};
|
||||
StaticVector<int, 5> b{0, 1, 2};
|
||||
REQUIRE(a == b);
|
||||
REQUIRE_FALSE(a != b);
|
||||
|
||||
@ -199,8 +199,8 @@ SCENARIO("Comparison of FixedCapacityContainers", "[support]") {
|
||||
a.push_back(4);
|
||||
THEN("they are not equal anymore") { REQUIRE(a != b); }
|
||||
}
|
||||
WHEN("Compared to a FixedCapacityContainer with different capacity") {
|
||||
FixedCapacityContainer<int, 8> c{0, 1, 2};
|
||||
WHEN("Compared to a StaticVector with different capacity") {
|
||||
StaticVector<int, 8> c{0, 1, 2};
|
||||
THEN("The comparison still holds") {
|
||||
REQUIRE(a == c);
|
||||
REQUIRE_FALSE(a != c);
|
||||
@ -232,7 +232,7 @@ SCENARIO("Comparison of FixedCapacityContainers", "[support]") {
|
||||
SCENARIO("Sorting, removing and other manipulation of a container",
|
||||
"[support]") {
|
||||
GIVEN("An unsorted container") {
|
||||
FixedCapacityContainer<int, 5> a{14, 12, 90, 12};
|
||||
StaticVector<int, 5> a{14, 12, 90, 12};
|
||||
WHEN("We sort it") {
|
||||
std::sort(a.begin(), a.end());
|
||||
THEN("Elements appear sorted") {
|
||||
@ -264,8 +264,8 @@ SCENARIO("Sorting, removing and other manipulation of a container",
|
||||
|
||||
SCENARIO("Assigning containers to each other", "[support]") {
|
||||
GIVEN("Two containers") {
|
||||
FixedCapacityContainer<int, 3> a{1, 2, 3};
|
||||
FixedCapacityContainer<int, 3> b{4, 5, 6};
|
||||
StaticVector<int, 3> a{1, 2, 3};
|
||||
StaticVector<int, 3> b{4, 5, 6};
|
||||
WHEN("a is assigned to b") {
|
||||
a = b;
|
||||
THEN("A deep copy is made and both containers are equal") {
|
||||
@ -278,7 +278,7 @@ SCENARIO("Assigning containers to each other", "[support]") {
|
||||
}
|
||||
}
|
||||
WHEN("A new object is create from an old one") {
|
||||
FixedCapacityContainer<int, 3> c(a);
|
||||
StaticVector<int, 3> c(a);
|
||||
THEN("A deep copy is also made") {
|
||||
REQUIRE(c == a);
|
||||
REQUIRE(&c != &a);
|
||||
@ -288,8 +288,8 @@ SCENARIO("Assigning containers to each other", "[support]") {
|
||||
REQUIRE(c[2] == 3);
|
||||
}
|
||||
}
|
||||
WHEN("We create a const FixedCapacityContainer") {
|
||||
const FixedCapacityContainer<int, 5> c(a);
|
||||
WHEN("We create a const StaticVector") {
|
||||
const StaticVector<int, 5> c(a);
|
||||
THEN("The values are still the same using const operators") {
|
||||
REQUIRE(c[0] == 1);
|
||||
REQUIRE(c[1] == 2);
|
||||
@ -302,8 +302,8 @@ SCENARIO("Assigning containers to each other", "[support]") {
|
||||
}
|
||||
|
||||
SCENARIO("Converting to vector", "[support]") {
|
||||
GIVEN("a FixedCapacityContainer") {
|
||||
FixedCapacityContainer<int, 5> a{1, 2, 3};
|
||||
GIVEN("a StaticVector") {
|
||||
StaticVector<int, 5> a{1, 2, 3};
|
||||
WHEN("Converted into a vector") {
|
||||
std::vector<int> b(a);
|
||||
THEN("Data and size matches") {
|
@ -232,15 +232,15 @@ TEST_CASE("Streaming of slsDetectorDefs::ROI") {
|
||||
REQUIRE(oss.str() == "[-10, 1]");
|
||||
}
|
||||
|
||||
TEST_CASE("sls::FixedCapacityContainer") {
|
||||
sls::FixedCapacityContainer<int, 5> vec;
|
||||
TEST_CASE("sls::StaticVector") {
|
||||
sls::StaticVector<int, 5> vec;
|
||||
vec.push_back(3);
|
||||
vec.push_back(8);
|
||||
REQUIRE(ToString(vec) == "[3, 8]");
|
||||
}
|
||||
|
||||
TEST_CASE("sls::FixedCapacityContainer stream") {
|
||||
sls::FixedCapacityContainer<int, 5> vec;
|
||||
TEST_CASE("sls::StaticVector stream") {
|
||||
sls::StaticVector<int, 5> vec;
|
||||
vec.push_back(33);
|
||||
vec.push_back(85667);
|
||||
vec.push_back(2);
|
||||
|
Loading…
x
Reference in New Issue
Block a user