jfjoch_viewer: Track top-pixels without storing/sorting all valid pixels

This commit is contained in:
2025-12-12 11:36:54 +01:00
parent d70c60c501
commit e03d0677ba
9 changed files with 241 additions and 51 deletions

28
tests/TopPixelsTest.cpp Normal file
View File

@@ -0,0 +1,28 @@
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#include <catch2/catch_all.hpp>
#include "../common/TopPixels.h"
TEST_CASE("TopPixels") {
TopPixels tp(5);
REQUIRE(tp.Empty());
REQUIRE(tp.Size() == 0);
for (int i = 50; i > 0; i--)
tp.Add(i*2, i);
tp.Add(500,245);
tp.Add(0,1221);
REQUIRE(tp.Size() == 5);
CHECK(tp[0].index == 245);
CHECK(tp[0].value == 500);
for (int i = 1; i < 4; i++) {
CHECK(tp[i].index == (50 - i + 1));
CHECK(tp[i].value == (50 - i + 1) * 2);
}
}