clang format

This commit is contained in:
2021-10-19 14:49:43 +02:00
parent 3726ae3fd1
commit b39c64032d
66 changed files with 642 additions and 624 deletions

View File

@ -149,18 +149,18 @@ SCENARIO("Parsing strings with -h or --help", "[support]") {
}
}
TEST_CASE("Parse string with --help"){
TEST_CASE("Parse string with --help") {
CmdParser p;
p.Parse("list --help");
REQUIRE(p.isHelp()==true);
REQUIRE(p.command()=="list");
REQUIRE(p.isHelp() == true);
REQUIRE(p.command() == "list");
}
TEST_CASE("Parse string with -h"){
TEST_CASE("Parse string with -h") {
CmdParser p;
p.Parse("list -h");
REQUIRE(p.isHelp()==true);
REQUIRE(p.command()=="list");
REQUIRE(p.isHelp() == true);
REQUIRE(p.command() == "list");
}
TEST_CASE("Parsing consecutive strings resets not found det id") {
@ -272,9 +272,7 @@ TEST_CASE("Double digit id", "[support]") {
REQUIRE(p.arguments().empty());
}
TEST_CASE("Allows space between mod id and command"){
TEST_CASE("Allows space between mod id and command") {
CmdParser p;
p.Parse("7: exptime 0.5");
REQUIRE(p.detector_id() == 7);
@ -283,7 +281,7 @@ TEST_CASE("Allows space between mod id and command"){
REQUIRE(p.arguments()[0] == "0.5");
}
TEST_CASE("Allows space between mod id and command also without :"){
TEST_CASE("Allows space between mod id and command also without :") {
CmdParser p;
p.Parse("1 exptime 0.5");
REQUIRE(p.detector_id() == 1);
@ -292,7 +290,7 @@ TEST_CASE("Allows space between mod id and command also without :"){
REQUIRE(p.arguments()[0] == "0.5");
}
TEST_CASE("Allows space between mod id and command when detector id is used"){
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);
@ -302,7 +300,7 @@ TEST_CASE("Allows space between mod id and command when detector id is used"){
REQUIRE(p.arguments()[0] == "0.5");
}
TEST_CASE("Allows space between mod id and command with detector id and :"){
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);
@ -312,7 +310,7 @@ TEST_CASE("Allows space between mod id and command with detector id and :"){
REQUIRE(p.arguments()[0] == "0.5");
}
TEST_CASE("Parse receiver ID"){
TEST_CASE("Parse receiver ID") {
CmdParser p;
p.Parse("2-5:3 flowcontrol10g 1");
REQUIRE(p.detector_id() == 5);
@ -320,84 +318,81 @@ TEST_CASE("Parse receiver ID"){
REQUIRE(p.command() == "flowcontrol10g");
REQUIRE(p.arguments().size() == 1);
REQUIRE(p.arguments()[0] == "1");
REQUIRE(p.receiver_id()==3);
REQUIRE(p.receiver_id() == 3);
}
TEST_CASE("Parse receiver ID no det id"){
TEST_CASE("Parse receiver ID no det id") {
CmdParser p;
p.Parse("5:95 flowcontrol10g");
REQUIRE(p.detector_id() == 5);
REQUIRE(p.multi_id() == 0);
REQUIRE(p.command() == "flowcontrol10g");
REQUIRE(p.arguments().size() == 0);
REQUIRE(p.receiver_id()==95);
REQUIRE(p.receiver_id() == 95);
}
TEST_CASE("Det id but no mod id"){
TEST_CASE("Det id but no mod id") {
CmdParser p;
p.Parse("1-exptime");
REQUIRE(p.detector_id() == -1); //not there
REQUIRE(p.detector_id() == -1); // not there
REQUIRE(p.multi_id() == 1);
REQUIRE(p.command() == "exptime");
}
TEST_CASE("Det id but no mod id but with space after -"){
TEST_CASE("Det id but no mod id but with space after -") {
CmdParser p;
p.Parse("1- exptime");
REQUIRE(p.detector_id() == -1); //not there
REQUIRE(p.detector_id() == -1); // not there
REQUIRE(p.multi_id() == 1);
REQUIRE(p.command() == "exptime");
}
TEST_CASE("Parse receiver ID no det id no mod"){
TEST_CASE("Parse receiver ID no det id no mod") {
CmdParser p;
p.Parse(":95 flowcontrol10g");
REQUIRE(p.detector_id() == -1); //not there
REQUIRE(p.detector_id() == -1); // not there
REQUIRE(p.multi_id() == 0);
REQUIRE(p.command() == "flowcontrol10g");
REQUIRE(p.arguments().size() == 0);
REQUIRE(p.receiver_id()==95);
REQUIRE(p.receiver_id() == 95);
}
TEST_CASE("Parse mod and receiver id"){
TEST_CASE("Parse mod and receiver id") {
CmdParser p;
p.Parse("1:3 exptime");
REQUIRE(p.detector_id() == 1);
REQUIRE(p.receiver_id()==3);
REQUIRE(p.detector_id() == 1);
REQUIRE(p.receiver_id() == 3);
REQUIRE(p.command() == "exptime");
}
TEST_CASE("Det id but no no mod"){
TEST_CASE("Det id but no no mod") {
CmdParser p;
p.Parse("2-:35 exptime");
REQUIRE(p.detector_id() == -1);
REQUIRE(p.receiver_id()==35);
REQUIRE(p.detector_id() == -1);
REQUIRE(p.receiver_id() == 35);
REQUIRE(p.multi_id() == 2);
REQUIRE(p.command() == "exptime");
}
TEST_CASE("All stuff"){
TEST_CASE("All stuff") {
CmdParser p;
p.Parse("3-4:2 exptime");
REQUIRE(p.detector_id() == 4);
REQUIRE(p.receiver_id()==2);
REQUIRE(p.detector_id() == 4);
REQUIRE(p.receiver_id() == 2);
REQUIRE(p.multi_id() == 3);
REQUIRE(p.command() == "exptime");
}
TEST_CASE("Parse a command that has -h in it"){
TEST_CASE("Parse a command that has -h in it") {
CmdParser p;
p.Parse("1-hostname somepc");
REQUIRE(p.multi_id() == 1);
REQUIRE(p.command() == "hostname");
REQUIRE(p.arguments().size() == 1);
REQUIRE(p.arguments()[0]== "somepc");
REQUIRE(p.arguments()[0] == "somepc");
}
TEST_CASE("Parse a command in the form 0-1 command"){
TEST_CASE("Parse a command in the form 0-1 command") {
CmdParser p;
p.Parse("3-5 exptime");
REQUIRE(p.multi_id() == 3);
@ -405,7 +400,7 @@ TEST_CASE("Parse a command in the form 0-1 command"){
REQUIRE(p.command() == "exptime");
}
TEST_CASE("Parse a command in the form 0-1:command"){
TEST_CASE("Parse a command in the form 0-1:command") {
CmdParser p;
p.Parse("3-5:exptime");
REQUIRE(p.multi_id() == 3);

View File

@ -289,7 +289,8 @@ TEST_CASE("comp_disable_time", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU && det.getChipVersion().squash()*10 == 11) {
if (det_type == defs::JUNGFRAU &&
det.getChipVersion().squash() * 10 == 11) {
auto prev_val = det.getComparatorDisableTime();
{
std::ostringstream oss;
@ -321,7 +322,7 @@ TEST_CASE("storagecells", "[.cmd]") {
auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU) {
// chip version 1.0
if (det.getChipVersion().squash()*10 == 10) {
if (det.getChipVersion().squash() * 10 == 10) {
auto prev_val = det.getNumberOfAdditionalStorageCells().tsquash(
"inconsistent #additional storage cells to test");
{
@ -346,11 +347,11 @@ TEST_CASE("storagecells", "[.cmd]") {
}
REQUIRE_THROWS(proxy.Call("storagecells", {"16"}, -1, PUT));
det.setNumberOfAdditionalStorageCells(prev_val);
}
}
// chip version 1.1
else {
// cannot set number of addl. storage cells
REQUIRE_THROWS(proxy.Call("storagecells", {"1"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("storagecells", {"1"}, -1, PUT));
}
} else {
REQUIRE_THROWS(proxy.Call("storagecells", {}, -1, GET));
@ -370,11 +371,11 @@ TEST_CASE("storagecell_start", "[.cmd]") {
REQUIRE(oss.str() == "storagecell_start 1\n");
}
// chip version 1.0
if (det.getChipVersion().squash()*10 == 10) {
if (det.getChipVersion().squash() * 10 == 10) {
std::ostringstream oss;
proxy.Call("storagecell_start", {"15"}, -1, PUT, oss);
REQUIRE(oss.str() == "storagecell_start 15\n");
}
}
// chip version 1.1
else {
// max is 3
@ -409,7 +410,7 @@ TEST_CASE("storagecell_delay", "[.cmd]") {
auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU) {
// chip version 1.0
if (det.getChipVersion().squash()*10 == 10) {
if (det.getChipVersion().squash() * 10 == 10) {
auto prev_val = det.getStorageCellDelay();
{
std::ostringstream oss;
@ -426,15 +427,17 @@ TEST_CASE("storagecell_delay", "[.cmd]") {
proxy.Call("storagecell_delay", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "storagecell_delay 0\n");
}
REQUIRE_THROWS(proxy.Call("storagecell_delay", {"1638376ns"}, -1, PUT));
REQUIRE_THROWS(
proxy.Call("storagecell_delay", {"1638376ns"}, -1, PUT));
for (int i = 0; i != det.size(); ++i) {
det.setStorageCellDelay(prev_val[i], {i});
}
}
}
// chip version 1.1
else {
// cannot set storage cell delay
REQUIRE_THROWS(proxy.Call("storagecell_delay", {"1.62ms"}, -1, PUT));
REQUIRE_THROWS(
proxy.Call("storagecell_delay", {"1.62ms"}, -1, PUT));
}
} else {
REQUIRE_THROWS(proxy.Call("storagecell_delay", {}, -1, GET));

View File

@ -347,7 +347,8 @@ TEST_CASE("thresholdnotb", "[.cmd]") {
std::string senergy = std::to_string(prev_energies[0]);
std::ostringstream oss1, oss2;
proxy.Call("thresholdnotb", {senergy, "standard"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "thresholdnotb [" + senergy + ", standard]\n");
REQUIRE(oss1.str() ==
"thresholdnotb [" + senergy + ", standard]\n");
proxy.Call("threshold", {}, -1, GET, oss2);
REQUIRE(oss2.str() == "threshold " + senergy + "\n");
REQUIRE_THROWS(proxy.Call("thresholdnotb",
@ -895,12 +896,15 @@ TEST_CASE("readoutspeed", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER || det_type == defs::JUNGFRAU || det_type == defs::GOTTHARD2) {
if (det_type == defs::EIGER || det_type == defs::JUNGFRAU ||
det_type == defs::GOTTHARD2) {
auto prev_val = det.getReadoutSpeed();
// full speed for jungfrau only works for new boards (chipv1.1 is with new board [hw1.0 and chipv1.0 not tested here])
if ((det_type == defs::JUNGFRAU && det.getChipVersion().squash() * 10 == 11) || (det_type == defs::EIGER))
{
// full speed for jungfrau only works for new boards (chipv1.1 is with
// new board [hw1.0 and chipv1.0 not tested here])
if ((det_type == defs::JUNGFRAU &&
det.getChipVersion().squash() * 10 == 11) ||
(det_type == defs::EIGER)) {
std::ostringstream oss1, oss2, oss3, oss4;
proxy.Call("readoutspeed", {"0"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "readoutspeed full_speed\n");
@ -911,7 +915,7 @@ TEST_CASE("readoutspeed", "[.cmd]") {
proxy.Call("readoutspeed", {}, -1, GET, oss4);
REQUIRE(oss4.str() == "readoutspeed full_speed\n");
}
if (det_type == defs::EIGER || det_type == defs::JUNGFRAU) {
{
std::ostringstream oss1, oss2, oss3, oss4;
@ -954,10 +958,11 @@ TEST_CASE("readoutspeed", "[.cmd]") {
REQUIRE(oss1.str() == "readoutspeed 144\n");
proxy.Call("readoutspeed", {}, -1, GET, oss2);
REQUIRE(oss2.str() == "readoutspeed 144\n");
}
}
REQUIRE_THROWS(proxy.Call("readoutspeed", {"full_speed"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("readoutspeed", {"half_speed"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("readoutspeed", {"quarter_speed"}, -1, PUT));
REQUIRE_THROWS(
proxy.Call("readoutspeed", {"quarter_speed"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("readoutspeed", {"0"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("readoutspeed", {"1"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("readoutspeed", {"2"}, -1, PUT));
@ -976,8 +981,8 @@ TEST_CASE("readoutspeedlist", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::GOTTHARD2 || det_type == defs::JUNGFRAU || det_type == defs::EIGER)
{
if (det_type == defs::GOTTHARD2 || det_type == defs::JUNGFRAU ||
det_type == defs::EIGER) {
REQUIRE_NOTHROW(proxy.Call("readoutspeedlist", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("readoutspeedlist", {}, -1, PUT));
} else {
@ -1795,33 +1800,30 @@ TEST_CASE("defaultdac", "[.cmd]") {
std::ostringstream oss;
proxy.Call("defaultdac", {dacname}, -1, GET, oss);
REQUIRE(oss.str() == std::string("defaultdac ") + dacname +
std::string(" 1000\n"));
std::string(" 1000\n"));
}
for (int i = 0; i != det.size(); ++i) {
det.setDefaultDac(it, prev_val[i], {i});
}
}
if (det_type == defs::JUNGFRAU) {
std::vector<defs::dacIndex> daclist = {defs::VREF_PRECH, defs::VREF_DS,
defs::VREF_COMP};
std::vector<defs::dacIndex> daclist = {
defs::VREF_PRECH, defs::VREF_DS, defs::VREF_COMP};
for (auto it : daclist) {
auto dacname = sls::ToString(it);
auto prev_val = det.getDefaultDac(it, defs::GAIN0);
{
std::ostringstream oss;
proxy.Call("defaultdac", {dacname, "1000", "gain0"}, -1,
PUT, oss);
REQUIRE(oss.str() ==
std::string("defaultdac ") + dacname +
std::string(" gain0 1000\n"));
PUT, oss);
REQUIRE(oss.str() == std::string("defaultdac ") + dacname +
std::string(" gain0 1000\n"));
}
{
std::ostringstream oss;
proxy.Call("defaultdac", {dacname, "gain0"}, -1, GET,
oss);
REQUIRE(oss.str() ==
std::string("defaultdac ") + dacname +
std::string(" gain0 1000\n"));
proxy.Call("defaultdac", {dacname, "gain0"}, -1, GET, oss);
REQUIRE(oss.str() == std::string("defaultdac ") + dacname +
std::string(" gain0 1000\n"));
}
for (int i = 0; i != det.size(); ++i) {
det.setDefaultDac(it, prev_val[i], defs::GAIN0, {i});
@ -1829,7 +1831,7 @@ TEST_CASE("defaultdac", "[.cmd]") {
}
}
} else {
REQUIRE_THROWS(proxy.Call("defaultdac", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("defaultdac", {}, -1, GET));
}
}
@ -1927,7 +1929,8 @@ TEST_CASE("blockingtrigger", "[.cmd]") {
proxy.Call("blockingtrigger", {}, -1, PUT, oss);
REQUIRE(oss.str() == "blockingtrigger successful\n");
}
if (det.isVirtualDetectorServer().tsquash("inconsistent virtual detectors")) {
if (det.isVirtualDetectorServer().tsquash(
"inconsistent virtual detectors")) {
std::this_thread::sleep_for(std::chrono::seconds(2));
}
auto currentfnum =
@ -2286,7 +2289,6 @@ TEST_CASE("udp_numdst", "[.cmd]") {
}
}
TEST_CASE("udp_cleardst", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);

View File

@ -5,21 +5,21 @@
using sls::Pattern;
TEST_CASE("Pattern is default constructable and has zeroed fields"){
TEST_CASE("Pattern is default constructable and has zeroed fields") {
Pattern p;
for (int i = 0; i!=MAX_PATTERN_LENGTH; ++i)
for (int i = 0; i != MAX_PATTERN_LENGTH; ++i)
REQUIRE(p.data()->word[i] == 0);
REQUIRE(p.data()->ioctrl == 0);
}
TEST_CASE("Copy construct pattern"){
TEST_CASE("Copy construct pattern") {
Pattern p;
p.data()->loop[0] = 7;
Pattern p1(p);
REQUIRE(p1.data()->loop[0] == 7);
}
TEST_CASE("Compare patterns"){
TEST_CASE("Compare patterns") {
Pattern p;
Pattern p1;
REQUIRE(p == p1);
@ -27,7 +27,3 @@ TEST_CASE("Compare patterns"){
p1.data()->word[500] = 1;
REQUIRE_FALSE(p == p1);
}

View File

@ -21,8 +21,8 @@ TEST_CASE("Create SharedMemory read and write", "[detector]") {
SharedMemory<Data> shm(shm_id, -1);
shm.CreateSharedMemory();
CHECK(shm.GetName() ==
std::string("/slsDetectorPackage_detector_") + std::to_string(shm_id));
CHECK(shm.GetName() == std::string("/slsDetectorPackage_detector_") +
std::to_string(shm_id));
shm()->x = 3;
shm()->y = 5.7;
@ -92,8 +92,8 @@ TEST_CASE("Open two shared memories to the same place", "[detector]") {
TEST_CASE("Move SharedMemory", "[detector]") {
SharedMemory<Data> shm(shm_id, -1);
CHECK(shm.GetName() ==
std::string("/slsDetectorPackage_detector_") + std::to_string(shm_id));
CHECK(shm.GetName() == std::string("/slsDetectorPackage_detector_") +
std::to_string(shm_id));
shm.CreateSharedMemory();
shm()->x = 9;
@ -106,8 +106,8 @@ TEST_CASE("Move SharedMemory", "[detector]") {
CHECK(shm() == nullptr);
CHECK(shm.size() == 0);
CHECK(shm2.GetName() ==
std::string("/slsDetectorPackage_detector_") + std::to_string(shm_id));
CHECK(shm2.GetName() == std::string("/slsDetectorPackage_detector_") +
std::to_string(shm_id));
shm2.RemoveSharedMemory();
}