Use include <cstring> and std::memcpy etc

This commit is contained in:
2025-08-23 20:24:50 -04:00
parent 18a1b30d9f
commit a2e1fd5ba1
8 changed files with 56 additions and 22 deletions

View File

@@ -3,6 +3,7 @@
#include "connection.hpp"
#include "perfetto_categories.hpp"
#include "server.hpp"
#include <cstring>
#include <doctest/doctest.h>
#include <thread>
@@ -71,9 +72,9 @@ TEST_CASE(
const char *test_message = "Hello, World!";
ssize_t bytes_written;
do {
bytes_written = write(client_fd, test_message, strlen(test_message));
bytes_written = write(client_fd, test_message, std::strlen(test_message));
} while (bytes_written == -1 && errno == EINTR);
REQUIRE(bytes_written == strlen(test_message));
REQUIRE(bytes_written == std::strlen(test_message));
// Read the echoed response
char buffer[1024] = {0};
@@ -84,7 +85,7 @@ TEST_CASE(
if (bytes_read == -1) {
perror("read failed");
}
REQUIRE(bytes_read == strlen(test_message));
REQUIRE(bytes_read == std::strlen(test_message));
// Verify we got back exactly what we sent
CHECK(std::string(buffer, bytes_read) == std::string(test_message));
@@ -93,7 +94,7 @@ TEST_CASE(
int e = close(client_fd);
if (e == -1 && errno != EINTR) {
perror("close client_fd");
abort();
std::abort();
}
server->shutdown();
server_thread.join();