summaryrefslogtreecommitdiff
path: root/tests/unicode
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-10-15 13:04:32 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-10-15 13:04:32 +0300
commitbdaedce69b17b654bd0060579dd9b9ff120009b5 (patch)
tree0e9cd8597652263a96c48ba678fb0b66e1fc131b /tests/unicode
parentba75c8b0a1bba03ad92c53375432f122ddb4cb98 (diff)
parentdcebf9c7f954a55350b68d0ead1935612c4e2e05 (diff)
Merge branch 'wt/rename' into api-hardening
# Conflicts: # README.md
Diffstat (limited to 'tests/unicode')
-rw-r--r--tests/unicode/unicode_test.c70
1 files changed, 35 insertions, 35 deletions
diff --git a/tests/unicode/unicode_test.c b/tests/unicode/unicode_test.c
index e3cf5a7..dd6534b 100644
--- a/tests/unicode/unicode_test.c
+++ b/tests/unicode/unicode_test.c
@@ -1,4 +1,4 @@
-#include "term/unicode/utf8.h"
+#include "wsap_vtcore/unicode/utf8.h"
#include <assert.h>
#include <stdio.h>
#include <string.h>
@@ -16,17 +16,17 @@ static void test_utf8_decode_one(void)
for (size_t i = 0; i < sizeof(valid) / sizeof(*valid); i++) {
uint32_t cp = 0xdeadbeef;
for (int n = 0; n < valid[i].len; n++) {
- int r = term_utf8_decode_one(valid[i].bytes, n, &cp);
+ int r = wsap_vtcore_utf8_decode_one(valid[i].bytes, n, &cp);
assert(r == 0);
assert(cp == 0xdeadbeef);
}
- int r = term_utf8_decode_one(valid[i].bytes, valid[i].len, &cp);
+ int r = wsap_vtcore_utf8_decode_one(valid[i].bytes, valid[i].len, &cp);
assert(r == valid[i].len);
assert(cp == valid[i].cp);
char followed[8];
memcpy(followed, valid[i].bytes, valid[i].len);
memcpy(followed + valid[i].len, "next", 4);
- r = term_utf8_decode_one(followed, valid[i].len + 4, &cp);
+ r = wsap_vtcore_utf8_decode_one(followed, valid[i].len + 4, &cp);
assert(r == valid[i].len);
assert(cp == valid[i].cp);
}
@@ -38,7 +38,7 @@ static void test_utf8_decode_one(void)
};
for (size_t i = 0; i < sizeof(invalid) / sizeof(*invalid); i++) {
uint32_t cp = 0xdeadbeef;
- int r = term_utf8_decode_one(invalid[i], strlen(invalid[i]), &cp);
+ int r = wsap_vtcore_utf8_decode_one(invalid[i], strlen(invalid[i]), &cp);
assert(r == 0);
assert(cp == 0xdeadbeef);
}
@@ -48,24 +48,24 @@ static void test_scalar_roundtrips(void)
{
for (uint32_t cp = 0; cp <= 0x10ffff; cp++) {
if (cp >= 0xd800 && cp <= 0xdfff) continue;
- char bytes[TERM_UTF8_MAX_BYTES];
- int len = term_utf8_encode(cp, bytes);
- uint32_t scalar = 0, streamed = 0, state = TERM_UTF8_ACCEPT;
- int r = term_utf8_decode_one(bytes, (size_t)len, &scalar);
+ char bytes[WSAP_VTCORE_UTF8_MAX_BYTES];
+ int len = wsap_vtcore_utf8_encode(cp, bytes);
+ uint32_t scalar = 0, streamed = 0, state = WSAP_VTCORE_UTF8_ACCEPT;
+ int r = wsap_vtcore_utf8_decode_one(bytes, (size_t)len, &scalar);
assert(r == len);
assert(scalar == cp);
for (int i = 0; i < len; i++) {
- term_utf8_decode(&state, &streamed, (unsigned char)bytes[i]);
- if (i + 1 < len) assert(state != TERM_UTF8_ACCEPT && state != TERM_UTF8_REJECT);
+ wsap_vtcore_utf8_decode(&state, &streamed, (unsigned char)bytes[i]);
+ if (i + 1 < len) assert(state != WSAP_VTCORE_UTF8_ACCEPT && state != WSAP_VTCORE_UTF8_REJECT);
}
- assert(state == TERM_UTF8_ACCEPT && streamed == cp);
+ assert(state == WSAP_VTCORE_UTF8_ACCEPT && streamed == cp);
}
static const uint32_t invalid[] = {0xd800, 0xdfff, 0x110000, UINT32_MAX};
for (size_t i = 0; i < sizeof(invalid) / sizeof(*invalid); i++) {
- char bytes[TERM_UTF8_MAX_BYTES];
- int len = term_utf8_encode(invalid[i], bytes);
+ char bytes[WSAP_VTCORE_UTF8_MAX_BYTES];
+ int len = wsap_vtcore_utf8_encode(invalid[i], bytes);
uint32_t cp = 0;
- int r = term_utf8_decode_one(bytes, len, &cp);
+ int r = wsap_vtcore_utf8_decode_one(bytes, len, &cp);
assert(len == 3 && r == len && cp == 0xfffd);
}
}
@@ -74,26 +74,26 @@ static void test_utf8_sanitize(void)
{
char dst[64];
- term_utf8_sanitize(dst, sizeof(dst), "hello \xe2\x82\xac\xf0\x9f\x98\x80");
+ wsap_vtcore_utf8_sanitize(dst, sizeof(dst), "hello \xe2\x82\xac\xf0\x9f\x98\x80");
assert(!strcmp(dst, "hello \xe2\x82\xac\xf0\x9f\x98\x80"));
- term_utf8_sanitize(dst, sizeof(dst), "a\xff\x80" "b\xed\xa0\x80" "c\xe2\x82");
+ wsap_vtcore_utf8_sanitize(dst, sizeof(dst), "a\xff\x80" "b\xed\xa0\x80" "c\xe2\x82");
assert(!strcmp(dst, "abc"));
- term_utf8_sanitize(dst, sizeof(dst), "");
+ wsap_vtcore_utf8_sanitize(dst, sizeof(dst), "");
assert(!strcmp(dst, ""));
- term_utf8_sanitize(dst, sizeof(dst), "\xff\xfe");
+ wsap_vtcore_utf8_sanitize(dst, sizeof(dst), "\xff\xfe");
assert(!strcmp(dst, ""));
- term_utf8_sanitize(dst, 6, "ab\xe2\x82\xac" "cd");
+ wsap_vtcore_utf8_sanitize(dst, 6, "ab\xe2\x82\xac" "cd");
assert(!strcmp(dst, "ab\xe2\x82\xac"));
- term_utf8_sanitize(dst, 5, "ab\xe2\x82\xac" "cd");
+ wsap_vtcore_utf8_sanitize(dst, 5, "ab\xe2\x82\xac" "cd");
assert(!strcmp(dst, "abcd"));
memset(dst, 'x', sizeof(dst));
- term_utf8_sanitize(dst, 4, "abcdef");
+ wsap_vtcore_utf8_sanitize(dst, 4, "abcdef");
assert(!strcmp(dst, "abc"));
memset(dst, 'x', sizeof(dst));
- term_utf8_sanitize(dst, 0, "abc");
+ wsap_vtcore_utf8_sanitize(dst, 0, "abc");
assert(dst[0] == 'x');
}
@@ -101,30 +101,30 @@ static void test_utf8_sanitize(void)
* stays unused. */
static void test_ground_invalid_subparts(void)
{
- uint32_t state = TERM_UTF8_ACCEPT, codep = 0, cp = 0xdead;
- int n = term_utf8_decode_ground(&state, &codep, "\xe2\x80\x1b\xac", 4, &cp);
+ uint32_t state = WSAP_VTCORE_UTF8_ACCEPT, codep = 0, cp = 0xdead;
+ int n = wsap_vtcore_utf8_decode_ground(&state, &codep, "\xe2\x80\x1b\xac", 4, &cp);
assert(n == 2);
assert(cp == 0xFFFD);
- assert(state == TERM_UTF8_ACCEPT);
- n = term_utf8_decode_ground(&state, &codep, "\xac", 1, &cp);
+ assert(state == WSAP_VTCORE_UTF8_ACCEPT);
+ n = wsap_vtcore_utf8_decode_ground(&state, &codep, "\xac", 1, &cp);
assert(n == 1);
assert(cp == 0xFFFD);
- assert(state == TERM_UTF8_ACCEPT);
- n = term_utf8_decode_ground(&state, &codep, "\xe2\x82z", 3, &cp);
+ assert(state == WSAP_VTCORE_UTF8_ACCEPT);
+ n = wsap_vtcore_utf8_decode_ground(&state, &codep, "\xe2\x82z", 3, &cp);
assert(n == 2);
assert(cp == 0xFFFD);
- assert(state == TERM_UTF8_ACCEPT);
- n = term_utf8_decode_ground(&state, &codep, "\xe2\x82", 2, &cp);
+ assert(state == WSAP_VTCORE_UTF8_ACCEPT);
+ n = wsap_vtcore_utf8_decode_ground(&state, &codep, "\xe2\x82", 2, &cp);
assert(n == 2);
assert(cp == 0);
- assert(state != TERM_UTF8_ACCEPT);
+ assert(state != WSAP_VTCORE_UTF8_ACCEPT);
- state = TERM_UTF8_ACCEPT;
+ state = WSAP_VTCORE_UTF8_ACCEPT;
codep = 0;
- n = term_utf8_decode_ground(&state, &codep, "\xe2\x82\xac", 3, &cp);
+ n = wsap_vtcore_utf8_decode_ground(&state, &codep, "\xe2\x82\xac", 3, &cp);
assert(n == 3);
assert(cp == 0x20ac);
- assert(state == TERM_UTF8_ACCEPT);
+ assert(state == WSAP_VTCORE_UTF8_ACCEPT);
}
int main(void)