jfjoch_viewer: Track top-pixels without storing/sorting all valid pixels
This commit is contained in:
28
tests/TopPixelsTest.cpp
Normal file
28
tests/TopPixelsTest.cpp
Normal 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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user