root/maint/gnulib/tests/uninorm/test-compat-decomposition.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. main

   1 /* Test of compatibility decomposition of Unicode characters.
   2    Copyright (C) 2009-2021 Free Software Foundation, Inc.
   3 
   4    This program is free software: you can redistribute it and/or modify
   5    it under the terms of the GNU General Public License as published by
   6    the Free Software Foundation; either version 3 of the License, or
   7    (at your option) any later version.
   8 
   9    This program is distributed in the hope that it will be useful,
  10    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12    GNU General Public License for more details.
  13 
  14    You should have received a copy of the GNU General Public License
  15    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
  16 
  17 /* Written by Bruno Haible <bruno@clisp.org>, 2009.  */
  18 
  19 #include <config.h>
  20 
  21 #include "uninorm/decompose-internal.h"
  22 
  23 #include "uninorm.h"
  24 #include "macros.h"
  25 
  26 int
  27 main ()
     /* [previous][next][first][last][top][bottom][index][help] */
  28 {
  29   ucs4_t decomposed[UC_DECOMPOSITION_MAX_LENGTH];
  30   int ret;
  31 
  32   /* SPACE */
  33   ret = uc_compat_decomposition (0x0020, decomposed);
  34   ASSERT (ret == -1);
  35 
  36   /* LATIN CAPITAL LETTER A WITH DIAERESIS */
  37   ret = uc_compat_decomposition (0x00C4, decomposed);
  38   ASSERT (ret == 2);
  39   ASSERT (decomposed[0] == 0x0041);
  40   ASSERT (decomposed[1] == 0x0308);
  41 
  42   /* LATIN CAPITAL LETTER A WITH DIAERESIS AND MACRON */
  43   ret = uc_compat_decomposition (0x01DE, decomposed);
  44   ASSERT (ret == 2);
  45   ASSERT (decomposed[0] == 0x00C4);
  46   ASSERT (decomposed[1] == 0x0304);
  47 
  48   /* GREEK DIALYTIKA AND PERISPOMENI */
  49   ret = uc_compat_decomposition (0x1FC1, decomposed);
  50   ASSERT (ret == 2);
  51   ASSERT (decomposed[0] == 0x00A8);
  52   ASSERT (decomposed[1] == 0x0342);
  53 
  54   /* SCRIPT SMALL L */
  55   ret = uc_compat_decomposition (0x2113, decomposed);
  56   ASSERT (ret == 1);
  57   ASSERT (decomposed[0] == 0x006C);
  58 
  59   /* NO-BREAK SPACE */
  60   ret = uc_compat_decomposition (0x00A0, decomposed);
  61   ASSERT (ret == 1);
  62   ASSERT (decomposed[0] == 0x0020);
  63 
  64   /* ARABIC LETTER VEH INITIAL FORM */
  65   ret = uc_compat_decomposition (0xFB6C, decomposed);
  66   ASSERT (ret == 1);
  67   ASSERT (decomposed[0] == 0x06A4);
  68 
  69   /* ARABIC LETTER VEH MEDIAL FORM */
  70   ret = uc_compat_decomposition (0xFB6D, decomposed);
  71   ASSERT (ret == 1);
  72   ASSERT (decomposed[0] == 0x06A4);
  73 
  74   /* ARABIC LETTER VEH FINAL FORM */
  75   ret = uc_compat_decomposition (0xFB6B, decomposed);
  76   ASSERT (ret == 1);
  77   ASSERT (decomposed[0] == 0x06A4);
  78 
  79   /* ARABIC LETTER VEH ISOLATED FORM */
  80   ret = uc_compat_decomposition (0xFB6A, decomposed);
  81   ASSERT (ret == 1);
  82   ASSERT (decomposed[0] == 0x06A4);
  83 
  84   /* CIRCLED NUMBER FIFTEEN */
  85   ret = uc_compat_decomposition (0x246E, decomposed);
  86   ASSERT (ret == 2);
  87   ASSERT (decomposed[0] == 0x0031);
  88   ASSERT (decomposed[1] == 0x0035);
  89 
  90   /* TRADE MARK SIGN */
  91   ret = uc_compat_decomposition (0x2122, decomposed);
  92   ASSERT (ret == 2);
  93   ASSERT (decomposed[0] == 0x0054);
  94   ASSERT (decomposed[1] == 0x004D);
  95 
  96   /* LATIN SUBSCRIPT SMALL LETTER I */
  97   ret = uc_compat_decomposition (0x1D62, decomposed);
  98   ASSERT (ret == 1);
  99   ASSERT (decomposed[0] == 0x0069);
 100 
 101   /* PRESENTATION FORM FOR VERTICAL LEFT PARENTHESIS */
 102   ret = uc_compat_decomposition (0xFE35, decomposed);
 103   ASSERT (ret == 1);
 104   ASSERT (decomposed[0] == 0x0028);
 105 
 106   /* FULLWIDTH LATIN CAPITAL LETTER A */
 107   ret = uc_compat_decomposition (0xFF21, decomposed);
 108   ASSERT (ret == 1);
 109   ASSERT (decomposed[0] == 0x0041);
 110 
 111   /* HALFWIDTH IDEOGRAPHIC COMMA */
 112   ret = uc_compat_decomposition (0xFF64, decomposed);
 113   ASSERT (ret == 1);
 114   ASSERT (decomposed[0] == 0x3001);
 115 
 116   /* SMALL IDEOGRAPHIC COMMA */
 117   ret = uc_compat_decomposition (0xFE51, decomposed);
 118   ASSERT (ret == 1);
 119   ASSERT (decomposed[0] == 0x3001);
 120 
 121   /* SQUARE MHZ */
 122   ret = uc_compat_decomposition (0x3392, decomposed);
 123   ASSERT (ret == 3);
 124   ASSERT (decomposed[0] == 0x004D);
 125   ASSERT (decomposed[1] == 0x0048);
 126   ASSERT (decomposed[2] == 0x007A);
 127 
 128   /* VULGAR FRACTION THREE EIGHTHS */
 129   ret = uc_compat_decomposition (0x215C, decomposed);
 130   ASSERT (ret == 3);
 131   ASSERT (decomposed[0] == 0x0033);
 132   ASSERT (decomposed[1] == 0x2044);
 133   ASSERT (decomposed[2] == 0x0038);
 134 
 135   /* MICRO SIGN */
 136   ret = uc_compat_decomposition (0x00B5, decomposed);
 137   ASSERT (ret == 1);
 138   ASSERT (decomposed[0] == 0x03BC);
 139 
 140   /* ARABIC LIGATURE SALLALLAHOU ALAYHE WASALLAM */
 141   ret = uc_compat_decomposition (0xFDFA, decomposed);
 142   ASSERT (ret == 18);
 143   ASSERT (decomposed[0] == 0x0635);
 144   ASSERT (decomposed[1] == 0x0644);
 145   ASSERT (decomposed[2] == 0x0649);
 146   ASSERT (decomposed[3] == 0x0020);
 147   ASSERT (decomposed[4] == 0x0627);
 148   ASSERT (decomposed[5] == 0x0644);
 149   ASSERT (decomposed[6] == 0x0644);
 150   ASSERT (decomposed[7] == 0x0647);
 151   ASSERT (decomposed[8] == 0x0020);
 152   ASSERT (decomposed[9] == 0x0639);
 153   ASSERT (decomposed[10] == 0x0644);
 154   ASSERT (decomposed[11] == 0x064A);
 155   ASSERT (decomposed[12] == 0x0647);
 156   ASSERT (decomposed[13] == 0x0020);
 157   ASSERT (decomposed[14] == 0x0648);
 158   ASSERT (decomposed[15] == 0x0633);
 159   ASSERT (decomposed[16] == 0x0644);
 160   ASSERT (decomposed[17] == 0x0645);
 161 
 162   /* HANGUL SYLLABLE GEUL */
 163   ret = uc_compat_decomposition (0xAE00, decomposed);
 164   /* See the clarification at <https://www.unicode.org/versions/Unicode5.1.0/>,
 165      section "Clarification of Hangul Jamo Handling".  */
 166 #if 1
 167   ASSERT (ret == 2);
 168   ASSERT (decomposed[0] == 0xADF8);
 169   ASSERT (decomposed[1] == 0x11AF);
 170 #else
 171   ASSERT (ret == 3);
 172   ASSERT (decomposed[0] == 0x1100);
 173   ASSERT (decomposed[1] == 0x1173);
 174   ASSERT (decomposed[2] == 0x11AF);
 175 #endif
 176 
 177   /* HANGUL SYLLABLE GEU */
 178   ret = uc_compat_decomposition (0xADF8, decomposed);
 179   ASSERT (ret == 2);
 180   ASSERT (decomposed[0] == 0x1100);
 181   ASSERT (decomposed[1] == 0x1173);
 182 
 183   return 0;
 184 }

/* [previous][next][first][last][top][bottom][index][help] */