v1.0.0-rc.44

This commit is contained in:
2025-06-15 17:46:46 +02:00
parent 50fd15c678
commit b59a03ff02
180 changed files with 1531 additions and 1779 deletions

View File

@@ -4,7 +4,6 @@
#include <catch2/catch_all.hpp>
#include "../common/GridScanSettings.h"
#include "../common/JFJochException.h"
#include "../common/GridPlot.h"
TEST_CASE("GridScanSettings basic construction", "[GridScanSettings]") {
SECTION("Valid parameters") {
@@ -421,74 +420,3 @@ TEST_CASE("GridScanSettings::Rearrange functionality tests", "[gridscan][rearran
}
}
}
TEST_CASE("GridPlot", "[GridScanSettings]") {
GridScanSettings grid(4, 20.0f, 5.0f, true, false);
grid.ImageNum(19);
MultiLinePlotStruct p;
for (int i = 0; i < 19; i++) {
p.y.push_back(i);
p.x.push_back(i);
}
GridPlot plot(p, grid, -1);
SECTION("GridPlot metadata") {
CHECK(plot.GetStepX_um() == 20.0f);
CHECK(plot.GetStepY_um() == 5.0f);
CHECK(plot.GetWidth() == 4);
CHECK(plot.GetHeight() == 5);
}
SECTION("GridPlot GetPlot()") {
REQUIRE(plot.GetPlot().size() == 4 * 5);
// Row 0
CHECK(plot.GetPlot()[0] == 0);
CHECK(plot.GetPlot()[3] == 3);
// Row 1 (reversed)
CHECK(plot.GetPlot()[4] == 7);
CHECK(plot.GetPlot()[7] == 4);
// Row 2
CHECK(plot.GetPlot()[8] == 8);
CHECK(plot.GetPlot()[11] == 11);
// Row 3 (reversed)
CHECK(plot.GetPlot()[12] == 15);
CHECK(plot.GetPlot()[15] == 12);
// Row 4
CHECK(plot.GetPlot()[16] == 16);
CHECK(plot.GetPlot()[17] == 17);
CHECK(plot.GetPlot()[18] == 18);
CHECK(plot.GetPlot()[19] == -1);
}
std::vector<rgb> buf;
CompressedImage image;
SECTION("GridPlot GetImage") {
image = plot.GetImage(buf, GridPlotImageRequest{
.scale = ColorScaleEnum::BW,
.base_unit = 0.5
});
CHECK(image.GetWidth() == 4 * 20 * 2); // 160, 1 column = 40
CHECK(image.GetHeight() == 5 * 5 * 2); // 50, 1 row = 10
CHECK(image.GetMode() == CompressedImageMode::RGB);
CHECK(image.GetCompressedSize() == 160 * 50 * 3);
REQUIRE(buf.size() == 160 * 50);
CHECK(buf[160 * 3 + 10].r == 255);
CHECK(buf[160 * 3 + 10].g == 255);
CHECK(buf[160 * 3 + 10].b == 255);
CHECK(buf[160 * 43 + 2 * 40 + 15].r == 0);
CHECK(buf[160 * 43 + 2 * 40 + 15].g == 0);
CHECK(buf[160 * 43 + 2 * 40 + 15].b == 0);
// Gap (empty)
CHECK(buf[160 * 45 + 3 * 40 + 15].r == 190);
CHECK(buf[160 * 45 + 3 * 40 + 15].g == 190);
CHECK(buf[160 * 45 + 3 * 40 + 15].b == 190);
}
}