Mercurial > minori
comparison dep/utf8proc/test/custom.c @ 343:1faa72660932
*: transfer back to cmake from autotools
autotools just made lots of things more complicated than
they should have and many things broke (i.e. translations)
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Thu, 20 Jun 2024 05:56:06 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
342:adb79bdde329 | 343:1faa72660932 |
---|---|
1 #include "tests.h" | |
2 | |
3 static int thunk_test = 1; | |
4 | |
5 static utf8proc_int32_t custom(utf8proc_int32_t codepoint, void *thunk) | |
6 { | |
7 check(((int *) thunk) == &thunk_test, "unexpected thunk passed"); | |
8 if (codepoint == 'a') | |
9 return 'b'; | |
10 if (codepoint == 'S') | |
11 return 0x00df; /* ß */ | |
12 return codepoint; | |
13 } | |
14 | |
15 int main(void) | |
16 { | |
17 utf8proc_uint8_t input[] = {0x41,0x61,0x53,0x62,0xef,0xbd,0x81,0x00}; /* "AaSb\uff41" */ | |
18 utf8proc_uint8_t correct[] = {0x61,0x62,0x73,0x73,0x62,0x61,0x00}; /* "abssba" */ | |
19 utf8proc_uint8_t *output; | |
20 utf8proc_map_custom(input, 0, &output, UTF8PROC_CASEFOLD | UTF8PROC_COMPOSE | UTF8PROC_COMPAT | UTF8PROC_NULLTERM, | |
21 custom, &thunk_test); | |
22 printf("mapped \"%s\" -> \"%s\"\n", (char*)input, (char*)output); | |
23 check(strlen((char*) output) == 6, "incorrect output length"); | |
24 check(!memcmp(correct, output, 7), "incorrect output data"); | |
25 free(output); | |
26 printf("map_custom tests SUCCEEDED.\n"); | |
27 return 0; | |
28 } |