mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-11 04:17:15 +02:00
fixed tests
This commit is contained in:
@ -93,13 +93,15 @@ TEST_CASE("rx_framescaught", "[.cmd][.rx]") {
|
||||
CmdProxy proxy(&det);
|
||||
|
||||
// This ensures 0 caught frames
|
||||
auto prev_val = det.getFileWrite();
|
||||
det.setFileWrite(false); // avoid writing or error on file creation
|
||||
det.startReceiver();
|
||||
det.stopReceiver();
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("rx_framescaught", {}, -1, GET, oss);
|
||||
if (det.getNumberofUDPInterfaces() == 1) {
|
||||
if (det.getNumberofUDPInterfaces().tsquash(
|
||||
"inconsistent number of interfaces") == 1) {
|
||||
REQUIRE(oss.str() == "rx_framescaught [0]\n");
|
||||
} else {
|
||||
REQUIRE(oss.str() == "rx_framescaught [0, 0]\n");
|
||||
@ -115,10 +117,15 @@ TEST_CASE("rx_framescaught", "[.cmd][.rx]") {
|
||||
// proxy.Call("rx_framescaught", {}, -1, GET, oss);
|
||||
// REQUIRE(oss.str() == "rx_framescaught 1\n");
|
||||
// }
|
||||
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setFileWrite(prev_val[i], {i});
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("rx_missingpackets", "[.cmd][.rx]") {
|
||||
Detector det;
|
||||
auto prev_val = det.getFileWrite();
|
||||
det.setFileWrite(false); // avoid writing or error on file creation
|
||||
CmdProxy proxy(&det);
|
||||
{
|
||||
@ -127,8 +134,12 @@ TEST_CASE("rx_missingpackets", "[.cmd][.rx]") {
|
||||
det.stopReceiver();
|
||||
std::ostringstream oss;
|
||||
proxy.Call("rx_missingpackets", {}, -1, GET, oss);
|
||||
std::string s = (oss.str()).erase(0, strlen("rx_missingpackets ["));
|
||||
REQUIRE(std::stoi(s) > 0);
|
||||
if (det.getNumberofUDPInterfaces().tsquash(
|
||||
"inconsistent number of interfaces") == 1) {
|
||||
REQUIRE(oss.str() != "rx_missingpackets [0]\n");
|
||||
} else {
|
||||
REQUIRE(oss.str() != "rx_missingpackets [0, 0]\n");
|
||||
}
|
||||
}
|
||||
{
|
||||
// 0 missing packets (takes into account that acquisition is stopped)
|
||||
@ -137,8 +148,15 @@ TEST_CASE("rx_missingpackets", "[.cmd][.rx]") {
|
||||
det.stopReceiver();
|
||||
std::ostringstream oss;
|
||||
proxy.Call("rx_missingpackets", {}, -1, GET, oss);
|
||||
std::string s = (oss.str()).erase(0, strlen("rx_missingpackets ["));
|
||||
REQUIRE(std::stoi(s) == 0);
|
||||
if (det.getNumberofUDPInterfaces().tsquash(
|
||||
"inconsistent number of interfaces") == 1) {
|
||||
REQUIRE(oss.str() == "rx_missingpackets [0]\n");
|
||||
} else {
|
||||
REQUIRE(oss.str() == "rx_missingpackets [0, 0]\n");
|
||||
}
|
||||
}
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setFileWrite(prev_val[i], {i});
|
||||
}
|
||||
}
|
||||
|
||||
@ -149,10 +167,6 @@ TEST_CASE("rx_frameindex", "[.cmd][.rx]") {
|
||||
|
||||
// This is a get only command
|
||||
REQUIRE_THROWS(proxy.Call("rx_frameindex", {"2"}, -1, PUT));
|
||||
std::ostringstream oss;
|
||||
proxy.Call("rx_frameindex", {}, 0, GET, oss);
|
||||
std::string s = (oss.str()).erase(0, strlen("rx_frameindex "));
|
||||
REQUIRE(std::stoi(s) >= 0);
|
||||
}
|
||||
|
||||
/* Network Configuration (Detector<->Receiver) */
|
||||
|
@ -34,8 +34,8 @@ TEST_CASE("Push pop") {
|
||||
for (size_t i = 0; i != vec.size(); ++i) {
|
||||
fifo.push(p);
|
||||
++p;
|
||||
CHECK(fifo.getDataValue() == i + 1);
|
||||
CHECK(fifo.getFreeValue() == 4 - i);
|
||||
CHECK(fifo.getDataValue() == (int)(i + 1));
|
||||
CHECK(fifo.getFreeValue() == (int)(4 - i));
|
||||
}
|
||||
|
||||
CHECK(fifo.isEmpty() == false);
|
||||
@ -44,8 +44,8 @@ TEST_CASE("Push pop") {
|
||||
for (size_t i = 0; i != vec.size(); ++i) {
|
||||
fifo.pop(p);
|
||||
CHECK(*p == vec[i]);
|
||||
CHECK(fifo.getDataValue() == 4 - i);
|
||||
CHECK(fifo.getFreeValue() == i + 1);
|
||||
CHECK(fifo.getDataValue() == (int)(4 - i));
|
||||
CHECK(fifo.getFreeValue() == (int)(i + 1));
|
||||
}
|
||||
|
||||
CHECK(fifo.isEmpty() == true);
|
||||
|
Reference in New Issue
Block a user