1
// ---------------------------------------------------------------------------
3
// - unicode database (ucd) library - normal form decomposition (nfd) tester -
4
// ---------------------------------------------------------------------------
5
// - This program is free software; you can redistribute it and/or modify -
6
// - it provided that this copyright notice is kept intact. -
8
// - This program is distributed in the hope that it will be useful, but -
9
// - without any warranty; without even the implied warranty of -
10
// - merchantability or fitness for a particular purpose. In no event shall -
11
// - the copyright holder be liable for any direct, indirect, incidental or -
12
// - special damages arising in any way out of the use of this software. -
13
// ---------------------------------------------------------------------------
14
// - copyright (c) 1999-2007 amaury darsch -
15
// ---------------------------------------------------------------------------
20
// this procedure returns true if a field is a single code point
21
static bool nfd_is_single (const t_quad fld[NFT_ELM_MAX]) {
22
if (fld[0] == nilq) return false;
23
for (long i = 1; i < NFT_ELM_MAX; i++) {
24
if (fld[i] != nilq) return false;
29
// this procedure compare 2 fields
30
static bool nfd_cmp_fld (const t_quad dst[UCD_CDV_MAX],
31
const t_quad fld[UCD_CDV_MAX]) {
32
for (long i = 0; i < UCD_CDV_MAX; i++) {
33
if (dst[i] != fld[i]) return false;
38
// this procedure test a nfd transformationd at index 0
39
static bool nfd_test_0 (void) {
40
// loop in the test data
41
for (long i = 0; i < NFT_TEST_SIZE; i++) {
42
// get the data sample
43
const nft_t* data = &NFT_TEST_DATA[i];
44
// check for single code point
45
t_quad dst[UCD_CDV_MAX];
46
if (nfd_is_single ((*data)[0]) == true) {
47
// get the code point and transform it
48
t_quad code = (*data)[0][0];
51
if (nfd_cmp_fld (dst, (*data)[2]) == false) {
55
// check for a full array
56
c_ucdnfd (dst, (*data)[0]);
58
if (nfd_cmp_fld (dst, (*data)[2]) == false) {
66
int main (int, char**) {
67
using namespace afnix;
69
// check first the version consistency
70
if (NFT_MAJOR != UCD_MAJOR) return 1;
71
if (NFT_MINOR != UCD_MINOR) return 1;
72
if (NFT_PATCH != UCD_PATCH) return 1;
74
// check consistent UCD_CDV_MAX SIZE/NFT_ELM_MAX
75
// this ensure that the array have the same size
76
if (UCD_CDV_MAX != NFT_ELM_MAX) return 1;
78
// test the single code point first
79
if (nfd_test_0 () == false) return 1;