Skip to content

Commit 3668ad1

Browse files
committed
Fix cpplint issues in test files
- Replace static global strings with function-static pattern - Change 'long' to 'int64_t' for http_code variables - Add missing #include <utility> for std::move
1 parent 2434473 commit 3668ad1

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

test/integ/basic.cpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2827,19 +2827,27 @@ LT_BEGIN_AUTO_TEST(basic_suite, get_arg_flat_first_value)
28272827
LT_END_AUTO_TEST(get_arg_flat_first_value)
28282828

28292829
// Test access and error log callbacks
2830-
static std::string access_log_msg;
2831-
static std::string error_log_msg;
2830+
struct LogCapture {
2831+
static std::string& access_log_msg() {
2832+
static std::string msg;
2833+
return msg;
2834+
}
2835+
static std::string& error_log_msg() {
2836+
static std::string msg;
2837+
return msg;
2838+
}
2839+
};
28322840

28332841
void test_access_logger(const std::string& msg) {
2834-
access_log_msg = msg;
2842+
LogCapture::access_log_msg() = msg;
28352843
}
28362844

28372845
void test_error_logger(const std::string& msg) {
2838-
error_log_msg = msg;
2846+
LogCapture::error_log_msg() = msg;
28392847
}
28402848

28412849
LT_BEGIN_AUTO_TEST(basic_suite, log_access_callback)
2842-
access_log_msg.clear();
2850+
LogCapture::access_log_msg().clear();
28432851

28442852
webserver ws2 = create_webserver(PORT + 70)
28452853
.log_access(test_access_logger);
@@ -2861,8 +2869,8 @@ LT_BEGIN_AUTO_TEST(basic_suite, log_access_callback)
28612869
LT_CHECK_EQ(s, "OK");
28622870

28632871
// The access log should have been called with the request info
2864-
LT_CHECK_EQ(access_log_msg.find("/logtest") != std::string::npos, true);
2865-
LT_CHECK_EQ(access_log_msg.find("METHOD") != std::string::npos, true);
2872+
LT_CHECK_EQ(LogCapture::access_log_msg().find("/logtest") != std::string::npos, true);
2873+
LT_CHECK_EQ(LogCapture::access_log_msg().find("METHOD") != std::string::npos, true);
28662874

28672875
curl_easy_cleanup(curl);
28682876
ws2.stop();
@@ -2964,7 +2972,7 @@ LT_BEGIN_AUTO_TEST(basic_suite, default_render_method)
29642972
{
29652973
curl_global_init(CURL_GLOBAL_ALL);
29662974
string s;
2967-
long http_code = 0;
2975+
int64_t http_code = 0;
29682976
CURL *curl = curl_easy_init();
29692977
CURLcode res;
29702978
std::string url = "http://localhost:" + std::to_string(PORT + 73) + "/empty";
@@ -3144,7 +3152,7 @@ LT_BEGIN_AUTO_TEST(basic_suite, custom_internal_error_resource)
31443152

31453153
curl_global_init(CURL_GLOBAL_ALL);
31463154
string s;
3147-
long http_code = 0;
3155+
int64_t http_code = 0;
31483156
CURL *curl = curl_easy_init();
31493157
CURLcode res;
31503158
std::string url = "http://localhost:" + std::to_string(PORT + 76) + "/throw";

test/unit/create_webserver_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include <memory>
2222
#include <string>
23+
#include <utility>
2324
#include <vector>
2425

2526
#include "./httpserver.hpp"

0 commit comments

Comments
 (0)