fix tests

This commit is contained in:
maliakal_d 2021-11-25 10:14:49 +01:00
parent 993ba5926e
commit 00d63e48bb
2 changed files with 41 additions and 27 deletions

View File

@ -4705,7 +4705,6 @@ int get_read_n_rows(int file_des) {
#if !defined(EIGERD) && !defined(JUNGFRAUD) #if !defined(EIGERD) && !defined(JUNGFRAUD)
functionNotImplemented(); functionNotImplemented();
#else #else
// get only
retval = getReadNRows(); retval = getReadNRows();
if (retval == -1) { if (retval == -1) {
ret = FAIL; ret = FAIL;
@ -8685,7 +8684,7 @@ int get_flip_rows(int file_des) {
// only for HW 2.0 (version = 3) // only for HW 2.0 (version = 3)
if (isHardwareVersion2()) { if (isHardwareVersion2()) {
ret = FAIL; ret = FAIL;
strcpy(mess, "Could not set flip rows. Only available for " strcpy(mess, "Could not get flip rows. Only available for "
"Hardware Board version 2.0.\n"); "Hardware Board version 2.0.\n");
LOG(logERROR, (mess)); LOG(logERROR, (mess));
} else { } else {

View File

@ -1557,32 +1557,47 @@ TEST_CASE("readnrows", "[.cmd]") {
CmdProxy proxy(&det); CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash(); auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER || det_type == defs::JUNGFRAU) { if (det_type == defs::EIGER || det_type == defs::JUNGFRAU) {
auto prev_val = det.getReadNRows(); bool jungfrauhw2 = false;
{ if (det_type == defs::JUNGFRAU &&
std::ostringstream oss; !(det.getSerialNumber().tsquash(
proxy.Call("readnrows", {"256"}, -1, PUT, oss); "inconsistent serial number to test") &
REQUIRE(oss.str() == "readnrows 256\n"); 0x20000)) {
jungfrauhw2 = true;
} }
{ if (jungfrauhw2) {
std::ostringstream oss; {
proxy.Call("readnrows", {}, -1, GET, oss); std::ostringstream oss;
REQUIRE(oss.str() == "readnrows 256\n"); proxy.Call("readnrows", {}, -1, GET, oss);
} REQUIRE(oss.str() == "readnrows 512\n");
{ }
std::ostringstream oss; } else {
proxy.Call("readnrows", {"16"}, -1, PUT, oss); auto prev_val = det.getReadNRows();
REQUIRE(oss.str() == "readnrows 16\n"); {
} std::ostringstream oss;
if (det_type == defs::JUNGFRAU) { proxy.Call("readnrows", {"256"}, -1, PUT, oss);
REQUIRE_THROWS(proxy.Call("readnrows", {"7"}, -1, PUT)); REQUIRE(oss.str() == "readnrows 256\n");
REQUIRE_THROWS(proxy.Call("readnrows", {"20"}, -1, PUT)); }
REQUIRE_THROWS(proxy.Call("readnrows", {"44"}, -1, PUT)); {
REQUIRE_THROWS(proxy.Call("readnrows", {"513"}, -1, PUT)); std::ostringstream oss;
REQUIRE_THROWS(proxy.Call("readnrows", {"1"}, -1, PUT)); proxy.Call("readnrows", {}, -1, GET, oss);
} REQUIRE(oss.str() == "readnrows 256\n");
REQUIRE_THROWS(proxy.Call("readnrows", {"0"}, -1, PUT)); }
for (int i = 0; i != det.size(); ++i) { {
det.setReadNRows(prev_val[i], {i}); std::ostringstream oss;
proxy.Call("readnrows", {"16"}, -1, PUT, oss);
REQUIRE(oss.str() == "readnrows 16\n");
}
if (det_type == defs::JUNGFRAU) {
REQUIRE_THROWS(proxy.Call("readnrows", {"7"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("readnrows", {"20"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("readnrows", {"44"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("readnrows", {"513"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("readnrows", {"1"}, -1, PUT));
}
REQUIRE_THROWS(proxy.Call("readnrows", {"0"}, -1, PUT));
for (int i = 0; i != det.size(); ++i) {
det.setReadNRows(prev_val[i], {i});
}
} }
} else { } else {
REQUIRE_THROWS(proxy.Call("readnrows", {}, -1, GET)); REQUIRE_THROWS(proxy.Call("readnrows", {}, -1, GET));