use clang-tidy (#59)

* use clang-tidy for Frame.cpp

* fixes for defs.cpp

* clang-tidy 6/45

* clang-tidy for core

* clang-tidy fixes: for hpp File,FileInterface,SubFile.cpp

* ci fixes

* fix build errors

* fix clang-tidy command ci

* fix clang-tidy ci

* clang-tidy for rawfile.cpp

* clang-tidy numpy helpers

* fix ci

* clang-tidy file_io

* clang-tidy file_io and core working

* zmqheader

* clagn-tidy: network_io,file_io,core

* clang-tidy working

* format

---------

Co-authored-by: Bechir <bechir.brahem420@gmail.com>
This commit is contained in:
Bechir Braham
2024-04-12 17:35:36 +02:00
committed by GitHub
parent eb7108b837
commit 9dfd388927
44 changed files with 1055 additions and 470 deletions

View File

@ -26,7 +26,7 @@ enum class endian {
*/
class DType {
// TODO! support for non native endianess?
static_assert(sizeof(long) == sizeof(int64_t), "long should be 64bits");
static_assert(sizeof(long) == sizeof(int64_t), "long should be 64bits"); // NOLINT
public:
enum TypeIndex { INT8, UINT8, INT16, UINT16, INT32, UINT32, INT64, UINT64, FLOAT, DOUBLE, ERROR };
@ -37,7 +37,7 @@ class DType {
explicit DType(std::string_view sv);
// not explicit to allow conversions form enum to DType
DType(DType::TypeIndex ti);
DType(DType::TypeIndex ti); // NOLINT
bool operator==(const DType &other) const noexcept;
bool operator!=(const DType &other) const noexcept;

View File

@ -4,7 +4,6 @@
#include <cstddef>
#include <cstdint>
#include <memory>
#include <sys/types.h>
#include <vector>
namespace aare {
@ -15,59 +14,73 @@ namespace aare {
* should be able to work with streams coming from files or network
*/
class Frame {
ssize_t m_rows;
ssize_t m_cols;
ssize_t m_bitdepth;
size_t m_rows;
size_t m_cols;
size_t m_bitdepth;
std::byte *m_data;
public:
Frame(ssize_t rows, ssize_t cols, ssize_t m_bitdepth);
Frame(std::byte *fp, ssize_t rows, ssize_t cols, ssize_t m_bitdepth);
std::byte *get(int row, int col);
Frame(size_t rows, size_t cols, size_t m_bitdepth);
Frame(std::byte *bytes, size_t rows, size_t cols, size_t m_bitdepth);
std::byte *get(size_t row, size_t col);
// TODO! can we, or even want to remove the template?
template <typename T> void set(int row, int col, T data) {
template <typename T> void set(size_t row, size_t col, T data) {
assert(sizeof(T) == m_bitdepth / 8);
if (row < 0 || row >= m_rows || col < 0 || col >= m_cols) {
if (row >= m_rows or col >= m_cols) {
throw std::out_of_range("Invalid row or column index");
}
std::memcpy(m_data + (row * m_cols + col) * (m_bitdepth / 8), &data, m_bitdepth / 8);
}
ssize_t rows() const { return m_rows; }
ssize_t cols() const { return m_cols; }
ssize_t bitdepth() const { return m_bitdepth; }
ssize_t size() const { return m_rows * m_cols * m_bitdepth / 8; }
size_t rows() const { return m_rows; }
size_t cols() const { return m_cols; }
size_t bitdepth() const { return m_bitdepth; }
size_t size() const { return m_rows * m_cols * m_bitdepth / 8; }
std::byte *data() const { return m_data; }
Frame &operator=(Frame &other) {
Frame &operator=(const Frame &other) {
if (this == &other) {
return *this;
}
m_rows = other.rows();
m_cols = other.cols();
m_bitdepth = other.bitdepth();
m_data = new std::byte[m_rows * m_cols * m_bitdepth / 8];
if (m_data == nullptr) {
throw std::bad_alloc();
}
std::memcpy(m_data, other.m_data, m_rows * m_cols * m_bitdepth / 8);
return *this;
}
// add move constructor
Frame(Frame &&other) {
Frame &operator=(Frame &&other) noexcept {
m_rows = other.rows();
m_cols = other.cols();
m_bitdepth = other.bitdepth();
m_data = other.m_data;
other.m_data = nullptr;
other.m_rows = other.m_cols = other.m_bitdepth = 0;
return *this;
}
// add move constructor
Frame(Frame &&other) noexcept
: m_rows(other.rows()), m_cols(other.cols()), m_bitdepth(other.bitdepth()), m_data(other.m_data) {
other.m_data = nullptr;
other.m_rows = other.m_cols = other.m_bitdepth = 0;
}
// copy constructor
Frame(const Frame &other) {
m_rows = other.rows();
m_cols = other.cols();
m_bitdepth = other.bitdepth();
m_data = new std::byte[m_rows * m_cols * m_bitdepth / 8];
Frame(const Frame &other)
: m_rows(other.rows()), m_cols(other.cols()), m_bitdepth(other.bitdepth()),
m_data(new std::byte[m_rows * m_cols * m_bitdepth / 8]) {
std::memcpy(m_data, other.m_data, m_rows * m_cols * m_bitdepth / 8);
}
template <typename T> NDView<T> view() {
std::vector<ssize_t> shape = {m_rows, m_cols};
std::vector<ssize_t> shape = {static_cast<ssize_t>(m_rows), static_cast<ssize_t>(m_cols)};
T *data = reinterpret_cast<T *>(m_data);
return NDView<T>(data, shape);
}

View File

@ -22,25 +22,25 @@ namespace aare {
template <typename T, ssize_t Ndim = 2> class NDArray {
public:
NDArray() : shape_(), strides_(c_strides<Ndim>(shape_)), size_(0), data_(nullptr){};
NDArray() : shape_(), strides_(c_strides<Ndim>(shape_)), data_(nullptr){};
explicit NDArray(std::array<ssize_t, Ndim> shape)
: shape_(shape), strides_(c_strides<Ndim>(shape_)),
size_(std::accumulate(shape_.begin(), shape_.end(), 1, std::multiplies<ssize_t>())), data_(new T[size_]){};
size_(std::accumulate(shape_.begin(), shape_.end(), 1, std::multiplies<>())), data_(new T[size_]){};
NDArray(std::array<ssize_t, Ndim> shape, T value) : NDArray(shape) { this->operator=(value); }
/* When constructing from a NDView we need to copy the data since
NDArray expect to own its data, and span is just a view*/
NDArray(NDView<T, Ndim> span) : NDArray(span.shape()) {
explicit NDArray(NDView<T, Ndim> span) : NDArray(span.shape()) {
std::copy(span.begin(), span.end(), begin());
// fmt::print("NDArray(NDView<T, Ndim> span)\n");
}
// Move constructor
NDArray(NDArray &&other)
: shape_(other.shape_), strides_(c_strides<Ndim>(shape_)), size_(other.size_), data_(nullptr) {
data_ = other.data_;
NDArray(NDArray &&other) noexcept
: shape_(other.shape_), strides_(c_strides<Ndim>(shape_)), size_(other.size_), data_(other.data_) {
other.reset();
// fmt::print("NDArray(NDArray &&other)\n");
}
@ -59,8 +59,8 @@ template <typename T, ssize_t Ndim = 2> class NDArray {
using value_type = T;
NDArray &operator=(NDArray &&other); // Move assign
NDArray &operator=(const NDArray &other); // Copy assign
NDArray &operator=(NDArray &&other) noexcept; // Move assign
NDArray &operator=(const NDArray &other); // Copy assign
NDArray operator+(const NDArray &other);
NDArray &operator+=(const NDArray &other);
@ -77,9 +77,8 @@ template <typename T, ssize_t Ndim = 2> class NDArray {
data_[i] /= other(i);
}
return *this;
} else {
throw(std::runtime_error("Shape of NDArray must match"));
}
throw(std::runtime_error("Shape of NDArray must match"));
}
NDArray<bool, Ndim> operator>(const NDArray &other);
@ -87,17 +86,17 @@ template <typename T, ssize_t Ndim = 2> class NDArray {
bool operator==(const NDArray &other) const;
bool operator!=(const NDArray &other) const;
NDArray &operator=(const T &);
NDArray &operator+=(const T &);
NDArray operator+(const T &);
NDArray &operator-=(const T &);
NDArray operator-(const T &);
NDArray &operator*=(const T &);
NDArray operator*(const T &);
NDArray &operator/=(const T &);
NDArray operator/(const T &);
NDArray &operator=(const T & /*value*/);
NDArray &operator+=(const T & /*value*/);
NDArray operator+(const T & /*value*/);
NDArray &operator-=(const T & /*value*/);
NDArray operator-(const T & /*value*/);
NDArray &operator*=(const T & /*value*/);
NDArray operator*(const T & /*value*/);
NDArray &operator/=(const T & /*value*/);
NDArray operator/(const T & /*value*/);
NDArray &operator&=(const T &);
NDArray &operator&=(const T & /*mask*/);
void sqrt() {
for (int i = 0; i < size_; ++i) {
@ -107,15 +106,15 @@ template <typename T, ssize_t Ndim = 2> class NDArray {
NDArray &operator++(); // pre inc
template <typename... Ix> typename std::enable_if<sizeof...(Ix) == Ndim, T &>::type operator()(Ix... index) {
template <typename... Ix> std::enable_if_t<sizeof...(Ix) == Ndim, T &> operator()(Ix... index) {
return data_[element_offset(strides_, index...)];
}
template <typename... Ix> typename std::enable_if<sizeof...(Ix) == Ndim, T &>::type operator()(Ix... index) const {
template <typename... Ix> std::enable_if_t<sizeof...(Ix) == Ndim, T &> operator()(Ix... index) const {
return data_[element_offset(strides_, index...)];
}
template <typename... Ix> typename std::enable_if<sizeof...(Ix) == Ndim, T>::type value(Ix... index) {
template <typename... Ix> std::enable_if_t<sizeof...(Ix) == Ndim, T> value(Ix... index) {
return data_[element_offset(strides_, index...)];
}
@ -153,12 +152,12 @@ template <typename T, ssize_t Ndim = 2> class NDArray {
private:
std::array<ssize_t, Ndim> shape_;
std::array<ssize_t, Ndim> strides_;
ssize_t size_;
ssize_t size_{};
T *data_;
};
// Move assign
template <typename T, ssize_t Ndim> NDArray<T, Ndim> &NDArray<T, Ndim>::operator=(NDArray<T, Ndim> &&other) {
template <typename T, ssize_t Ndim> NDArray<T, Ndim> &NDArray<T, Ndim>::operator=(NDArray<T, Ndim> &&other) noexcept {
if (this != &other) {
delete[] data_;
data_ = other.data_;
@ -182,9 +181,8 @@ template <typename T, ssize_t Ndim> NDArray<T, Ndim> &NDArray<T, Ndim>::operator
data_[i] += other.data_[i];
}
return *this;
} else {
throw(std::runtime_error("Shape of ImageDatas must match"));
}
throw(std::runtime_error("Shape of ImageDatas must match"));
}
template <typename T, ssize_t Ndim> NDArray<T, Ndim> NDArray<T, Ndim>::operator-(const NDArray &other) {
@ -200,9 +198,8 @@ template <typename T, ssize_t Ndim> NDArray<T, Ndim> &NDArray<T, Ndim>::operator
data_[i] -= other.data_[i];
}
return *this;
} else {
throw(std::runtime_error("Shape of ImageDatas must match"));
}
throw(std::runtime_error("Shape of ImageDatas must match"));
}
template <typename T, ssize_t Ndim> NDArray<T, Ndim> NDArray<T, Ndim>::operator*(const NDArray &other) {
NDArray result = *this;
@ -217,9 +214,8 @@ template <typename T, ssize_t Ndim> NDArray<T, Ndim> &NDArray<T, Ndim>::operator
data_[i] *= other.data_[i];
}
return *this;
} else {
throw(std::runtime_error("Shape of ImageDatas must match"));
}
throw(std::runtime_error("Shape of ImageDatas must match"));
}
template <typename T, ssize_t Ndim> NDArray<T, Ndim> NDArray<T, Ndim>::operator/(const NDArray &other) {
@ -256,9 +252,8 @@ template <typename T, ssize_t Ndim> NDArray<bool, Ndim> NDArray<T, Ndim>::operat
result(i) = (data_[i] > other.data_[i]);
}
return result;
} else {
throw(std::runtime_error("Shape of ImageDatas must match"));
}
throw(std::runtime_error("Shape of ImageDatas must match"));
}
template <typename T, ssize_t Ndim> NDArray<T, Ndim> &NDArray<T, Ndim>::operator=(const NDArray<T, Ndim> &other) {
@ -364,7 +359,7 @@ template <typename T, ssize_t Ndim> void NDArray<T, Ndim>::Print_some() {
}
}
template <typename T, ssize_t Ndim> void save(NDArray<T, Ndim> &img, std::string pathname) {
template <typename T, ssize_t Ndim> void save(NDArray<T, Ndim> &img, std::string &pathname) {
std::ofstream f;
f.open(pathname, std::ios::binary);
f.write(img.buffer(), img.size() * sizeof(T));

View File

@ -20,7 +20,7 @@ template <ssize_t Ndim> Shape<Ndim> make_shape(const std::vector<size_t> &shape)
return arr;
}
template <ssize_t Dim = 0, typename Strides> ssize_t element_offset(const Strides &) { return 0; }
template <ssize_t Dim = 0, typename Strides> ssize_t element_offset(const Strides & /*unused*/) { return 0; }
template <ssize_t Dim = 0, typename Strides, typename... Ix>
ssize_t element_offset(const Strides &strides, ssize_t i, Ix... index) {
@ -28,7 +28,7 @@ ssize_t element_offset(const Strides &strides, ssize_t i, Ix... index) {
}
template <ssize_t Ndim> std::array<ssize_t, Ndim> c_strides(const std::array<ssize_t, Ndim> &shape) {
std::array<ssize_t, Ndim> strides;
std::array<ssize_t, Ndim> strides{};
std::fill(strides.begin(), strides.end(), 1);
for (ssize_t i = Ndim - 1; i > 0; --i) {
strides[i - 1] = strides[i] * shape[i];
@ -38,42 +38,36 @@ template <ssize_t Ndim> std::array<ssize_t, Ndim> c_strides(const std::array<ssi
template <ssize_t Ndim> std::array<ssize_t, Ndim> make_array(const std::vector<ssize_t> &vec) {
assert(vec.size() == Ndim);
std::array<ssize_t, Ndim> arr;
std::array<ssize_t, Ndim> arr{};
std::copy_n(vec.begin(), Ndim, arr.begin());
return arr;
}
template <typename T, ssize_t Ndim = 2> class NDView {
public:
NDView(){};
NDView() = default;
~NDView() = default;
NDView(const NDView &) = default;
NDView(NDView &&) = default;
NDView(T *buffer, std::array<ssize_t, Ndim> shape) {
buffer_ = buffer;
strides_ = c_strides<Ndim>(shape);
shape_ = shape;
size_ = std::accumulate(std::begin(shape), std::end(shape), 1, std::multiplies<ssize_t>());
}
NDView(T *buffer, std::array<ssize_t, Ndim> shape)
: buffer_(buffer), strides_(c_strides<Ndim>(shape)), shape_(shape),
size_(std::accumulate(std::begin(shape), std::end(shape), 1, std::multiplies<>())) {}
NDView(T *buffer, const std::vector<ssize_t> &shape) {
buffer_ = buffer;
strides_ = c_strides<Ndim>(make_array<Ndim>(shape));
shape_ = make_array<Ndim>(shape);
size_ = std::accumulate(std::begin(shape), std::end(shape), 1, std::multiplies<ssize_t>());
}
NDView(T *buffer, const std::vector<ssize_t> &shape)
: buffer_(buffer), strides_(c_strides<Ndim>(make_array<Ndim>(shape))), shape_(make_array<Ndim>(shape)),
size_(std::accumulate(std::begin(shape), std::end(shape), 1, std::multiplies<>())) {}
template <typename... Ix> typename std::enable_if<sizeof...(Ix) == Ndim, T &>::type operator()(Ix... index) {
template <typename... Ix> std::enable_if_t<sizeof...(Ix) == Ndim, T &> operator()(Ix... index) {
return buffer_[element_offset(strides_, index...)];
}
template <typename... Ix> typename std::enable_if<sizeof...(Ix) == Ndim, T &>::type operator()(Ix... index) const {
template <typename... Ix> std::enable_if_t<sizeof...(Ix) == Ndim, T &> operator()(Ix... index) const {
return buffer_[element_offset(strides_, index...)];
}
ssize_t size() const { return size_; }
NDView(const NDView &) = default;
NDView(NDView &&) = default;
T *begin() { return buffer_; }
T *end() { return buffer_ + size_; }
T &operator()(ssize_t i) { return buffer_[i]; }
@ -103,12 +97,26 @@ template <typename T, ssize_t Ndim = 2> class NDView {
}
NDView &operator=(const NDView &other) {
if (this == &other)
return *this;
shape_ = other.shape_;
strides_ = other.strides_;
size_ = other.size_;
buffer_ = other.buffer_;
return *this;
}
NDView &operator=(NDView &&other) noexcept {
if (this == &other)
return *this;
shape_ = std::move(other.shape_);
strides_ = std::move(other.strides_);
size_ = other.size_;
buffer_ = other.buffer_;
other.buffer_ = nullptr;
return *this;
}
auto &shape() { return shape_; }
auto shape(ssize_t i) const { return shape_[i]; }

View File

@ -28,7 +28,7 @@ struct sls_detector_header {
uint16_t roundRNumber;
uint8_t detType;
uint8_t version;
uint8_t packetMask[64];
std::array<uint8_t, 64> packetMask;
};
struct xy {
@ -44,14 +44,14 @@ enum class DetectorType { Jungfrau, Eiger, Mythen3, Moench, ChipTestBoard };
enum class TimingMode { Auto, Trigger };
template <class T> T StringTo(std::string sv) { return T(sv); }
template <class T> T StringTo(const std::string &arg) { return T(arg); }
template <class T> std::string toString(T sv) { return T(sv); }
template <class T> std::string toString(T arg) { return T(arg); }
template <> DetectorType StringTo(std::string);
template <> std::string toString(DetectorType type);
template <> DetectorType StringTo(const std::string & /*name*/);
template <> std::string toString(DetectorType arg);
template <> TimingMode StringTo(std::string);
template <> TimingMode StringTo(const std::string & /*mode*/);
using DataTypeVariants = std::variant<uint16_t, uint32_t>;

View File

@ -1,8 +1,7 @@
#include "aare/core/DType.hpp"
#include "aare/utils/logger.hpp"
#include <fmt/format.h>
#include <fmt/core.h>
namespace aare {
@ -26,9 +25,7 @@ DType::DType(const std::type_info &t) {
m_type = TypeIndex::INT32;
else if (t == typeid(uint32_t))
m_type = TypeIndex::UINT32;
else if (t == typeid(int64_t))
m_type = TypeIndex::INT64;
else if (t == typeid(long))
else if (t == typeid(int64_t) || t == typeid(long)) // NOLINT
m_type = TypeIndex::INT64;
else if (t == typeid(uint64_t))
m_type = TypeIndex::UINT64;
@ -130,7 +127,7 @@ DType::DType(std::string_view sv) {
*/
std::string DType::str() const {
char ec;
char ec{};
if (endian::native == endian::little)
ec = '<';
else

View File

@ -1,7 +1,8 @@
#include "aare/core/Frame.hpp"
#include "aare/utils/logger.hpp"
#include <cassert>
#include <cstddef>
#include <cstring>
#include <iostream>
#include <sys/types.h>
namespace aare {
@ -12,9 +13,9 @@ namespace aare {
* @param cols number of columns
* @param bitdepth bitdepth of the pixels
*/
Frame::Frame(std::byte *bytes, ssize_t rows, ssize_t cols, ssize_t bitdepth)
: m_rows(rows), m_cols(cols), m_bitdepth(bitdepth) {
m_data = new std::byte[rows * cols * bitdepth / 8];
Frame::Frame(std::byte *bytes, size_t rows, size_t cols, size_t bitdepth)
: m_rows(rows), m_cols(cols), m_bitdepth(bitdepth), m_data(new std::byte[rows * cols * bitdepth / 8]) {
std::memcpy(m_data, bytes, rows * cols * bitdepth / 8);
}
@ -25,8 +26,9 @@ Frame::Frame(std::byte *bytes, ssize_t rows, ssize_t cols, ssize_t bitdepth)
* @param bitdepth bitdepth of the pixels
* @note the data is initialized to zero
*/
Frame::Frame(ssize_t rows, ssize_t cols, ssize_t bitdepth) : m_rows(rows), m_cols(cols), m_bitdepth(bitdepth) {
m_data = new std::byte[rows * cols * bitdepth / 8];
Frame::Frame(size_t rows, size_t cols, size_t bitdepth)
: m_rows(rows), m_cols(cols), m_bitdepth(bitdepth), m_data(new std::byte[rows * cols * bitdepth / 8]) {
std::memset(m_data, 0, rows * cols * bitdepth / 8);
}
@ -37,10 +39,10 @@ Frame::Frame(ssize_t rows, ssize_t cols, ssize_t bitdepth) : m_rows(rows), m_col
* @return pointer to the pixel
* @note the user should cast the pointer to the appropriate type
*/
std::byte *Frame::get(int row, int col) {
if (row < 0 || row >= m_rows || col < 0 || col >= m_cols) {
std::cerr << "Invalid row or column index" << std::endl;
return 0;
std::byte *Frame::get(size_t row, size_t col) {
if (row >= m_rows or col >= m_cols) {
std::cerr << "Invalid row or column index" << '\n';
return nullptr;
}
return m_data + (row * m_cols + col) * (m_bitdepth / 8);
}

View File

@ -1,4 +1,6 @@
#include "aare/core/defs.hpp"
#include <stdexcept>
#include <string>
namespace aare {
@ -7,8 +9,8 @@ namespace aare {
* @param type DetectorType
* @return string representation of the DetectorType
*/
template <> std::string toString(DetectorType type) {
switch (type) {
template <> std::string toString(DetectorType arg) {
switch (arg) {
case DetectorType::Jungfrau:
return "Jungfrau";
case DetectorType::Eiger:
@ -30,20 +32,18 @@ template <> std::string toString(DetectorType type) {
* @return DetectorType
* @throw runtime_error if the string does not match any DetectorType
*/
template <> DetectorType StringTo(std::string name) {
if (name == "Jungfrau")
template <> DetectorType StringTo(const std::string &arg) {
if (arg == "Jungfrau")
return DetectorType::Jungfrau;
else if (name == "Eiger")
if (arg == "Eiger")
return DetectorType::Eiger;
else if (name == "Mythen3")
if (arg == "Mythen3")
return DetectorType::Mythen3;
else if (name == "Moench")
if (arg == "Moench")
return DetectorType::Moench;
else if (name == "ChipTestBoard")
if (arg == "ChipTestBoard")
return DetectorType::ChipTestBoard;
else {
throw std::runtime_error("Could not decode dector from: \"" + name + "\"");
}
throw std::runtime_error("Could not decode dector from: \"" + arg + "\"");
}
/**
@ -52,14 +52,12 @@ template <> DetectorType StringTo(std::string name) {
* @return TimingMode
* @throw runtime_error if the string does not match any TimingMode
*/
template <> TimingMode StringTo(std::string mode) {
if (mode == "auto")
template <> TimingMode StringTo(const std::string &arg) {
if (arg == "auto")
return TimingMode::Auto;
else if (mode == "trigger")
if (arg == "trigger")
return TimingMode::Trigger;
else {
throw std::runtime_error("Could not decode timing mode from: \"" + mode + "\"");
}
throw std::runtime_error("Could not decode timing mode from: \"" + arg + "\"");
}
// template <> TimingMode StringTo<TimingMode>(std::string mode);

View File

@ -4,9 +4,9 @@
using aare::Frame;
TEST_CASE("Construct a frame") {
ssize_t rows = 10;
ssize_t cols = 10;
ssize_t bitdepth = 8;
size_t rows = 10;
size_t cols = 10;
size_t bitdepth = 8;
Frame frame(rows, cols, bitdepth);
@ -16,8 +16,8 @@ TEST_CASE("Construct a frame") {
REQUIRE(frame.size() == rows * cols * bitdepth / 8);
// data should be initialized to 0
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
for (size_t i = 0; i < rows; i++) {
for (size_t j = 0; j < cols; j++) {
uint8_t *data = (uint8_t *)frame.get(i, j);
REQUIRE(data != nullptr);
REQUIRE(*data == 0);
@ -26,9 +26,9 @@ TEST_CASE("Construct a frame") {
}
TEST_CASE("Set a value in a 8 bit frame") {
ssize_t rows = 10;
ssize_t cols = 10;
ssize_t bitdepth = 8;
size_t rows = 10;
size_t cols = 10;
size_t bitdepth = 8;
Frame frame(rows, cols, bitdepth);
@ -37,8 +37,8 @@ TEST_CASE("Set a value in a 8 bit frame") {
frame.set(5, 7, value);
// only the value we did set should be non-zero
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
for (size_t i = 0; i < rows; i++) {
for (size_t j = 0; j < cols; j++) {
uint8_t *data = (uint8_t *)frame.get(i, j);
REQUIRE(data != nullptr);
if (i == 5 && j == 7) {
@ -51,9 +51,9 @@ TEST_CASE("Set a value in a 8 bit frame") {
}
TEST_CASE("Set a value in a 64 bit frame") {
ssize_t rows = 10;
ssize_t cols = 10;
ssize_t bitdepth = 64;
size_t rows = 10;
size_t cols = 10;
size_t bitdepth = 64;
Frame frame(rows, cols, bitdepth);
@ -62,8 +62,8 @@ TEST_CASE("Set a value in a 64 bit frame") {
frame.set(5, 7, value);
// only the value we did set should be non-zero
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
for (size_t i = 0; i < rows; i++) {
for (size_t j = 0; j < cols; j++) {
uint64_t *data = (uint64_t *)frame.get(i, j);
REQUIRE(data != nullptr);
if (i == 5 && j == 7) {
@ -76,9 +76,9 @@ TEST_CASE("Set a value in a 64 bit frame") {
}
TEST_CASE("Move construct a frame") {
ssize_t rows = 10;
ssize_t cols = 10;
ssize_t bitdepth = 8;
size_t rows = 10;
size_t cols = 10;
size_t bitdepth = 8;
Frame frame(rows, cols, bitdepth);
std::byte *data = frame.data();