File: maxdecomposition.c

package info (click to toggle)
utf8proc 2.11.3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,836 kB
  • sloc: ansic: 19,168; lisp: 449; makefile: 242; sh: 7
file content (22 lines) | stat: -rw-r--r-- 770 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "tests.h"

/* Check the maximum decomposed size returned by utf8proc_decompose_char with UTF8PROC_DECOMPOSE,
   in order to give a hint in the documentation.  The hint will need to be updated if this changes. */

int main(void)
{
    utf8proc_int32_t dst[128];
    utf8proc_ssize_t maxsize = 0, expected_maxsize = 4;
    int success;

    for (utf8proc_int32_t c = 0; c <= 0x110000; ++c) {
        utf8proc_ssize_t sz = utf8proc_decompose_char(c, dst, 128, UTF8PROC_DECOMPOSE, NULL);
        maxsize = sz > maxsize ? sz : maxsize;
    }

    success = expected_maxsize == maxsize;
    fprintf(success ? stdout : stderr,
            "%s: maximum decomposed size = %d chars\n",
            success ? "SUCCEEDED" : "FAILED", (int) maxsize);
    return !success;
}