utf8proc

A clean C library for processing UTF-8 Unicode data
git clone https://git.sinitax.com/juliastrings/utf8proc
Log | Files | Refs | README | LICENSE | sfeed.txt

valid.c (1103B)


      1#include "tests.h"
      2#include <ctype.h>
      3#include <wchar.h>
      4
      5int main(int argc, char **argv)
      6{
      7     int c, error = 0;
      8
      9     (void) argc; /* unused */
     10     (void) argv; /* unused */
     11
     12     /* some simple sanity tests of  */
     13     for (c = 0; c < 0xd800; c++) {
     14        if (!utf8proc_codepoint_valid(c)) {
     15           fprintf(stderr, "Failed: codepoint_valid(%04x) -> false\n", c);
     16           error++;
     17        }
     18     }
     19     for (;c < 0xe000; c++) {
     20        if (utf8proc_codepoint_valid(c)) {
     21           fprintf(stderr, "Failed: codepoint_valid(%04x) -> true\n", c);
     22           error++;
     23        }
     24     }
     25     for (;c < 0x110000; c++) {
     26        if (!utf8proc_codepoint_valid(c)) {
     27           fprintf(stderr, "Failed: codepoint_valid(%06x) -> false\n", c);
     28           error++;
     29        }
     30     }
     31     for (;c < 0x110010; c++) {
     32        if (utf8proc_codepoint_valid(c)) {
     33           fprintf(stderr, "Failed: codepoint_valid(%06x) -> true\n", c);
     34           error++;
     35        }
     36     }
     37     check(!error, "utf8proc_codepoint_valid FAILED %d tests.", error);
     38     printf("Validity tests SUCCEEDED.\n");
     39
     40     return 0;
     41}