62 lines
2.9 KiB
C++
62 lines
2.9 KiB
C++
// Copyright (2019-2023) Paul Scherrer Institute
|
|
|
|
#include <catch2/catch_all.hpp>
|
|
#include "../common/DetectorSetup.h"
|
|
|
|
TEST_CASE("DetectorSetup_MismatchInSize") {
|
|
REQUIRE_THROWS(DetectorSetup(DetectorGeometry(8), DetectorType::JUNGFRAU, "JF", {"mx1","mx2","mx3","mx4"}));
|
|
REQUIRE_THROWS(DetectorSetup(DetectorGeometry(2), DetectorType::JUNGFRAU, "JF", {"mx1","mx2","mx3","mx4"}));
|
|
REQUIRE_NOTHROW(DetectorSetup(DetectorGeometry(4), DetectorType::JUNGFRAU, "JF", {"mx1","mx2","mx3","mx4"}));
|
|
}
|
|
|
|
TEST_CASE("DetectorSetup_ProtoBuf") {
|
|
DetectorSetup setup(DetectorGeometry(4), DetectorType::JUNGFRAU, "JF", {"mx1","mx2","mx3","mx4"});
|
|
|
|
REQUIRE(setup.GetDescription() == "JF");
|
|
REQUIRE(setup.GetDetectorModuleHostname().size() == 4);
|
|
REQUIRE(setup.GetDetectorModuleHostname()[3] == "mx4");
|
|
REQUIRE(setup.GetPixelSize_mm() == Catch::Approx(0.075));
|
|
REQUIRE(setup.GetModulesNum() == 4);
|
|
REQUIRE(setup.GetGeometry().GetModulesNum() == 4);
|
|
}
|
|
|
|
TEST_CASE("DetectorSetup_ProtoBuf_FullSpeed") {
|
|
DetectorSetup setup(DetectorGeometry(4), DetectorType::JUNGFRAU, "JF", {"mx1","mx2","mx3","mx4"});
|
|
|
|
REQUIRE(setup.GetUDPInterfaceCount() == 2);
|
|
REQUIRE_NOTHROW(setup.UDPInterfaceCount(1));
|
|
REQUIRE_THROWS(setup.UDPInterfaceCount(0));
|
|
REQUIRE_THROWS(setup.UDPInterfaceCount(5));
|
|
REQUIRE_THROWS(setup.UDPInterfaceCount(-56));
|
|
|
|
REQUIRE(setup.GetUDPInterfaceCount() == 1);
|
|
}
|
|
|
|
TEST_CASE("DetectorSetup_LoadGainFile") {
|
|
DetectorSetup setup(DetectorGeometry(4), DetectorType::JUNGFRAU, "JF", {"mx1","mx2","mx3","mx4"});
|
|
REQUIRE_THROWS(setup.LoadGain({}));
|
|
|
|
REQUIRE(setup.GetGainCalibration().empty());
|
|
|
|
REQUIRE_THROWS(setup.LoadGain({
|
|
"../../tests/test_data/gainMaps_M049.bin",
|
|
"../../tests/test_data/gainMaps_M049.bin",
|
|
"../../tests/test_data/gainMaps_M049.bin"
|
|
}));
|
|
|
|
REQUIRE_THROWS(setup.LoadGain({
|
|
"../../tests/test_data/gainMaps_M049.bin",
|
|
"../../tests/test_data/gainMaps_M049.bin",
|
|
"../../tests/test_data/gainMaps_M049.bin",
|
|
"../../tests/test_data/gainMaps_M049.bin",
|
|
"../../tests/test_data/gainMaps_M049.bin"
|
|
}));
|
|
|
|
REQUIRE_NOTHROW(setup.LoadGain({
|
|
"../../tests/test_data/gainMaps_M049.bin",
|
|
"../../tests/test_data/gainMaps_M049.bin",
|
|
"../../tests/test_data/gainMaps_M049.bin",
|
|
"../../tests/test_data/gainMaps_M049.bin"
|
|
}));
|
|
REQUIRE(setup.GetGainCalibration().size() == 4);
|
|
} |