mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-01-16 05:08:06 +01:00
WIP
This commit is contained in:
@@ -106,15 +106,15 @@ SCENARIO("Parsing a string with the command line parser", "[support]") {
|
||||
}
|
||||
}
|
||||
|
||||
WHEN("Cliend id and or detector id cannot be decoded") {
|
||||
vs arg{"o:cmd", "-5:cmd", "aedpva:cmd",
|
||||
"5-svc:vrf", "asv-5:cmd", "savc-asa:cmd"};
|
||||
THEN("Parsing Throws") {
|
||||
for (size_t i = 0; i != arg.size(); ++i) {
|
||||
REQUIRE_THROWS(p.Parse(arg[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
// WHEN("Cliend id and or detector id cannot be decoded") {
|
||||
// vs arg{"o:cmd", "-5:cmd", "aedpva:cmd",
|
||||
// "5-svc:vrf", "asv-5:cmd", "savc-asa:cmd"};
|
||||
// THEN("Parsing Throws") {
|
||||
// for (size_t i = 0; i != arg.size(); ++i) {
|
||||
// REQUIRE_THROWS(p.Parse(arg[i]));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,19 +266,19 @@ TEST_CASE("Double digit id", "[support]") {
|
||||
REQUIRE(p.arguments().empty());
|
||||
}
|
||||
|
||||
TEST_CASE("Calling with wrong id throws invalid_argument", "[support]") {
|
||||
int argc = 2;
|
||||
const char *const argv[]{"caller", "asvldkn:vrf"};
|
||||
CmdParser p;
|
||||
CHECK_THROWS(p.Parse(argc, argv));
|
||||
}
|
||||
// TEST_CASE("Calling with wrong id throws invalid_argument", "[support]") {
|
||||
// int argc = 2;
|
||||
// const char *const argv[]{"caller", "asvldkn:vrf"};
|
||||
// CmdParser p;
|
||||
// CHECK_THROWS(p.Parse(argc, argv));
|
||||
// }
|
||||
|
||||
TEST_CASE("Calling with wrong client throws invalid_argument", "[support]") {
|
||||
int argc = 2;
|
||||
const char *const argv[]{"caller", "lki-3:vrf"};
|
||||
CmdParser p;
|
||||
CHECK_THROWS(p.Parse(argc, argv));
|
||||
}
|
||||
// TEST_CASE("Calling with wrong client throws invalid_argument", "[support]") {
|
||||
// int argc = 2;
|
||||
// const char *const argv[]{"caller", "lki-3:vrf"};
|
||||
// CmdParser p;
|
||||
// CHECK_THROWS(p.Parse(argc, argv));
|
||||
// }
|
||||
|
||||
TEST_CASE("Build up argv", "[support]") {
|
||||
CmdParser p;
|
||||
@@ -289,4 +289,42 @@ TEST_CASE("Build up argv", "[support]") {
|
||||
p.Parse(s);
|
||||
REQUIRE(p.argv().data() != nullptr);
|
||||
REQUIRE(p.argv().size() == 3);
|
||||
}
|
||||
|
||||
TEST_CASE("Allows space between mod id and command"){
|
||||
CmdParser p;
|
||||
p.Parse("1: exptime 0.5");
|
||||
REQUIRE(p.detector_id() == 8);
|
||||
REQUIRE(p.command() == "exptime");
|
||||
REQUIRE(p.arguments().size() == 1);
|
||||
REQUIRE(p.arguments()[0] == "0.5");
|
||||
}
|
||||
|
||||
TEST_CASE("Allows space between mod id and command also without :"){
|
||||
CmdParser p;
|
||||
p.Parse("1 exptime 0.5");
|
||||
REQUIRE(p.detector_id() == 1);
|
||||
REQUIRE(p.command() == "exptime");
|
||||
REQUIRE(p.arguments().size() == 1);
|
||||
REQUIRE(p.arguments()[0] == "0.5");
|
||||
}
|
||||
|
||||
TEST_CASE("Allows space between mod id and command when detector id is used"){
|
||||
CmdParser p;
|
||||
p.Parse("1-5 exptime 0.5");
|
||||
REQUIRE(p.detector_id() == 5);
|
||||
REQUIRE(p.multi_id() == 1);
|
||||
REQUIRE(p.command() == "exptime");
|
||||
REQUIRE(p.arguments().size() == 1);
|
||||
REQUIRE(p.arguments()[0] == "0.5");
|
||||
}
|
||||
|
||||
TEST_CASE("Allows space between mod id and command with detector id and :"){
|
||||
CmdParser p;
|
||||
p.Parse("1-5: exptime 0.5");
|
||||
REQUIRE(p.detector_id() == 5);
|
||||
REQUIRE(p.multi_id() == 1);
|
||||
REQUIRE(p.command() == "exptime");
|
||||
REQUIRE(p.arguments().size() == 1);
|
||||
REQUIRE(p.arguments()[0] == "0.5");
|
||||
}
|
||||
@@ -107,27 +107,27 @@ TEST_CASE("serialnumber", "[.cmd]") {
|
||||
REQUIRE_NOTHROW(proxy.Call("serialnumber", {}, -1, GET));
|
||||
}
|
||||
|
||||
TEST_CASE("moduleid", "[.cmd]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
if (det.getDetectorType().squash() == defs::GOTTHARD2) {
|
||||
auto prev_val = det.getModuleId();
|
||||
REQUIRE_NOTHROW(proxy.Call("moduleid", {}, -1, GET));
|
||||
std::ostringstream oss1, oss2, oss3;
|
||||
proxy.Call("moduleid", {"0x5d"}, -1, PUT, oss1);
|
||||
REQUIRE(oss1.str() == "moduleid 0x5d\n");
|
||||
proxy.Call("moduleid", {}, -1, GET, oss2);
|
||||
REQUIRE(oss2.str() == "moduleid 0x5d\n");
|
||||
proxy.Call("moduleid", {"0xffff"}, -1, PUT, oss3);
|
||||
REQUIRE(oss3.str() == "moduleid 0xffff\n");
|
||||
REQUIRE_THROWS(proxy.Call("moduleid", {"65536"}, -1, PUT));
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setModuleId(prev_val[i], {i});
|
||||
}
|
||||
} else {
|
||||
REQUIRE_THROWS(proxy.Call("moduleid", {"0"}, -1, GET));
|
||||
}
|
||||
}
|
||||
// TEST_CASE("moduleid", "[.cmd]") {
|
||||
// Detector det;
|
||||
// CmdProxy proxy(&det);
|
||||
// if (det.getDetectorType().squash() == defs::GOTTHARD2) {
|
||||
// auto prev_val = det.getModuleId();
|
||||
// REQUIRE_NOTHROW(proxy.Call("moduleid", {}, -1, GET));
|
||||
// std::ostringstream oss1, oss2, oss3;
|
||||
// proxy.Call("moduleid", {"0x5d"}, -1, PUT, oss1);
|
||||
// REQUIRE(oss1.str() == "moduleid 0x5d\n");
|
||||
// proxy.Call("moduleid", {}, -1, GET, oss2);
|
||||
// REQUIRE(oss2.str() == "moduleid 0x5d\n");
|
||||
// proxy.Call("moduleid", {"0xffff"}, -1, PUT, oss3);
|
||||
// REQUIRE(oss3.str() == "moduleid 0xffff\n");
|
||||
// REQUIRE_THROWS(proxy.Call("moduleid", {"65536"}, -1, PUT));
|
||||
// for (int i = 0; i != det.size(); ++i) {
|
||||
// det.setModuleId(prev_val[i], {i});
|
||||
// }
|
||||
// } else {
|
||||
// REQUIRE_THROWS(proxy.Call("moduleid", {"0"}, -1, GET));
|
||||
// }
|
||||
// }
|
||||
|
||||
TEST_CASE("type", "[.cmd]") {
|
||||
Detector det;
|
||||
|
||||
Reference in New Issue
Block a user