Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
Do a clang-format -i pass
Browse files Browse the repository at this point in the history
  • Loading branch information
bassosimone committed May 13, 2018
1 parent 53814d1 commit 5d04324
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 55 deletions.
6 changes: 3 additions & 3 deletions curlx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static size_t curl_callback(char *ptr, size_t size, size_t nmemb,
return nmemb;
}

} // extern "C"
} // extern "C"

namespace measurement_kit {
namespace libndt {
Expand All @@ -42,8 +42,8 @@ void CurlDeleter::operator()(CURL *handle) noexcept {

Curl::Curl() noexcept {}

bool Curl::method_get(const std::string &url, long timeout,
std::string *body, std::string *err) noexcept {
bool Curl::method_get(const std::string &url, long timeout, std::string *body,
std::string *err) noexcept {
if (body == nullptr || err == nullptr) {
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions curlx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class Curl {

Curl() noexcept;

bool method_get(const std::string &url, long timeout,
std::string *body, std::string *err) noexcept;
bool method_get(const std::string &url, long timeout, std::string *body,
std::string *err) noexcept;

// Mid-level API

Expand Down
4 changes: 1 addition & 3 deletions curlx_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ TEST_CASE("Curl::method_get() deals with Curl::setopt_timeout() failure") {
class FailPerform : public libndt::Curl {
public:
using libndt::Curl::Curl;
virtual CURLcode perform() noexcept override {
return CURLE_AGAIN;
}
virtual CURLcode perform() noexcept override { return CURLE_AGAIN; }
};

TEST_CASE("Curl::method_get() deals with Curl::perform() failure") {
Expand Down
2 changes: 1 addition & 1 deletion libndt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include <sys/socket.h>

#include <errno.h>
#include <netdb.h>
#include <limits.h>
#include <netdb.h>
#include <unistd.h>
#endif

Expand Down
2 changes: 1 addition & 1 deletion libndt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#endif

#include <stddef.h>
#include <stdint.h> // IWYU pragma: export
#include <stdint.h> // IWYU pragma: export

#include <map>
#include <memory>
Expand Down
64 changes: 22 additions & 42 deletions libndt_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -765,8 +765,7 @@ class RecvNonTestMsgDuringDownload : public libndt::Client {
}
};

TEST_CASE(
"Client::run_download() deals with non-msg_test_msg receipt") {
TEST_CASE("Client::run_download() deals with non-msg_test_msg receipt") {
RecvNonTestMsgDuringDownload client;
client.settings.verbosity = libndt::verbosity_quiet;
REQUIRE(client.run_download() == false);
Expand Down Expand Up @@ -794,13 +793,10 @@ class FailMsgWriteDuringDownload : public libndt::Client {
*code = libndt::msg_test_msg;
return true;
}
bool msg_write(uint8_t, std::string &&) noexcept override {
return false;
}
bool msg_write(uint8_t, std::string &&) noexcept override { return false; }
};

TEST_CASE(
"Client::run_download() deals with Client::msg_write() failure") {
TEST_CASE("Client::run_download() deals with Client::msg_write() failure") {
FailMsgWriteDuringDownload client;
client.settings.verbosity = libndt::verbosity_quiet;
REQUIRE(client.run_download() == false);
Expand Down Expand Up @@ -828,16 +824,11 @@ class FailMsgReadDuringDownload : public libndt::Client {
*code = libndt::msg_test_msg;
return true;
}
bool msg_write(uint8_t, std::string &&) noexcept override {
return true;
}
bool msg_read(uint8_t *, std::string *) noexcept override {
return false;
}
bool msg_write(uint8_t, std::string &&) noexcept override { return true; }
bool msg_read(uint8_t *, std::string *) noexcept override { return false; }
};

TEST_CASE(
"Client::run_download() deals with Client::msg_read() failure") {
TEST_CASE("Client::run_download() deals with Client::msg_read() failure") {
FailMsgReadDuringDownload client;
client.settings.verbosity = libndt::verbosity_quiet;
REQUIRE(client.run_download() == false);
Expand Down Expand Up @@ -865,17 +856,14 @@ class RecvNonTestOrLogoutMsgDuringDownload : public libndt::Client {
*code = libndt::msg_test_msg;
return true;
}
bool msg_write(uint8_t, std::string &&) noexcept override {
return true;
}
bool msg_write(uint8_t, std::string &&) noexcept override { return true; }
bool msg_read(uint8_t *code, std::string *) noexcept override {
*code = libndt::msg_login;
return true;
}
};

TEST_CASE(
"Client::run_download() deals with non-logout-or-test msg") {
TEST_CASE("Client::run_download() deals with non-logout-or-test msg") {
RecvNonTestOrLogoutMsgDuringDownload client;
client.settings.verbosity = libndt::verbosity_quiet;
REQUIRE(client.run_download() == false);
Expand Down Expand Up @@ -903,18 +891,15 @@ class FailEmitResultDuringDownload : public libndt::Client {
*code = libndt::msg_test_msg;
return true;
}
bool msg_write(uint8_t, std::string &&) noexcept override {
return true;
}
bool msg_write(uint8_t, std::string &&) noexcept override { return true; }
bool msg_read(uint8_t *code, std::string *s) noexcept override {
*code = libndt::msg_test_msg;
*s = "antani-antani"; // Causes emit_result() to fail
*s = "antani-antani"; // Causes emit_result() to fail
return true;
}
};

TEST_CASE(
"Client::run_download() deals with emit_result() failure") {
TEST_CASE("Client::run_download() deals with emit_result() failure") {
FailEmitResultDuringDownload client;
client.settings.verbosity = libndt::verbosity_quiet;
REQUIRE(client.run_download() == false);
Expand Down Expand Up @@ -942,18 +927,15 @@ class TooManyTestMsgsDuringDownload : public libndt::Client {
*code = libndt::msg_test_msg;
return true;
}
bool msg_write(uint8_t, std::string &&) noexcept override {
return true;
}
bool msg_write(uint8_t, std::string &&) noexcept override { return true; }
bool msg_read(uint8_t *code, std::string *s) noexcept override {
*code = libndt::msg_test_msg;
*s = "antani:antani"; // Accepted by emit_result()
*s = "antani:antani"; // Accepted by emit_result()
return true;
}
};

TEST_CASE(
"Client::run_download() deals with too many results messages") {
TEST_CASE("Client::run_download() deals with too many results messages") {
TooManyTestMsgsDuringDownload client;
client.settings.verbosity = libndt::verbosity_quiet;
REQUIRE(client.run_download() == false);
Expand Down Expand Up @@ -994,9 +976,7 @@ class FailMsgWriteDuringMeta : public libndt::Client {
public:
using libndt::Client::Client;
bool msg_expect_empty(uint8_t) noexcept override { return true; }
bool msg_write(uint8_t, std::string &&) noexcept override {
return false;
}
bool msg_write(uint8_t, std::string &&) noexcept override { return false; }
};

TEST_CASE("Client::run_meta() deals with Client::msg_write() failure") {
Expand All @@ -1009,9 +989,7 @@ class FailFinalMsgWriteDuringMeta : public libndt::Client {
public:
using libndt::Client::Client;
bool msg_expect_empty(uint8_t) noexcept override { return true; }
bool msg_write(uint8_t, std::string &&s) noexcept override {
return s != "";
}
bool msg_write(uint8_t, std::string &&s) noexcept override { return s != ""; }
};

TEST_CASE("Client::run_meta() deals with final Client::msg_write() failure") {
Expand Down Expand Up @@ -1077,7 +1055,7 @@ TEST_CASE(
}

TEST_CASE("Client::run_upload() deals with Client::select() failure") {
FailSelectDuringDownload client; // Works also for upload phase
FailSelectDuringDownload client; // Works also for upload phase
client.settings.verbosity = libndt::verbosity_quiet;
REQUIRE(client.run_upload() == false);
}
Expand All @@ -1099,7 +1077,7 @@ class FailSendDuringUpload : public libndt::Client {
}
libndt::Ssize send(libndt::Socket, const void *,
libndt::Size) noexcept override {
set_last_error(0); // Anything not EPIPE would cause a failure
set_last_error(0); // Anything not EPIPE would cause a failure
return -1;
}
};
Expand Down Expand Up @@ -1501,7 +1479,9 @@ TEST_CASE("Client::msg_expect() deals with unexpected message") {
class FailMsgReadLegacy : public libndt::Client {
public:
using libndt::Client::Client;
bool msg_read_legacy(uint8_t *, std::string *) noexcept override { return false; }
bool msg_read_legacy(uint8_t *, std::string *) noexcept override {
return false;
}
};

TEST_CASE("Client::msg_read() deals with Client::msg_read_legacy() failure") {
Expand Down Expand Up @@ -1633,7 +1613,7 @@ TEST_CASE("Client::get_last_error() works as expected") {
libndt::Client client;
client.set_last_error(OS_EINVAL);
REQUIRE(client.get_last_error() == OS_EINVAL);
client.set_last_error(0); // clear
client.set_last_error(0); // clear
}

// Client::recv() tests
Expand Down
5 changes: 2 additions & 3 deletions strtonum.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
extern "C" {
#endif

long long
strtonum(const char *numstr, long long minval, long long maxval,
const char **errstrp);
long long strtonum(const char *numstr, long long minval, long long maxval,
const char **errstrp);

#ifdef __cplusplus
}
Expand Down

0 comments on commit 5d04324

Please sign in to comment.