diff --git a/include/aare/InclusiveROI.hpp b/include/aare/InclusiveROI.hpp index 7936ac5f..6e385bf6 100644 --- a/include/aare/InclusiveROI.hpp +++ b/include/aare/InclusiveROI.hpp @@ -34,6 +34,11 @@ struct InclusiveROI { return xmin >= 0 && ymin >= 0 && xmax < ncols && ymax < nrows; } + constexpr bool operator==(InclusiveROI const &other) const noexcept { + return xmin == other.xmin && xmax == other.xmax && ymin == other.ymin && + ymax == other.ymax; + } + static InclusiveROI emptyROI() noexcept { return {0, -1, 0, -1}; } // TODO (nice to have) // static InclusiveROI from_shape(ssize_t width, ssize_t height); diff --git a/src/InclusiveROI.test.cpp b/src/InclusiveROI.test.cpp new file mode 100644 index 00000000..77029986 --- /dev/null +++ b/src/InclusiveROI.test.cpp @@ -0,0 +1,16 @@ +#include "aare/InclusiveROI.hpp" +#include + +using namespace aare; + +TEST_CASE("mirror_on_y mirrors ROI about vertical axis", + "[InlusiveROIgeometry]") { + + SECTION("ROI on left side of axis") { + InclusiveROI roi{1, 3, 10, 20}; + + auto mirrored = inclusiveroi::geom::mirror_on_y(roi, 5); + + REQUIRE(mirrored == InclusiveROI{6, 8, 10, 20}); + } +} \ No newline at end of file