root/maint/gnulib/tests/unictype/test-categ_byname.c

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

DEFINITIONS

This source file includes following definitions.
  1. category_equals
  2. main

   1 /* Test the Unicode character type functions.
   2    Copyright (C) 2007-2011 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 #include <config.h>
  18 
  19 #include "unictype.h"
  20 
  21 #include <stdbool.h>
  22 #include <string.h>
  23 
  24 #include "macros.h"
  25 
  26 static bool
  27 category_equals (uc_general_category_t category1,
     /* [previous][next][first][last][top][bottom][index][help] */
  28                  uc_general_category_t category2)
  29 {
  30   return (category1.bitmask == category2.bitmask
  31           && category1.generic == category2.generic
  32           && (category1.generic
  33               ? category1.lookup.lookup_fn == category2.lookup.lookup_fn
  34               : category1.lookup.table == category2.lookup.table));
  35 }
  36 
  37 int
  38 main ()
     /* [previous][next][first][last][top][bottom][index][help] */
  39 {
  40   ASSERT (category_equals (uc_general_category_byname ("L"), UC_CATEGORY_L));
  41   ASSERT (category_equals (uc_general_category_byname ("LC"), UC_CATEGORY_LC));
  42   ASSERT (category_equals (uc_general_category_byname ("Lu"), UC_CATEGORY_Lu));
  43   ASSERT (category_equals (uc_general_category_byname ("Ll"), UC_CATEGORY_Ll));
  44   ASSERT (category_equals (uc_general_category_byname ("Lt"), UC_CATEGORY_Lt));
  45   ASSERT (category_equals (uc_general_category_byname ("Lm"), UC_CATEGORY_Lm));
  46   ASSERT (category_equals (uc_general_category_byname ("Lo"), UC_CATEGORY_Lo));
  47   ASSERT (category_equals (uc_general_category_byname ("M"), UC_CATEGORY_M));
  48   ASSERT (category_equals (uc_general_category_byname ("Mn"), UC_CATEGORY_Mn));
  49   ASSERT (category_equals (uc_general_category_byname ("Mc"), UC_CATEGORY_Mc));
  50   ASSERT (category_equals (uc_general_category_byname ("Me"), UC_CATEGORY_Me));
  51   ASSERT (category_equals (uc_general_category_byname ("N"), UC_CATEGORY_N));
  52   ASSERT (category_equals (uc_general_category_byname ("Nd"), UC_CATEGORY_Nd));
  53   ASSERT (category_equals (uc_general_category_byname ("Nl"), UC_CATEGORY_Nl));
  54   ASSERT (category_equals (uc_general_category_byname ("No"), UC_CATEGORY_No));
  55   ASSERT (category_equals (uc_general_category_byname ("P"), UC_CATEGORY_P));
  56   ASSERT (category_equals (uc_general_category_byname ("Pc"), UC_CATEGORY_Pc));
  57   ASSERT (category_equals (uc_general_category_byname ("Pd"), UC_CATEGORY_Pd));
  58   ASSERT (category_equals (uc_general_category_byname ("Ps"), UC_CATEGORY_Ps));
  59   ASSERT (category_equals (uc_general_category_byname ("Pe"), UC_CATEGORY_Pe));
  60   ASSERT (category_equals (uc_general_category_byname ("Pi"), UC_CATEGORY_Pi));
  61   ASSERT (category_equals (uc_general_category_byname ("Pf"), UC_CATEGORY_Pf));
  62   ASSERT (category_equals (uc_general_category_byname ("Po"), UC_CATEGORY_Po));
  63   ASSERT (category_equals (uc_general_category_byname ("S"), UC_CATEGORY_S));
  64   ASSERT (category_equals (uc_general_category_byname ("Sm"), UC_CATEGORY_Sm));
  65   ASSERT (category_equals (uc_general_category_byname ("Sc"), UC_CATEGORY_Sc));
  66   ASSERT (category_equals (uc_general_category_byname ("Sk"), UC_CATEGORY_Sk));
  67   ASSERT (category_equals (uc_general_category_byname ("So"), UC_CATEGORY_So));
  68   ASSERT (category_equals (uc_general_category_byname ("Z"), UC_CATEGORY_Z));
  69   ASSERT (category_equals (uc_general_category_byname ("Zs"), UC_CATEGORY_Zs));
  70   ASSERT (category_equals (uc_general_category_byname ("Zl"), UC_CATEGORY_Zl));
  71   ASSERT (category_equals (uc_general_category_byname ("Zp"), UC_CATEGORY_Zp));
  72   ASSERT (category_equals (uc_general_category_byname ("C"), UC_CATEGORY_C));
  73   ASSERT (category_equals (uc_general_category_byname ("Cc"), UC_CATEGORY_Cc));
  74   ASSERT (category_equals (uc_general_category_byname ("Cf"), UC_CATEGORY_Cf));
  75   ASSERT (category_equals (uc_general_category_byname ("Cs"), UC_CATEGORY_Cs));
  76   ASSERT (category_equals (uc_general_category_byname ("Co"), UC_CATEGORY_Co));
  77   ASSERT (category_equals (uc_general_category_byname ("Cn"), UC_CATEGORY_Cn));
  78 
  79   ASSERT (category_equals (uc_general_category_byname ("LETTER"), UC_CATEGORY_L));
  80   ASSERT (category_equals (uc_general_category_byname ("Letter"), UC_CATEGORY_L));
  81   ASSERT (category_equals (uc_general_category_byname ("CASED LETTER"), UC_CATEGORY_LC));
  82   ASSERT (category_equals (uc_general_category_byname ("Cased Letter"), UC_CATEGORY_LC));
  83   ASSERT (category_equals (uc_general_category_byname ("Cased_Letter"), UC_CATEGORY_LC));
  84   ASSERT (category_equals (uc_general_category_byname ("CasedLetter"), UC_CATEGORY_LC));
  85   ASSERT (category_equals (uc_general_category_byname ("UPPERCASE LETTER"), UC_CATEGORY_Lu));
  86   ASSERT (category_equals (uc_general_category_byname ("Uppercase Letter"), UC_CATEGORY_Lu));
  87   ASSERT (category_equals (uc_general_category_byname ("Uppercase_Letter"), UC_CATEGORY_Lu));
  88   ASSERT (category_equals (uc_general_category_byname ("UppercaseLetter"), UC_CATEGORY_Lu));
  89   ASSERT (category_equals (uc_general_category_byname ("LOWERCASE LETTER"), UC_CATEGORY_Ll));
  90   ASSERT (category_equals (uc_general_category_byname ("Lowercase Letter"), UC_CATEGORY_Ll));
  91   ASSERT (category_equals (uc_general_category_byname ("Lowercase_Letter"), UC_CATEGORY_Ll));
  92   ASSERT (category_equals (uc_general_category_byname ("LowercaseLetter"), UC_CATEGORY_Ll));
  93   ASSERT (category_equals (uc_general_category_byname ("TITLECASE LETTER"), UC_CATEGORY_Lt));
  94   ASSERT (category_equals (uc_general_category_byname ("Titlecase Letter"), UC_CATEGORY_Lt));
  95   ASSERT (category_equals (uc_general_category_byname ("Titlecase_Letter"), UC_CATEGORY_Lt));
  96   ASSERT (category_equals (uc_general_category_byname ("TitlecaseLetter"), UC_CATEGORY_Lt));
  97   ASSERT (category_equals (uc_general_category_byname ("MODIFIER LETTER"), UC_CATEGORY_Lm));
  98   ASSERT (category_equals (uc_general_category_byname ("Modifier Letter"), UC_CATEGORY_Lm));
  99   ASSERT (category_equals (uc_general_category_byname ("Modifier_Letter"), UC_CATEGORY_Lm));
 100   ASSERT (category_equals (uc_general_category_byname ("ModifierLetter"), UC_CATEGORY_Lm));
 101   ASSERT (category_equals (uc_general_category_byname ("OTHER LETTER"), UC_CATEGORY_Lo));
 102   ASSERT (category_equals (uc_general_category_byname ("Other Letter"), UC_CATEGORY_Lo));
 103   ASSERT (category_equals (uc_general_category_byname ("Other_Letter"), UC_CATEGORY_Lo));
 104   ASSERT (category_equals (uc_general_category_byname ("OtherLetter"), UC_CATEGORY_Lo));
 105   ASSERT (category_equals (uc_general_category_byname ("MARK"), UC_CATEGORY_M));
 106   ASSERT (category_equals (uc_general_category_byname ("Mark"), UC_CATEGORY_M));
 107   ASSERT (category_equals (uc_general_category_byname ("NONSPACING MARK"), UC_CATEGORY_Mn));
 108   ASSERT (category_equals (uc_general_category_byname ("Nonspacing Mark"), UC_CATEGORY_Mn));
 109   ASSERT (category_equals (uc_general_category_byname ("Nonspacing_Mark"), UC_CATEGORY_Mn));
 110   ASSERT (category_equals (uc_general_category_byname ("NonspacingMark"), UC_CATEGORY_Mn));
 111   ASSERT (category_equals (uc_general_category_byname ("SPACING MARK"), UC_CATEGORY_Mc));
 112   ASSERT (category_equals (uc_general_category_byname ("Spacing Mark"), UC_CATEGORY_Mc));
 113   ASSERT (category_equals (uc_general_category_byname ("Spacing_Mark"), UC_CATEGORY_Mc));
 114   ASSERT (category_equals (uc_general_category_byname ("SpacingMark"), UC_CATEGORY_Mc));
 115   ASSERT (category_equals (uc_general_category_byname ("ENCLOSING MARK"), UC_CATEGORY_Me));
 116   ASSERT (category_equals (uc_general_category_byname ("Enclosing Mark"), UC_CATEGORY_Me));
 117   ASSERT (category_equals (uc_general_category_byname ("Enclosing_Mark"), UC_CATEGORY_Me));
 118   ASSERT (category_equals (uc_general_category_byname ("EnclosingMark"), UC_CATEGORY_Me));
 119   ASSERT (category_equals (uc_general_category_byname ("NUMBER"), UC_CATEGORY_N));
 120   ASSERT (category_equals (uc_general_category_byname ("Number"), UC_CATEGORY_N));
 121   ASSERT (category_equals (uc_general_category_byname ("DECIMAL NUMBER"), UC_CATEGORY_Nd));
 122   ASSERT (category_equals (uc_general_category_byname ("Decimal Number"), UC_CATEGORY_Nd));
 123   ASSERT (category_equals (uc_general_category_byname ("Decimal_Number"), UC_CATEGORY_Nd));
 124   ASSERT (category_equals (uc_general_category_byname ("DecimalNumber"), UC_CATEGORY_Nd));
 125   ASSERT (category_equals (uc_general_category_byname ("LETTER NUMBER"), UC_CATEGORY_Nl));
 126   ASSERT (category_equals (uc_general_category_byname ("Letter Number"), UC_CATEGORY_Nl));
 127   ASSERT (category_equals (uc_general_category_byname ("Letter_Number"), UC_CATEGORY_Nl));
 128   ASSERT (category_equals (uc_general_category_byname ("LetterNumber"), UC_CATEGORY_Nl));
 129   ASSERT (category_equals (uc_general_category_byname ("OTHER NUMBER"), UC_CATEGORY_No));
 130   ASSERT (category_equals (uc_general_category_byname ("Other Number"), UC_CATEGORY_No));
 131   ASSERT (category_equals (uc_general_category_byname ("Other_Number"), UC_CATEGORY_No));
 132   ASSERT (category_equals (uc_general_category_byname ("OtherNumber"), UC_CATEGORY_No));
 133   ASSERT (category_equals (uc_general_category_byname ("PUNCTUATION"), UC_CATEGORY_P));
 134   ASSERT (category_equals (uc_general_category_byname ("Punctuation"), UC_CATEGORY_P));
 135   ASSERT (category_equals (uc_general_category_byname ("CONNECTOR PUNCTUATION"), UC_CATEGORY_Pc));
 136   ASSERT (category_equals (uc_general_category_byname ("Connector Punctuation"), UC_CATEGORY_Pc));
 137   ASSERT (category_equals (uc_general_category_byname ("Connector_Punctuation"), UC_CATEGORY_Pc));
 138   ASSERT (category_equals (uc_general_category_byname ("ConnectorPunctuation"), UC_CATEGORY_Pc));
 139   ASSERT (category_equals (uc_general_category_byname ("DASH PUNCTUATION"), UC_CATEGORY_Pd));
 140   ASSERT (category_equals (uc_general_category_byname ("Dash Punctuation"), UC_CATEGORY_Pd));
 141   ASSERT (category_equals (uc_general_category_byname ("Dash_Punctuation"), UC_CATEGORY_Pd));
 142   ASSERT (category_equals (uc_general_category_byname ("DashPunctuation"), UC_CATEGORY_Pd));
 143   ASSERT (category_equals (uc_general_category_byname ("OPEN PUNCTUATION"), UC_CATEGORY_Ps));
 144   ASSERT (category_equals (uc_general_category_byname ("Open Punctuation"), UC_CATEGORY_Ps));
 145   ASSERT (category_equals (uc_general_category_byname ("Open_Punctuation"), UC_CATEGORY_Ps));
 146   ASSERT (category_equals (uc_general_category_byname ("OpenPunctuation"), UC_CATEGORY_Ps));
 147   ASSERT (category_equals (uc_general_category_byname ("CLOSE PUNCTUATION"), UC_CATEGORY_Pe));
 148   ASSERT (category_equals (uc_general_category_byname ("Close Punctuation"), UC_CATEGORY_Pe));
 149   ASSERT (category_equals (uc_general_category_byname ("Close_Punctuation"), UC_CATEGORY_Pe));
 150   ASSERT (category_equals (uc_general_category_byname ("ClosePunctuation"), UC_CATEGORY_Pe));
 151   ASSERT (category_equals (uc_general_category_byname ("INITIAL PUNCTUATION"), UC_CATEGORY_Pi));
 152   ASSERT (category_equals (uc_general_category_byname ("Initial Punctuation"), UC_CATEGORY_Pi));
 153   ASSERT (category_equals (uc_general_category_byname ("Initial_Punctuation"), UC_CATEGORY_Pi));
 154   ASSERT (category_equals (uc_general_category_byname ("InitialPunctuation"), UC_CATEGORY_Pi));
 155   ASSERT (category_equals (uc_general_category_byname ("FINAL PUNCTUATION"), UC_CATEGORY_Pf));
 156   ASSERT (category_equals (uc_general_category_byname ("Final Punctuation"), UC_CATEGORY_Pf));
 157   ASSERT (category_equals (uc_general_category_byname ("Final_Punctuation"), UC_CATEGORY_Pf));
 158   ASSERT (category_equals (uc_general_category_byname ("FinalPunctuation"), UC_CATEGORY_Pf));
 159   ASSERT (category_equals (uc_general_category_byname ("OTHER PUNCTUATION"), UC_CATEGORY_Po));
 160   ASSERT (category_equals (uc_general_category_byname ("Other Punctuation"), UC_CATEGORY_Po));
 161   ASSERT (category_equals (uc_general_category_byname ("Other_Punctuation"), UC_CATEGORY_Po));
 162   ASSERT (category_equals (uc_general_category_byname ("OtherPunctuation"), UC_CATEGORY_Po));
 163   ASSERT (category_equals (uc_general_category_byname ("SYMBOL"), UC_CATEGORY_S));
 164   ASSERT (category_equals (uc_general_category_byname ("Symbol"), UC_CATEGORY_S));
 165   ASSERT (category_equals (uc_general_category_byname ("MATH SYMBOL"), UC_CATEGORY_Sm));
 166   ASSERT (category_equals (uc_general_category_byname ("Math Symbol"), UC_CATEGORY_Sm));
 167   ASSERT (category_equals (uc_general_category_byname ("Math_Symbol"), UC_CATEGORY_Sm));
 168   ASSERT (category_equals (uc_general_category_byname ("MathSymbol"), UC_CATEGORY_Sm));
 169   ASSERT (category_equals (uc_general_category_byname ("CURRENCY SYMBOL"), UC_CATEGORY_Sc));
 170   ASSERT (category_equals (uc_general_category_byname ("Currency Symbol"), UC_CATEGORY_Sc));
 171   ASSERT (category_equals (uc_general_category_byname ("Currency_Symbol"), UC_CATEGORY_Sc));
 172   ASSERT (category_equals (uc_general_category_byname ("CurrencySymbol"), UC_CATEGORY_Sc));
 173   ASSERT (category_equals (uc_general_category_byname ("MODIFIER SYMBOL"), UC_CATEGORY_Sk));
 174   ASSERT (category_equals (uc_general_category_byname ("Modifier Symbol"), UC_CATEGORY_Sk));
 175   ASSERT (category_equals (uc_general_category_byname ("Modifier_Symbol"), UC_CATEGORY_Sk));
 176   ASSERT (category_equals (uc_general_category_byname ("ModifierSymbol"), UC_CATEGORY_Sk));
 177   ASSERT (category_equals (uc_general_category_byname ("OTHER SYMBOL"), UC_CATEGORY_So));
 178   ASSERT (category_equals (uc_general_category_byname ("Other Symbol"), UC_CATEGORY_So));
 179   ASSERT (category_equals (uc_general_category_byname ("Other_Symbol"), UC_CATEGORY_So));
 180   ASSERT (category_equals (uc_general_category_byname ("OtherSymbol"), UC_CATEGORY_So));
 181   ASSERT (category_equals (uc_general_category_byname ("SEPARATOR"), UC_CATEGORY_Z));
 182   ASSERT (category_equals (uc_general_category_byname ("Separator"), UC_CATEGORY_Z));
 183   ASSERT (category_equals (uc_general_category_byname ("SPACE SEPARATOR"), UC_CATEGORY_Zs));
 184   ASSERT (category_equals (uc_general_category_byname ("Space Separator"), UC_CATEGORY_Zs));
 185   ASSERT (category_equals (uc_general_category_byname ("Space_Separator"), UC_CATEGORY_Zs));
 186   ASSERT (category_equals (uc_general_category_byname ("SpaceSeparator"), UC_CATEGORY_Zs));
 187   ASSERT (category_equals (uc_general_category_byname ("LINE SEPARATOR"), UC_CATEGORY_Zl));
 188   ASSERT (category_equals (uc_general_category_byname ("Line Separator"), UC_CATEGORY_Zl));
 189   ASSERT (category_equals (uc_general_category_byname ("Line_Separator"), UC_CATEGORY_Zl));
 190   ASSERT (category_equals (uc_general_category_byname ("LineSeparator"), UC_CATEGORY_Zl));
 191   ASSERT (category_equals (uc_general_category_byname ("PARAGRAPH SEPARATOR"), UC_CATEGORY_Zp));
 192   ASSERT (category_equals (uc_general_category_byname ("Paragraph Separator"), UC_CATEGORY_Zp));
 193   ASSERT (category_equals (uc_general_category_byname ("Paragraph_Separator"), UC_CATEGORY_Zp));
 194   ASSERT (category_equals (uc_general_category_byname ("ParagraphSeparator"), UC_CATEGORY_Zp));
 195   ASSERT (category_equals (uc_general_category_byname ("OTHER"), UC_CATEGORY_C));
 196   ASSERT (category_equals (uc_general_category_byname ("Other"), UC_CATEGORY_C));
 197   ASSERT (category_equals (uc_general_category_byname ("CONTROL"), UC_CATEGORY_Cc));
 198   ASSERT (category_equals (uc_general_category_byname ("Control"), UC_CATEGORY_Cc));
 199   ASSERT (category_equals (uc_general_category_byname ("FORMAT"), UC_CATEGORY_Cf));
 200   ASSERT (category_equals (uc_general_category_byname ("Format"), UC_CATEGORY_Cf));
 201   ASSERT (category_equals (uc_general_category_byname ("SURROGATE"), UC_CATEGORY_Cs));
 202   ASSERT (category_equals (uc_general_category_byname ("Surrogate"), UC_CATEGORY_Cs));
 203   ASSERT (category_equals (uc_general_category_byname ("PRIVATE USE"), UC_CATEGORY_Co));
 204   ASSERT (category_equals (uc_general_category_byname ("Private Use"), UC_CATEGORY_Co));
 205   ASSERT (category_equals (uc_general_category_byname ("Private_Use"), UC_CATEGORY_Co));
 206   ASSERT (category_equals (uc_general_category_byname ("PrivateUse"), UC_CATEGORY_Co));
 207   ASSERT (category_equals (uc_general_category_byname ("UNASSIGNED"), UC_CATEGORY_Cn));
 208   ASSERT (category_equals (uc_general_category_byname ("Unassigned"), UC_CATEGORY_Cn));
 209 
 210   uc_general_category_byname ("Nl");
 211 
 212   {
 213     uc_general_category_t ct = uc_general_category_byname ("Nd");
 214     unsigned int c;
 215 
 216     for (c = 0x30; c <= 0x39; c++)
 217       ASSERT (uc_is_general_category (c, ct));
 218     for (c = 0x40; c < 0x80; c++)
 219       ASSERT (!uc_is_general_category (c, ct));
 220   }
 221 
 222   {
 223     uc_general_category_t ct = uc_general_category_byname ("Foo");
 224     unsigned int c;
 225 
 226     for (c = 0; c < 0x110000; c++)
 227       ASSERT (!uc_is_general_category (c, ct));
 228   }
 229 
 230   return 0;
 231 }

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