aboutsummaryrefslogtreecommitdiff
path: root/tests/test_server.c
diff options
context:
space:
mode:
authorOnur Gündüz <ogunduz@gmail.com>2026-06-17 00:41:10 +0200
committerOnur Gündüz <ogunduz@gmail.com>2026-06-17 00:41:10 +0200
commit8b2a9cbdf0d31e5a9df91c05a531c4a860635278 (patch)
treef6818b9fae37c0da3f8b00051f675223fc0ddb78 /tests/test_server.c
parentd27b38730d6010abf1217f779f048778675c90c3 (diff)
downloadffwd-8b2a9cbdf0d31e5a9df91c05a531c4a860635278.tar.gz
ffwd-8b2a9cbdf0d31e5a9df91c05a531c4a860635278.zip
server: branch-free base64 block loop with overflow guard
Diffstat (limited to 'tests/test_server.c')
-rw-r--r--tests/test_server.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/test_server.c b/tests/test_server.c
index 6a558ae..81ed4f2 100644
--- a/tests/test_server.c
+++ b/tests/test_server.c
@@ -45,6 +45,24 @@ static void test_base64_rfc4648(void) {
}
}
+static void test_base64_binary_vectors(void) {
+ static const struct {
+ unsigned char bytes[5];
+ size_t n;
+ const char *out;
+ } cases[] = {
+ {{0xff}, 1, "/w=="},
+ {{0xff, 0xee}, 2, "/+4="},
+ {{0xff, 0xee, 0xdd}, 3, "/+7d"},
+ {{0x00, 0x01, 0x02, 0x03, 0x04}, 5, "AAECAwQ="},
+ };
+ for (size_t i = 0; i < sizeof(cases) / sizeof(cases[0]); i++) {
+ char *got = base64_encode(cases[i].bytes, cases[i].n);
+ TEST_ASSERT(strcmp(got, cases[i].out) == 0);
+ free(got);
+ }
+}
+
static void test_sbuf_growth_and_formatting(void) {
sbuf b = {0};
sbuf_puts(&b, "ab");
@@ -1125,6 +1143,7 @@ static void test_http_server(void) {
int main(void) {
test_base64_rfc4648();
+ test_base64_binary_vectors();
test_sbuf_growth_and_formatting();
test_json_error_body_escaping();
test_job_set_422_replaces_response();