Run clang-format on httplib.h and test.cc

Fixes formatting introduced in 199d7ee and d5f8858 that clang-format
18.1.3 (the version used by CI) disagrees with.
This commit is contained in:
yhirose
2026-09-07 16:29:08 -04:00
parent d5f8858731
commit 6303a99ce1
2 changed files with 33 additions and 34 deletions
+3 -4
View File
@@ -4603,8 +4603,8 @@ private:
};
template <class Rep, class Period>
inline void
WebSocket::set_read_timeout(const std::chrono::duration<Rep, Period> &duration) {
inline void WebSocket::set_read_timeout(
const std::chrono::duration<Rep, Period> &duration) {
detail::duration_to_sec_and_usec(
duration, [&](time_t sec, time_t usec) { set_read_timeout(sec, usec); });
}
@@ -6402,8 +6402,7 @@ inline ssize_t select_impl(socket_t sock, short events, time_t sec,
// A negative timeout waits forever, poll's own convention. 0 keeps meaning
// "return immediately", which callers here rely on to probe a socket.
auto timeout =
sec < 0 ? -1 : static_cast<int>(sec * 1000 + usec / 1000);
auto timeout = sec < 0 ? -1 : static_cast<int>(sec * 1000 + usec / 1000);
return handle_EINTR([&]() { return poll_wrapper(&pfd, 1, timeout); });
}
+30 -30
View File
@@ -22341,9 +22341,9 @@ TEST(WebSocketTest, RSVBitsMustBeZero) {
ws::Opcode opcode;
std::string payload;
bool fin;
EXPECT_EQ(ws::impl::read_websocket_frame(strm, opcode, payload, fin, false,
1024),
ws::impl::FrameRead::Fail);
EXPECT_EQ(
ws::impl::read_websocket_frame(strm, opcode, payload, fin, false, 1024),
ws::impl::FrameRead::Fail);
}
// RSV2 set (0x20)
@@ -22353,9 +22353,9 @@ TEST(WebSocketTest, RSVBitsMustBeZero) {
ws::Opcode opcode;
std::string payload;
bool fin;
EXPECT_EQ(ws::impl::read_websocket_frame(strm, opcode, payload, fin, false,
1024),
ws::impl::FrameRead::Fail);
EXPECT_EQ(
ws::impl::read_websocket_frame(strm, opcode, payload, fin, false, 1024),
ws::impl::FrameRead::Fail);
}
// RSV3 set (0x10)
@@ -22365,9 +22365,9 @@ TEST(WebSocketTest, RSVBitsMustBeZero) {
ws::Opcode opcode;
std::string payload;
bool fin;
EXPECT_EQ(ws::impl::read_websocket_frame(strm, opcode, payload, fin, false,
1024),
ws::impl::FrameRead::Fail);
EXPECT_EQ(
ws::impl::read_websocket_frame(strm, opcode, payload, fin, false, 1024),
ws::impl::FrameRead::Fail);
}
// No RSV bits set - should succeed
@@ -22377,9 +22377,9 @@ TEST(WebSocketTest, RSVBitsMustBeZero) {
ws::Opcode opcode;
std::string payload;
bool fin;
EXPECT_EQ(ws::impl::read_websocket_frame(strm, opcode, payload, fin, false,
1024),
ws::impl::FrameRead::Ok);
EXPECT_EQ(
ws::impl::read_websocket_frame(strm, opcode, payload, fin, false, 1024),
ws::impl::FrameRead::Ok);
EXPECT_EQ(ws::Opcode::Text, opcode);
EXPECT_EQ("Hello", payload);
EXPECT_TRUE(fin);
@@ -22400,9 +22400,9 @@ TEST(WebSocketTest, ControlFrameValidation) {
ws::Opcode opcode;
std::string payload;
bool fin;
EXPECT_EQ(ws::impl::read_websocket_frame(strm, opcode, payload, fin, false,
1024),
ws::impl::FrameRead::Fail);
EXPECT_EQ(
ws::impl::read_websocket_frame(strm, opcode, payload, fin, false, 1024),
ws::impl::FrameRead::Fail);
}
// Close with FIN=0 - must be rejected
@@ -22415,9 +22415,9 @@ TEST(WebSocketTest, ControlFrameValidation) {
ws::Opcode opcode;
std::string payload;
bool fin;
EXPECT_EQ(ws::impl::read_websocket_frame(strm, opcode, payload, fin, false,
1024),
ws::impl::FrameRead::Fail);
EXPECT_EQ(
ws::impl::read_websocket_frame(strm, opcode, payload, fin, false, 1024),
ws::impl::FrameRead::Fail);
}
// Ping with payload_len=126 (extended length) - must be rejected
@@ -22433,9 +22433,9 @@ TEST(WebSocketTest, ControlFrameValidation) {
ws::Opcode opcode;
std::string payload;
bool fin;
EXPECT_EQ(ws::impl::read_websocket_frame(strm, opcode, payload, fin, false,
1024),
ws::impl::FrameRead::Fail);
EXPECT_EQ(
ws::impl::read_websocket_frame(strm, opcode, payload, fin, false, 1024),
ws::impl::FrameRead::Fail);
}
// Ping with FIN=1 and payload_len=125 - should succeed
@@ -22449,9 +22449,9 @@ TEST(WebSocketTest, ControlFrameValidation) {
ws::Opcode opcode;
std::string payload;
bool fin;
EXPECT_EQ(ws::impl::read_websocket_frame(strm, opcode, payload, fin, false,
1024),
ws::impl::FrameRead::Ok);
EXPECT_EQ(
ws::impl::read_websocket_frame(strm, opcode, payload, fin, false, 1024),
ws::impl::FrameRead::Ok);
EXPECT_EQ(ws::Opcode::Ping, opcode);
EXPECT_EQ(125u, payload.size());
EXPECT_TRUE(fin);
@@ -22474,9 +22474,9 @@ TEST(WebSocketTest, PayloadLength64BitMSBMustBeZero) {
ws::Opcode opcode;
std::string payload;
bool fin;
EXPECT_EQ(ws::impl::read_websocket_frame(strm, opcode, payload, fin, false,
1024),
ws::impl::FrameRead::Fail);
EXPECT_EQ(
ws::impl::read_websocket_frame(strm, opcode, payload, fin, false, 1024),
ws::impl::FrameRead::Fail);
}
// MSB clear - should pass length parsing (will be rejected by max_len,
@@ -22493,9 +22493,9 @@ TEST(WebSocketTest, PayloadLength64BitMSBMustBeZero) {
ws::Opcode opcode;
std::string payload;
bool fin;
EXPECT_EQ(ws::impl::read_websocket_frame(strm, opcode, payload, fin, false,
1024),
ws::impl::FrameRead::Ok);
EXPECT_EQ(
ws::impl::read_websocket_frame(strm, opcode, payload, fin, false, 1024),
ws::impl::FrameRead::Ok);
EXPECT_EQ(ws::Opcode::Text, opcode);
EXPECT_EQ("abc", payload);
}