catch2: download with CMake + update to recent Catch2

This commit is contained in:
2024-05-14 21:31:34 +02:00
parent 9f1b6a6e96
commit eb0e5daf8f
47 changed files with 222 additions and 18206 deletions
+19 -19
View File
@@ -1,6 +1,6 @@
// Copyright (2019-2023) Paul Scherrer Institute
#include <catch2/catch.hpp>
#include <catch2/catch_all.hpp>
#include <random>
#include "../jungfrau/JFPedestalCalc.h"
@@ -367,7 +367,7 @@ TEST_CASE("HLS_C_Simulation_check_convert_full_range", "[FPGA][Full]") {
for (const auto energy : energy_values) {
x.PedestalG0Frames(0).NumTriggers(1).ImagesPerTrigger(1).PhotonEnergy_keV(energy);
REQUIRE(x.GetPhotonEnergy_keV() == Approx(energy));
REQUIRE(x.GetPhotonEnergy_keV() == Catch::Approx(energy));
JFCalibration c_in(x);
c_in.Pedestal(0,0) = pedestal_g0;
@@ -418,7 +418,7 @@ TEST_CASE("HLS_C_Simulation_check_convert_full_range_HG0", "[FPGA][Full]") {
x.PedestalG0Frames(0).NumTriggers(1).ImagesPerTrigger(1).PhotonEnergy_keV(energy);
REQUIRE(x.IsUsingGainHG0());
REQUIRE(x.GetPhotonEnergy_keV() == Approx(energy));
REQUIRE(x.GetPhotonEnergy_keV() == Catch::Approx(energy));
JFCalibration c_in(x);
c_in.Pedestal(0,0) = pedestal_g0;
@@ -448,7 +448,7 @@ TEST_CASE("HLS_C_Simulation_check_convert_full_range_HG0", "[FPGA][Full]") {
x.PedestalG0Frames(0).NumTriggers(1).ImagesPerTrigger(1).PhotonEnergy_keV(energy);
REQUIRE(!x.IsUsingGainHG0());
REQUIRE(x.GetPhotonEnergy_keV() == Approx(energy));
REQUIRE(x.GetPhotonEnergy_keV() == Catch::Approx(energy));
JFCalibration c_in(x);
c_in.Pedestal(0,0) = pedestal_g0;
@@ -499,7 +499,7 @@ TEST_CASE("HLS_C_Simulation_check_convert_full_range_fixedG1", "[FPGA][Full]") {
x.PedestalG0Frames(0).NumTriggers(1).ImagesPerTrigger(1).PhotonEnergy_keV(energy);
REQUIRE(x.IsFixedGainG1());
REQUIRE(x.GetPhotonEnergy_keV() == Approx(energy));
REQUIRE(x.GetPhotonEnergy_keV() == Catch::Approx(energy));
JFCalibration c_in(x);
c_in.Pedestal(0,0) = pedestal_g0;
@@ -549,7 +549,7 @@ TEST_CASE("HLS_C_Simulation_check_convert_full_range_I32", "[FPGA][Full]") {
for (const auto energy : energy_values) {
x.PedestalG0Frames(0).NumTriggers(1).ImagesPerTrigger(1).PhotonEnergy_keV(energy).FPGAOutputMode(FPGAPixelOutput::Int32);
REQUIRE(x.GetPhotonEnergy_keV() == Approx(energy));
REQUIRE(x.GetPhotonEnergy_keV() == Catch::Approx(energy));
JFCalibration c_in(x);
c_in.Pedestal(0,0) = pedestal_g0;
@@ -602,7 +602,7 @@ TEST_CASE("HLS_C_Simulation_check_convert_full_range_sum4", "[FPGA][Full]") {
logger.Info("Trying with {} keV", energy);
x.PedestalG0Frames(0).NumTriggers(1).ImagesPerTrigger(1).PhotonEnergy_keV(energy).Summation(nsummation);
REQUIRE(x.GetPhotonEnergy_keV() == Approx(energy));
REQUIRE(x.GetPhotonEnergy_keV() == Catch::Approx(energy));
JFCalibration c_in(x);
c_in.Pedestal(0,0) = pedestal_g0;
@@ -654,7 +654,7 @@ TEST_CASE("HLS_C_Simulation_check_convert_full_range_U16", "[FPGA][Full]") {
logger.Info("Trying with {} keV", energy);
x.PedestalG0Frames(0).NumTriggers(1).ImagesPerTrigger(1).PhotonEnergy_keV(energy).FPGAOutputMode(FPGAPixelOutput::Uint16);
REQUIRE(x.GetPhotonEnergy_keV() == Approx(energy));
REQUIRE(x.GetPhotonEnergy_keV() == Catch::Approx(energy));
JFCalibration c_in(x);
c_in.Pedestal(0,0) = pedestal_g0;
@@ -815,7 +815,7 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_convert_full_range", "[FPG
x.Mode(DetectorMode::Conversion);
x.PedestalG0Frames(0).NumTriggers(1).ImagesPerTrigger(1).UseInternalPacketGenerator(true).PhotonEnergy_keV(energy);
REQUIRE(x.GetPhotonEnergy_keV() == Approx(energy));
REQUIRE(x.GetPhotonEnergy_keV() == Catch::Approx(energy));
auto gain_from_file = GainCalibrationFromTestFile();
@@ -870,7 +870,7 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_convert_full_range_adu_his
x.Mode(DetectorMode::Conversion);
x.PedestalG0Frames(0).NumTriggers(1).ImagesPerTrigger(1).UseInternalPacketGenerator(true).PhotonEnergy_keV(energy);
REQUIRE(x.GetPhotonEnergy_keV() == Approx(energy));
REQUIRE(x.GetPhotonEnergy_keV() == Catch::Approx(energy));
auto gain_from_file = GainCalibrationFromTestFile();
@@ -1477,23 +1477,23 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_integration", "[FPGA][Full
REQUIRE(memcmp(imageBuf, frame.data(), RAW_MODULE_SIZE * sizeof(uint16_t)) == 0);
auto integration_result = test.GetDeviceOutput(0, 0)->integration_result;
CHECK(integration_result[0].sum == Approx(32754LU * (RAW_MODULE_SIZE / 2)));
CHECK(integration_result[0].sum == Catch::Approx(32754LU * (RAW_MODULE_SIZE / 2)));
CHECK(integration_result[0].count == RAW_MODULE_SIZE / 2);
CHECK(integration_result[1].sum == 0);
CHECK(integration_result[1].count == 0);
CHECK(integration_result[FPGA_INTEGRATION_BIN_COUNT - 1].sum == Approx(32754LU * (RAW_MODULE_SIZE / 2 - 1)));
CHECK(integration_result[FPGA_INTEGRATION_BIN_COUNT - 1].sum == Catch::Approx(32754LU * (RAW_MODULE_SIZE / 2 - 1)));
CHECK(integration_result[FPGA_INTEGRATION_BIN_COUNT - 1].count == RAW_MODULE_SIZE / 2 - 1);
integration_result = test.GetDeviceOutput(0, 1)->integration_result;
CHECK(integration_result[54].sum == Approx(32754LU * (RAW_MODULE_SIZE)));
CHECK(integration_result[54].sum == Catch::Approx(32754LU * (RAW_MODULE_SIZE)));
CHECK(integration_result[54].count == RAW_MODULE_SIZE);
integration_result = test.GetDeviceOutput(0, 2)->integration_result;
CHECK(integration_result[54].sum == Approx(32754 * (RAW_MODULE_SIZE)));
CHECK(integration_result[54].sum == Catch::Approx(32754 * (RAW_MODULE_SIZE)));
CHECK(integration_result[54].count == RAW_MODULE_SIZE);
integration_result = test.GetDeviceOutput(0, 3)->integration_result;
CHECK(integration_result[54].sum == Approx(32754 * (RAW_MODULE_SIZE)));
CHECK(integration_result[54].sum == Catch::Approx(32754 * (RAW_MODULE_SIZE)));
CHECK(integration_result[54].count == RAW_MODULE_SIZE);
}
@@ -2150,13 +2150,13 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_roi_calc", "[FPGA][Full]")
for (int m = 0; m < x.GetModulesNum(); m++) {
CHECK (test.GetDeviceOutput(i, m)->roi_counts[0].sum == 83 + 95 + 13 + 125);
CHECK (test.GetDeviceOutput(i, m)->roi_counts[0].sum2 == 83 * 83 + 95 * 95 + 13 * 13 + 125 * 125);
CHECK (test.GetDeviceOutput(i, m)->roi_counts[0].sum_x_weighted == Approx(83 * 12 + 95 * 13 + 13 * 12 + 125 * 13));
CHECK (test.GetDeviceOutput(i, m)->roi_counts[0].sum_y_weighted == Approx(83 * 3 + 95 * 3 + 13 * 4 + 125 * 4));
CHECK (test.GetDeviceOutput(i, m)->roi_counts[0].sum_x_weighted == Catch::Approx(83 * 12 + 95 * 13 + 13 * 12 + 125 * 13));
CHECK (test.GetDeviceOutput(i, m)->roi_counts[0].sum_y_weighted == Catch::Approx(83 * 3 + 95 * 3 + 13 * 4 + 125 * 4));
CHECK (test.GetDeviceOutput(i, m)->roi_counts[0].max_value == 125);
CHECK (test.GetDeviceOutput(i, m)->roi_counts[0].good_pixels == 4);
CHECK (test.GetDeviceOutput(i, m)->roi_counts[1].sum_x_weighted == Approx(83 * (812+6) + 95 * (813+6) + 13 * (812+6) + 125 * (813+6)));
CHECK (test.GetDeviceOutput(i, m)->roi_counts[1].sum_y_weighted == Approx(83 * (303+2) + 95 * (303+2) + 13 * (304+2) + 125 * (304+2)));
CHECK (test.GetDeviceOutput(i, m)->roi_counts[1].sum_x_weighted == Catch::Approx(83 * (812+6) + 95 * (813+6) + 13 * (812+6) + 125 * (813+6)));
CHECK (test.GetDeviceOutput(i, m)->roi_counts[1].sum_y_weighted == Catch::Approx(83 * (303+2) + 95 * (303+2) + 13 * (304+2) + 125 * (304+2)));
}
}