fix: address 8-bit output re-review findings
CI / lint (pull_request) Successful in 10s
CI / sanitizers (address) (pull_request) Successful in 37s
CI / sanitizers (undefined) (pull_request) Successful in 37s
CI / fuzz-build (pull_request) Successful in 14s
CI / coverage (pull_request) Successful in 31s
CI / build-and-test (pull_request) Successful in 1m15s
CI / valgrind (pull_request) Successful in 33s
CI / lint (pull_request) Successful in 10s
CI / sanitizers (address) (pull_request) Successful in 37s
CI / sanitizers (undefined) (pull_request) Successful in 37s
CI / fuzz-build (pull_request) Successful in 14s
CI / coverage (pull_request) Successful in 31s
CI / build-and-test (pull_request) Successful in 1m15s
CI / valgrind (pull_request) Successful in 33s
This commit is contained in:
@@ -1,8 +1,27 @@
|
||||
#include "test_shared_utils.h"
|
||||
#include "utils.h"
|
||||
#include "protocol.h"
|
||||
#include "test_utils.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <threads.h>
|
||||
|
||||
typedef struct {
|
||||
bool eight_bit_output;
|
||||
const char* expected;
|
||||
int failed;
|
||||
} EscapeThreadArgs;
|
||||
|
||||
static int escape_thread(void* arg) {
|
||||
EscapeThreadArgs* args = arg;
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
char* escaped = output_escape("x\xc3\xa9\n", args->eight_bit_output);
|
||||
if (!escaped || strcmp(escaped, args->expected) != 0)
|
||||
args->failed = 1;
|
||||
free(escaped);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void test_shared_utils() {
|
||||
char high_bit[] = {'a', (char)0xc3, (char)0xa9, '\n', '\0'};
|
||||
@@ -13,6 +32,26 @@ void test_shared_utils() {
|
||||
EXPECT_EQ_STR(escaped, "a\xc3\xa9\\#012");
|
||||
free(escaped);
|
||||
|
||||
ProtocolSession safe_session;
|
||||
ProtocolSession eight_bit_session;
|
||||
protocol_session_init(&safe_session, -1, -1);
|
||||
protocol_session_init(&eight_bit_session, -1, -1);
|
||||
protocol_session_set_8_bit_output(&safe_session, false);
|
||||
protocol_session_set_8_bit_output(&eight_bit_session, true);
|
||||
EXPECT_FALSE(safe_session.eight_bit_output);
|
||||
EXPECT_TRUE(eight_bit_session.eight_bit_output);
|
||||
|
||||
EscapeThreadArgs safe_args = {false, "x\\#303\\#251\\#012", 0};
|
||||
EscapeThreadArgs eight_bit_args = {true, "x\xc3\xa9\\#012", 0};
|
||||
thrd_t safe_thread;
|
||||
thrd_t eight_bit_thread;
|
||||
EXPECT_EQ_INT(thrd_create(&safe_thread, escape_thread, &safe_args), thrd_success);
|
||||
EXPECT_EQ_INT(thrd_create(&eight_bit_thread, escape_thread, &eight_bit_args), thrd_success);
|
||||
EXPECT_EQ_INT(thrd_join(safe_thread, NULL), thrd_success);
|
||||
EXPECT_EQ_INT(thrd_join(eight_bit_thread, NULL), thrd_success);
|
||||
EXPECT_FALSE(safe_args.failed);
|
||||
EXPECT_FALSE(eight_bit_args.failed);
|
||||
|
||||
// Test str_dup
|
||||
const char* dup_null = str_dup(NULL);
|
||||
EXPECT_NULL(dup_null);
|
||||
|
||||
Reference in New Issue
Block a user