diff --git a/slsSupportLib/include/sls/sls_detector_defs.h b/slsSupportLib/include/sls/sls_detector_defs.h index 192cbf3ce..a5ccb2566 100644 --- a/slsSupportLib/include/sls/sls_detector_defs.h +++ b/slsSupportLib/include/sls/sls_detector_defs.h @@ -804,7 +804,7 @@ typedef struct { } sls_detector_module &operator=(const sls_detector_module &other) { - if(this == &other) + if (this == &other) return *this; delete[] dacs; delete[] chanregs; diff --git a/slsSupportLib/src/DataSocket.cpp b/slsSupportLib/src/DataSocket.cpp index a8b4d2bfd..7979f9d70 100644 --- a/slsSupportLib/src/DataSocket.cpp +++ b/slsSupportLib/src/DataSocket.cpp @@ -113,10 +113,9 @@ int DataSocket::Send(const void *buffer, size_t size) { #endif Timer timer; while (bytes_sent < bytes_expected) { - this_send = ::send( - getSocketId(), - reinterpret_cast(buffer) + bytes_sent, - bytes_expected - bytes_sent, send_flags); + this_send = ::send(getSocketId(), + reinterpret_cast(buffer) + bytes_sent, + bytes_expected - bytes_sent, send_flags); if (this_send < 0 && errno == EINTR) continue; // interrupted by a signal, retry if (this_send <= 0) diff --git a/slsSupportLib/src/string_utils.cpp b/slsSupportLib/src/string_utils.cpp index 04c44ca81..2a7684bcc 100644 --- a/slsSupportLib/src/string_utils.cpp +++ b/slsSupportLib/src/string_utils.cpp @@ -69,7 +69,7 @@ std::pair ParseHostPort(const std::string &s) { std::string to_lower(const std::string &s) { std::string result = s; std::transform(result.begin(), result.end(), result.begin(), - [](unsigned char c) { return std::tolower(c); }); + [](unsigned char c) { return std::tolower(c); }); return result; } diff --git a/slsSupportLib/tests/test-Sockets.cpp b/slsSupportLib/tests/test-Sockets.cpp index 211df5858..897ed4e65 100644 --- a/slsSupportLib/tests/test-Sockets.cpp +++ b/slsSupportLib/tests/test-Sockets.cpp @@ -30,11 +30,8 @@ std::vector echo_server(uint16_t port, size_t bytes_to_send, std::vector buffer(100, '\0'); s.Receive(buffer.data(), buffer.size()); - if (port==1960){ - struct linger ling = { - .l_onoff = 1, - .l_linger = 0 - }; + if (port == 1960) { + struct linger ling = {.l_onoff = 1, .l_linger = 0}; auto fd = s.getSocketId(); setsockopt(fd, SOL_SOCKET, SO_LINGER, &ling, sizeof ling); @@ -199,7 +196,6 @@ TEST_CASE("Receiving with a socket error throws and reports the error", CHECK_THAT(error_message, Catch::Matchers::Contains("read error:")); } - TEST_CASE("Socket crash?", "[support]") { std::vector received_message(100, '\0'); std::vector sent_message(100, '\0'); @@ -211,25 +207,20 @@ TEST_CASE("Socket crash?", "[support]") { std::this_thread::sleep_for(std::chrono::milliseconds(100)); auto client = DetectorSocket("localhost", 1960); client.Send(sent_message.data(), sent_message.size()); - - - REQUIRE_THROWS(client.Receive(received_message.data(), received_message.size())); - - //Now try to send more - // client.Send(sent_message.data(), sent_message.size()); - + REQUIRE_THROWS( + client.Receive(received_message.data(), received_message.size())); + // Now try to send more + // client.Send(sent_message.data(), sent_message.size()); } - TEST_CASE("ClientSocket throws on invalid hostname", "[support]") { CHECK_THROWS(ReceiverSocket("invalidhostname", 1950)); CHECK_THROWS(DetectorSocket("invalidhostname", 1950)); CHECK_THROWS(GuiSocket("invalidhostname", 1950)); } - TEST_CASE("Using DetectorSocket to talk to a Server Socket", "[support]") { constexpr uint16_t port = 1961; constexpr int fnum = F_GET_DETECTOR_TYPE; @@ -240,9 +231,8 @@ TEST_CASE("Using DetectorSocket to talk to a Server Socket", "[support]") { auto client = DetectorSocket("localhost", port); int retval = 0; - int ret = - client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, - sizeof(retval)); + int ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, + sizeof(retval)); client.close(); auto server_received = s.get(); @@ -294,8 +284,8 @@ TEST_CASE("Client cannot send the expected number of bytes", "[support]") { // Server accepts but never reads; it stays open until we tell it the // client is done, so it cannot close mid-transfer. std::atomic client_done{false}; - auto s = std::async(std::launch::async, non_reading_server, port, - &client_done); + auto s = + std::async(std::launch::async, non_reading_server, port, &client_done); std::this_thread::sleep_for(std::chrono::milliseconds(100)); auto client = DetectorSocket("localhost", port); diff --git a/slsSupportLib/tests/test-string_utils.cpp b/slsSupportLib/tests/test-string_utils.cpp index 21200eca9..58f431f54 100644 --- a/slsSupportLib/tests/test-string_utils.cpp +++ b/slsSupportLib/tests/test-string_utils.cpp @@ -148,8 +148,6 @@ TEST_CASE("to_lower does not modify the original string") { REQUIRE(original == "MixedCase"); } - - // TEST_CASE("concat things not being strings") } // namespace sls