Skip to content

Commit

Permalink
code: use std:string instead of bits/basic_string.h
Browse files Browse the repository at this point in the history
Instantiate strings for assertion with `std:string` instead of
raw string literals to prevent clangd importing `bits/basic_string.h`
which leads to potential compiler errors.

Signed-off-by: Marco Hofstetter <[email protected]>
  • Loading branch information
mhofstetter committed Jan 7, 2025
1 parent 4653e38 commit 6cd8a15
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions tests/cilium_websocket_decap_integration_test.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <bits/basic_string.h>
#include <fmt/base.h>
#include <fmt/format.h>
#include <gtest/gtest-param-test.h>
Expand Down Expand Up @@ -290,7 +289,7 @@ TEST_P(CiliumWebSocketIntegrationTest, AcceptedWebSocket) {

// Masked frames
ASSERT_EQ(buf.length(), 0);
auto msg = "heello there\r\n"s;
auto msg = std::string{"heello there\r\n"};
unsigned char mask[4] = {0x12, 0x34, 0x56, 0x78};
auto masked = msg;
for (size_t i = 0; i < msg.length(); i++) {
Expand Down Expand Up @@ -318,7 +317,7 @@ TEST_P(CiliumWebSocketIntegrationTest, AcceptedWebSocket) {

// 2nd masked frame
ASSERT_EQ(buf.length(), 0);
auto msg2 = "hello there\r\n"s;
auto msg2 = std::string{"hello there\r\n"};
unsigned char mask2[4] = {0x90, 0xab, 0xcd, 0xef};
auto masked2 = msg2;
for (size_t i = 0; i < msg2.length(); i++) {
Expand Down
5 changes: 2 additions & 3 deletions tests/cilium_websocket_encap_integration_test.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <bits/basic_string.h>
#include <fmt/base.h>
#include <fmt/format.h>
#include <gtest/gtest-param-test.h>
Expand Down Expand Up @@ -392,7 +391,7 @@ TEST_P(CiliumWebSocketIntegrationTest, CiliumWebSocketLargeWrite) {
ASSERT_EQ(received_data.substr(frame_offset, 16 * 1024), data.substr(16 * 1024, 16 * 1024));

// writing data in one large chunk
ASSERT_TRUE(fake_upstream_connection->write("\x82\x7e\x80\x00"s));
ASSERT_TRUE(fake_upstream_connection->write(std::string{"\x82\x7e\x80\x00"}));
ASSERT_TRUE(fake_upstream_connection->write(data));
tcp_client->waitForData(data);
tcp_client->close();
Expand Down Expand Up @@ -448,7 +447,7 @@ TEST_P(CiliumWebSocketIntegrationTest, CiliumWebSocketDownstreamFlush) {

// writing data in one large chunk

ASSERT_TRUE(fake_upstream_connection->write("\x82\x7f\x03\x20\0\0"s));
ASSERT_TRUE(fake_upstream_connection->write(std::string{"\x82\x7f\x03\x20\0\0"}));
ASSERT_TRUE(fake_upstream_connection->write(data, true));

test_server_->waitForCounterGe("cluster.cluster1.upstream_flow_control_paused_reading_total", 1);
Expand Down

0 comments on commit 6cd8a15

Please sign in to comment.