libmicrohttpd2

HTTP server C library (MHD 2.x, alpha)
Log | Files | Refs | README | LICENSE

unit_str_compare.c (34078B)


      1 /*
      2   This file is part of libmicrohttpd
      3   Copyright (C) 2016 Karlson2k (Evgeny Grin)
      4 
      5   This test tool is free software; you can redistribute it and/or
      6   modify it under the terms of the GNU General Public License as
      7   published by the Free Software Foundation; either version 2, or
      8   (at your option) any later version.
      9 
     10   This test tool is distributed in the hope that it will be useful,
     11   but WITHOUT ANY WARRANTY; without even the implied warranty of
     12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     13   Lesser General Public License for more details.
     14 
     15   You should have received a copy of the GNU Lesser General Public
     16   License along with this library; if not, write to the Free Software
     17   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
     18 */
     19 
     20 /**
     21  * @file src/tests/unit/unit_str_test.h
     22  * @brief  Unit tests for mhd_str functions
     23  * @author Karlson2k (Evgeny Grin)
     24  */
     25 
     26 #include "mhd_sys_options.h"
     27 
     28 #include <stdio.h>
     29 #include <locale.h>
     30 #include <string.h>
     31 #ifdef HAVE_INTTYPES_H
     32 #include <inttypes.h>
     33 #else  /* ! HAVE_INTTYPES_H */
     34 #define PRIu64  "llu"
     35 #define PRIuPTR "u"
     36 #define PRIX64 "llX"
     37 #endif /* ! HAVE_INTTYPES_H */
     38 #include <stdint.h>
     39 #ifdef HAVE_STDLIB_H
     40 #include <stdlib.h>
     41 #endif /* HAVE_STDLIB_H */
     42 
     43 #include "mhd_limits.h"
     44 
     45 #include "mhd_str.h"
     46 #include "mhd_str.c"
     47 #include "mhdt_checks.h"
     48 #include "mhdt_has_param.h"
     49 
     50 
     51 static int verbose = 0; /* verbose level (0-3)*/
     52 
     53 /* Locale names to test.
     54  * Functions must not depend of current current locale,
     55  * so result must be the same in any locale.
     56  */
     57 static const char *const locale_names[] = {
     58   "C",
     59   "",        /* System default locale */
     60 #if defined(_WIN32) && ! defined(__CYGWIN__)
     61   ".OCP",    /* W32 system default OEM code page */
     62   ".ACP",    /* W32 system default ANSI code page */
     63   ".65001",  /* UTF-8 */
     64   ".437",
     65   ".850",
     66   ".857",
     67   ".866",
     68   ".1250",
     69   ".1251",
     70   ".1252",
     71   "en",
     72   "english",
     73   "French_France",
     74   "Turkish_Turkey.1254",
     75   "de",
     76   "zh-Hans",
     77   "ru-RU.1251"
     78 #if 0 /* Disabled extra checks */
     79   ,
     80   ".1254",
     81   ".20866",   /* number for KOI8-R */
     82   ".28591",   /* number for ISO-8859-1 */
     83   ".28595",   /* number for ISO-8859-5 */
     84   ".28599",   /* number for ISO-8859-9 */
     85   ".28605",   /* number for ISO-8859-15 */
     86   "en-US",
     87   "English-US",
     88   "en-US.437",
     89   "English_United States.437",
     90   "en-US.1252",
     91   "English_United States.1252",
     92   "English_United States.28591",
     93   "English_United States.65001",
     94   "fra",
     95   "french",
     96   "fr-FR",
     97   "fr-FR.850",
     98   "french_france.850",
     99   "fr-FR.1252",
    100   "French_france.1252",
    101   "French_france.28605",
    102   "French_France.65001",
    103   "de-DE",
    104   "de-DE.850",
    105   "German_Germany.850",
    106   "German_Germany.1250",
    107   "de-DE.1252",
    108   "German_Germany.1252",
    109   "German_Germany.28605",
    110   "German_Germany.65001",
    111   "tr",
    112   "trk",
    113   "turkish",
    114   "tr-TR",
    115   "tr-TR.1254",
    116   "tr-TR.857",
    117   "Turkish_Turkey.857",
    118   "Turkish_Turkey.28599",
    119   "Turkish_Turkey.65001",
    120   "ru",
    121   "ru-RU",
    122   "Russian",
    123   "ru-RU.866",
    124   "Russian_Russia.866",
    125   "Russian_Russia.1251",
    126   "Russian_Russia.20866",
    127   "Russian_Russia.28595",
    128   "Russian_Russia.65001",
    129   "zh-Hans.936",
    130   "chinese-simplified"
    131 #endif /* Disabled extra checks */
    132 #else /* ! _WIN32 || __CYGWIN__ */
    133   "C.UTF-8",
    134   "POSIX",
    135   "en",
    136   "en_US",
    137   "en_US.ISO-8859-1",
    138   "en_US.ISO_8859-1",
    139   "en_US.ISO8859-1",
    140   "en_US.iso88591",
    141   "en_US.ISO-8859-15",
    142   "en_US.DIS_8859-15",
    143   "en_US.ISO8859-15",
    144   "en_US.iso885915",
    145   "en_US.1252",
    146   "en_US.CP1252",
    147   "en_US.UTF-8",
    148   "en_US.utf8",
    149   "fr",
    150   "fr_FR",
    151   "fr_FR.850",
    152   "fr_FR.IBM850",
    153   "fr_FR.1252",
    154   "fr_FR.CP1252",
    155   "fr_FR.ISO-8859-1",
    156   "fr_FR.ISO_8859-1",
    157   "fr_FR.ISO8859-1",
    158   "fr_FR.iso88591",
    159   "fr_FR.ISO-8859-15",
    160   "fr_FR.DIS_8859-15",
    161   "fr_FR.ISO8859-15",
    162   "fr_FR.iso8859-15",
    163   "fr_FR.UTF-8",
    164   "fr_FR.utf8",
    165   "de",
    166   "de_DE",
    167   "de_DE.850",
    168   "de_DE.IBM850",
    169   "de_DE.1250",
    170   "de_DE.CP1250",
    171   "de_DE.1252",
    172   "de_DE.CP1252",
    173   "de_DE.ISO-8859-1",
    174   "de_DE.ISO_8859-1",
    175   "de_DE.ISO8859-1",
    176   "de_DE.iso88591",
    177   "de_DE.ISO-8859-15",
    178   "de_DE.DIS_8859-15",
    179   "de_DE.ISO8859-15",
    180   "de_DE.iso885915",
    181   "de_DE.UTF-8",
    182   "de_DE.utf8",
    183   "tr",
    184   "tr_TR",
    185   "tr_TR.1254",
    186   "tr_TR.CP1254",
    187   "tr_TR.857",
    188   "tr_TR.IBM857",
    189   "tr_TR.ISO-8859-9",
    190   "tr_TR.ISO8859-9",
    191   "tr_TR.iso88599",
    192   "tr_TR.UTF-8",
    193   "tr_TR.utf8",
    194   "ru",
    195   "ru_RU",
    196   "ru_RU.1251",
    197   "ru_RU.CP1251",
    198   "ru_RU.866",
    199   "ru_RU.IBM866",
    200   "ru_RU.KOI8-R",
    201   "ru_RU.koi8-r",
    202   "ru_RU.KOI8-RU",
    203   "ru_RU.ISO-8859-5",
    204   "ru_RU.ISO_8859-5",
    205   "ru_RU.ISO8859-5",
    206   "ru_RU.iso88595",
    207   "ru_RU.UTF-8",
    208   "zh_CN",
    209   "zh_CN.GB2312",
    210   "zh_CN.UTF-8",
    211 #endif /* ! _WIN32 || __CYGWIN__ */
    212 };
    213 
    214 static const unsigned int locale_name_count = sizeof(locale_names)
    215                                               / sizeof(locale_names[0]);
    216 
    217 
    218 /*
    219  *  Helper functions
    220  */
    221 
    222 static int
    223 set_test_locale (size_t num)
    224 {
    225   if (num >= locale_name_count)
    226   {
    227     fprintf (stderr, "Unexpected number of locale.\n");
    228     exit (99);
    229   }
    230   if (verbose > 2)
    231     printf ("Setting locale \"%s\":", locale_names[num]);
    232   if (setlocale (LC_ALL, locale_names[num]))
    233   {
    234     if (verbose > 2)
    235       printf (" succeed.\n");
    236     return 1;
    237   }
    238   if (verbose > 2)
    239     printf (" failed.\n");
    240   return 0;
    241 }
    242 
    243 
    244 static const char *
    245 get_current_locale_str (void)
    246 {
    247   char const *loc_str = setlocale (LC_ALL, NULL);
    248   return loc_str ? loc_str : "unknown";
    249 }
    250 
    251 
    252 static char tmp_bufs[4][4 * 1024]; /* should be enough for testing */
    253 static size_t buf_idx = 0;
    254 
    255 /* print non-printable chars as char codes */
    256 static char *
    257 n_prnt (const char *str)
    258 {
    259   static char *buf;  /* should be enough for testing */
    260   static const size_t buf_size = sizeof(tmp_bufs[0]);
    261   const unsigned char *p = (const unsigned char *) str;
    262   size_t w_pos = 0;
    263   if (++buf_idx > 3)
    264     buf_idx = 0;
    265   buf = tmp_bufs[buf_idx];
    266 
    267   while (*p && w_pos + 1 < buf_size)
    268   {
    269     const unsigned char c = *p;
    270     if ((c == '\\') || (c == '"') )
    271     {
    272       if (w_pos + 2 >= buf_size)
    273         break;
    274       buf[w_pos++] = '\\';
    275       buf[w_pos++] = (char) c;
    276     }
    277     else if ((c >= 0x20) && (c <= 0x7E) )
    278       buf[w_pos++] = (char) c;
    279     else
    280     {
    281       if (w_pos + 4 >= buf_size)
    282         break;
    283       if (snprintf (buf + w_pos, buf_size - w_pos, "\\x%02hX", (short unsigned
    284                                                                 int) c) != 4)
    285         break;
    286       w_pos += 4;
    287     }
    288     p++;
    289   }
    290   if (*p)
    291   {   /* not full string is printed */
    292       /* enough space for "..." ? */
    293     if (w_pos + 3 > buf_size)
    294       w_pos = buf_size - 4;
    295     buf[w_pos++] = '.';
    296     buf[w_pos++] = '.';
    297     buf[w_pos++] = '.';
    298   }
    299   buf[w_pos] = 0;
    300   return buf;
    301 }
    302 
    303 
    304 struct str_with_len
    305 {
    306   const char *const str;
    307   const size_t len;
    308 };
    309 
    310 #define D_STR_W_LEN(s) {(s), (sizeof((s)) / sizeof(char)) - 1}
    311 
    312 /*
    313  * String caseless equality functions tests
    314  */
    315 
    316 struct two_eq_strs
    317 {
    318   const struct str_with_len s1;
    319   const struct str_with_len s2;
    320 };
    321 
    322 static const struct two_eq_strs eq_strings[] = {
    323   {D_STR_W_LEN ("1234567890!@~%&$@#{}[]\\/!?`."),
    324    D_STR_W_LEN ("1234567890!@~%&$@#{}[]\\/!?`.")},
    325   {D_STR_W_LEN ("Simple string."), D_STR_W_LEN ("Simple string.")},
    326   {D_STR_W_LEN ("SIMPLE STRING."), D_STR_W_LEN ("SIMPLE STRING.")},
    327   {D_STR_W_LEN ("simple string."), D_STR_W_LEN ("simple string.")},
    328   {D_STR_W_LEN ("simple string."), D_STR_W_LEN ("Simple String.")},
    329   {D_STR_W_LEN ("sImPlE StRiNg."), D_STR_W_LEN ("SiMpLe sTrInG.")},
    330   {D_STR_W_LEN ("SIMPLE STRING."), D_STR_W_LEN ("simple string.")},
    331   {D_STR_W_LEN ("abcdefghijklmnopqrstuvwxyz"),
    332    D_STR_W_LEN ("abcdefghijklmnopqrstuvwxyz")},
    333   {D_STR_W_LEN ("ABCDEFGHIJKLMNOPQRSTUVWXYZ"),
    334    D_STR_W_LEN ("ABCDEFGHIJKLMNOPQRSTUVWXYZ")},
    335   {D_STR_W_LEN ("abcdefghijklmnopqrstuvwxyz"),
    336    D_STR_W_LEN ("ABCDEFGHIJKLMNOPQRSTUVWXYZ")},
    337   {D_STR_W_LEN ("zyxwvutsrqponMLKJIHGFEDCBA"),
    338    D_STR_W_LEN ("ZYXWVUTSRQPONmlkjihgfedcba")},
    339 
    340   {D_STR_W_LEN ("Cha\x8cne pour le test."),
    341    D_STR_W_LEN ("Cha\x8cne pour le test.")},      /* "Chaîne pour le test." in CP850 */
    342   {D_STR_W_LEN ("cha\x8cne pOur Le TEst."),
    343    D_STR_W_LEN ("Cha\x8cne poUr Le teST.")},
    344   {D_STR_W_LEN ("Cha\xeene pour le test."),
    345    D_STR_W_LEN ("Cha\xeene pour le test.")},      /* "Chaîne pour le test." in CP1252/ISO-8859-1/ISO-8859-15 */
    346   {D_STR_W_LEN ("CHa\xeene POUR le test."),
    347    D_STR_W_LEN ("Cha\xeeNe pour lE TEST.")},
    348   {D_STR_W_LEN ("Cha\xc3\xaene pour le Test."),
    349    D_STR_W_LEN ("Cha\xc3\xaene pour le Test.")},  /* "Chaîne pour le test." in UTF-8 */
    350   {D_STR_W_LEN ("ChA\xc3\xaene pouR lE TesT."),
    351    D_STR_W_LEN ("Cha\xc3\xaeNe Pour le teSt.")},
    352 
    353   {D_STR_W_LEN (".Beispiel Zeichenfolge"),
    354    D_STR_W_LEN (".Beispiel Zeichenfolge")},
    355   {D_STR_W_LEN (".bEisPiel ZEIchenfoLgE"),
    356    D_STR_W_LEN (".BEiSpiEl zeIcheNfolge")},
    357 
    358   {D_STR_W_LEN ("Do\xa7rulama \x87izgi!"),
    359    D_STR_W_LEN ("Do\xa7rulama \x87izgi!")},       /* "Doğrulama çizgi!" in CP857 */
    360   {D_STR_W_LEN ("Do\xa7rulama \x87IzgI!"),        /* Spelling intentionally incorrect here */
    361    D_STR_W_LEN ("Do\xa7rulama \x87izgi!")},       /* Note: 'i' is not caseless equal to 'I' in Turkish */
    362   {D_STR_W_LEN ("Do\xf0rulama \xe7izgi!"),
    363    D_STR_W_LEN ("Do\xf0rulama \xe7izgi!")},       /* "Doğrulama çizgi!" in CP1254/ISO-8859-9 */
    364   {D_STR_W_LEN ("Do\xf0rulamA \xe7Izgi!"),
    365    D_STR_W_LEN ("do\xf0rulama \xe7izgi!")},
    366   {D_STR_W_LEN ("Do\xc4\x9frulama \xc3\xa7izgi!"),
    367    D_STR_W_LEN ("Do\xc4\x9frulama \xc3\xa7izgi!")},         /* "Doğrulama çizgi!" in UTF-8 */
    368   {D_STR_W_LEN ("do\xc4\x9fruLAMA \xc3\xa7Izgi!"),          /* Spelling intentionally incorrect here */
    369    D_STR_W_LEN ("DO\xc4\x9frulama \xc3\xa7izgI!")},         /* Spelling intentionally incorrect here */
    370 
    371   {D_STR_W_LEN ("\x92\xa5\xe1\xe2\xae\xa2\xa0\xef \x91\xe2\xe0\xae\xaa\xa0."),
    372    D_STR_W_LEN ("\x92\xa5\xe1\xe2\xae\xa2\xa0\xef \x91\xe2\xe0\xae\xaa\xa0.")},  /* "Тестовая Строка." in CP866 */
    373   {D_STR_W_LEN ("\xd2\xe5\xf1\xf2\xee\xe2\xe0\xff \xd1\xf2\xf0\xee\xea\xe0."),
    374    D_STR_W_LEN ("\xd2\xe5\xf1\xf2\xee\xe2\xe0\xff \xd1\xf2\xf0\xee\xea\xe0.")},  /* "Тестовая Строка." in CP1251 */
    375   {D_STR_W_LEN ("\xf4\xc5\xd3\xd4\xcf\xd7\xc1\xd1 \xf3\xd4\xd2\xcf\xcb\xc1."),
    376    D_STR_W_LEN ("\xf4\xc5\xd3\xd4\xcf\xd7\xc1\xd1 \xf3\xd4\xd2\xcf\xcb\xc1.")},  /* "Тестовая Строка." in KOI8-R */
    377   {D_STR_W_LEN ("\xc2\xd5\xe1\xe2\xde\xd2\xd0\xef \xc1\xe2\xe0\xde\xda\xd0."),
    378    D_STR_W_LEN ("\xc2\xd5\xe1\xe2\xde\xd2\xd0\xef \xc1\xe2\xe0\xde\xda\xd0.")},  /* "Тестовая Строка." in ISO-8859-5 */
    379   {D_STR_W_LEN ("\xd0\xa2\xd0\xb5\xd1\x81\xd1\x82\xd0\xbe\xd0\xb2\xd0\xb0\xd1"
    380                 "\x8f \xd0\xa1\xd1\x82\xd1\x80\xd0\xbe\xd0\xba\xd0\xb0."),
    381    D_STR_W_LEN ("\xd0\xa2\xd0\xb5\xd1\x81\xd1\x82\xd0\xbe\xd0\xb2\xd0\xb0\xd1"
    382                 "\x8f \xd0\xa1\xd1\x82\xd1\x80\xd0\xbe\xd0\xba\xd0\xb0.")},      /* "Тестовая Строка." in UTF-8 */
    383 
    384   {D_STR_W_LEN (
    385      "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14"
    386      "\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@[\\]"
    387      "^_`{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90"
    388      "\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4"
    389      "\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8"
    390      "\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc"
    391      "\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0"
    392      "\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4"
    393      "\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"),
    394    D_STR_W_LEN (
    395      "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14"
    396      "\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@[\\]"
    397      "^_`{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90"
    398      "\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4"
    399      "\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8"
    400      "\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc"
    401      "\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0"
    402      "\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4"
    403      "\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff")},             /* Full sequence without a-z */
    404   {D_STR_W_LEN (
    405      "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14"
    406      "\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@AB"
    407      "CDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83"
    408      "\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97"
    409      "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab"
    410      "\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
    411      "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3"
    412      "\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
    413      "\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb"
    414      "\xfc\xfd\xfe\xff"),
    415    D_STR_W_LEN (
    416      "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14"
    417      "\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@AB"
    418      "CDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83"
    419      "\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97"
    420      "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab"
    421      "\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
    422      "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3"
    423      "\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
    424      "\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb"
    425      "\xfc\xfd\xfe\xff")},             /* Full sequence */
    426   {D_STR_W_LEN (
    427      "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14"
    428      "\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@AB"
    429      "CDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89"
    430      "\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d"
    431      "\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1"
    432      "\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5"
    433      "\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9"
    434      "\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed"
    435      "\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff")
    436    ,
    437    D_STR_W_LEN (
    438      "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14"
    439      "\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ab"
    440      "cdefghijklmnopqrstuvwxyz[\\]^_`{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89"
    441      "\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d"
    442      "\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1"
    443      "\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5"
    444      "\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9"
    445      "\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed"
    446      "\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff")
    447   }                                                                                           /* Full with A/a match */
    448 };
    449 
    450 struct two_neq_strs
    451 {
    452   const struct str_with_len s1;
    453   const struct str_with_len s2;
    454   const size_t dif_pos;
    455 };
    456 
    457 static const struct two_neq_strs neq_strings[] = {
    458   {D_STR_W_LEN ("1234567890!@~%&$@#{}[]\\/!?`."),
    459    D_STR_W_LEN ("1234567890!@~%&$@#{}[]\\/!?`"), 27},
    460   {D_STR_W_LEN (".1234567890!@~%&$@#{}[]\\/!?`."),
    461    D_STR_W_LEN ("1234567890!@~%&$@#{}[]\\/!?`"), 0},
    462   {D_STR_W_LEN ("Simple string."), D_STR_W_LEN ("Simple ctring."), 7},
    463   {D_STR_W_LEN ("simple string."), D_STR_W_LEN ("simple string"), 13},
    464   {D_STR_W_LEN ("simple strings"), D_STR_W_LEN ("Simple String."), 13},
    465   {D_STR_W_LEN ("sImPlE StRiNg."), D_STR_W_LEN ("SYMpLe sTrInG."), 1},
    466   {D_STR_W_LEN ("SIMPLE STRING."), D_STR_W_LEN ("simple string.2"), 14},
    467   {D_STR_W_LEN ("abcdefghijklmnopqrstuvwxyz,"),
    468    D_STR_W_LEN ("abcdefghijklmnopqrstuvwxyz."), 26},
    469   {D_STR_W_LEN ("abcdefghijklmnopqrstuvwxyz!"),
    470    D_STR_W_LEN ("ABCDEFGHIJKLMNOPQRSTUVWXYZ?"), 26},
    471   {D_STR_W_LEN ("zyxwvutsrqponwMLKJIHGFEDCBA"),
    472    D_STR_W_LEN ("ZYXWVUTSRQPON%mlkjihgfedcba"), 13},
    473 
    474   {D_STR_W_LEN ("S\xbdur veulent plus d'\xbdufs."),         /* "Sœur veulent plus d'œufs." in ISO-8859-15 */
    475    D_STR_W_LEN ("S\xbcUR VEULENT PLUS D'\xbcUFS."), 1}, /* "SŒUR VEULENT PLUS D'ŒUFS." in ISO-8859-15 */
    476   {D_STR_W_LEN ("S\x9cur veulent plus d'\x9cufs."),         /* "Sœur veulent plus d'œufs." in CP1252 */
    477    D_STR_W_LEN ("S\x8cUR VEULENT PLUS D'\x8cUFS."), 1}, /* "SŒUR VEULENT PLUS D'ŒUFS." in CP1252 */
    478   {D_STR_W_LEN ("S\xc5\x93ur veulent plus d'\xc5\x93ufs."), /* "Sœur veulent plus d'œufs." in UTF-8 */
    479    D_STR_W_LEN ("S\xc5\x92UR VEULENT PLUS D'\xc5\x92UFS."), 2}, /* "SŒUR VEULENT PLUS D'ŒUFS." in UTF-8 */
    480 
    481   {D_STR_W_LEN ("Um ein sch\x94nes M\x84" "dchen zu k\x81ssen."),              /* "Um ein schönes Mädchen zu küssen." in CP850 */
    482    D_STR_W_LEN ("UM EIN SCH\x99NES M\x8e" "DCHEN ZU K\x9aSSEN."), 10}, /* "UM EIN SCHÖNES MÄDCHEN ZU KÜSSEN." in CP850 */
    483   {D_STR_W_LEN ("Um ein sch\xf6nes M\xe4" "dchen zu k\xfcssen."),              /* "Um ein schönes Mädchen zu küssen." in ISO-8859-1/ISO-8859-15/CP1250/CP1252 */
    484    D_STR_W_LEN ("UM EIN SCH\xd6NES M\xc4" "DCHEN ZU K\xdcSSEN."), 10}, /* "UM EIN SCHÖNES MÄDCHEN ZU KÜSSEN." in ISO-8859-1/ISO-8859-15/CP1250/CP1252 */
    485   {D_STR_W_LEN ("Um ein sch\xc3\xb6nes M\xc3\xa4" "dchen zu k\xc3\xbcssen."),  /* "Um ein schönes Mädchen zu küssen." in UTF-8 */
    486    D_STR_W_LEN ("UM EIN SCH\xc3\x96NES M\xc3\x84" "DCHEN ZU K\xc3\x9cSSEN."),
    487    11},                                                                        /* "UM EIN SCHÖNES MÄDCHEN ZU KÜSSEN." in UTF-8 */
    488 
    489   {D_STR_W_LEN ("\x98stanbul"),                                                /* "İstanbul" in CP857 */
    490    D_STR_W_LEN ("istanbul"), 0},                                               /* "istanbul" in CP857 */
    491   {D_STR_W_LEN ("\xddstanbul"),                                                /* "İstanbul" in ISO-8859-9/CP1254 */
    492    D_STR_W_LEN ("istanbul"), 0},                                               /* "istanbul" in ISO-8859-9/CP1254 */
    493   {D_STR_W_LEN ("\xc4\xb0stanbul"),                                            /* "İstanbul" in UTF-8 */
    494    D_STR_W_LEN ("istanbul"), 0},                                               /* "istanbul" in UTF-8 */
    495   {D_STR_W_LEN ("Diyarbak\x8dr"),                                              /* "Diyarbakır" in CP857 */
    496    D_STR_W_LEN ("DiyarbakIR"), 8},                                             /* "DiyarbakIR" in CP857 */
    497   {D_STR_W_LEN ("Diyarbak\xfdr"),                                              /* "Diyarbakır" in ISO-8859-9/CP1254 */
    498    D_STR_W_LEN ("DiyarbakIR"), 8},                                             /* "DiyarbakIR" in ISO-8859-9/CP1254 */
    499   {D_STR_W_LEN ("Diyarbak\xc4\xb1r"),                                          /* "Diyarbakır" in UTF-8 */
    500    D_STR_W_LEN ("DiyarbakIR"), 8},                                             /* "DiyarbakIR" in UTF-8 */
    501 
    502   {D_STR_W_LEN ("\x92\xa5\xe1\xe2\xae\xa2\xa0\xef \x91\xe2\xe0\xae\xaa\xa0."), /* "Тестовая Строка." in CP866 */
    503    D_STR_W_LEN ("\x92\x85\x91\x92\x8e\x82\x80\x9f \x91\x92\x90\x8e\x8a\x80."),
    504    1},                                                                         /* "ТЕСТОВАЯ СТРОКА." in CP866 */
    505   {D_STR_W_LEN ("\xd2\xe5\xf1\xf2\xee\xe2\xe0\xff \xd1\xf2\xf0\xee\xea\xe0."), /* "Тестовая Строка." in CP1251 */
    506    D_STR_W_LEN ("\xd2\xc5\xd1\xd2\xce\xc2\xc0\xdf \xd1\xd2\xd0\xce\xca\xc0."),
    507    1},                                                                         /* "ТЕСТОВАЯ СТРОКА." in CP1251 */
    508   {D_STR_W_LEN ("\xf4\xc5\xd3\xd4\xcf\xd7\xc1\xd1 \xf3\xd4\xd2\xcf\xcb\xc1."), /* "Тестовая Строка." in KOI8-R */
    509    D_STR_W_LEN ("\xf4\xe5\xf3\xf4\xef\xf7\xe1\xf1 \xf3\xf4\xf2\xef\xeb\xe1."),
    510    1},                                                                         /* "ТЕСТОВАЯ СТРОКА." in KOI8-R */
    511   {D_STR_W_LEN ("\xc2\xd5\xe1\xe2\xde\xd2\xd0\xef \xc1\xe2\xe0\xde\xda\xd0."), /* "Тестовая Строка." in ISO-8859-5 */
    512    D_STR_W_LEN ("\xc2\xb5\xc1\xc2\xbe\xb2\xb0\xcf \xc1\xc2\xc0\xbe\xba\xb0."),
    513    1},                                                                         /* "ТЕСТОВАЯ СТРОКА." in ISO-8859-5 */
    514   {D_STR_W_LEN ("\xd0\xa2\xd0\xb5\xd1\x81\xd1\x82\xd0\xbe\xd0\xb2\xd0\xb0\xd1"
    515                 "\x8f \xd0\xa1\xd1\x82\xd1\x80\xd0\xbe\xd0\xba\xd0\xb0."),     /* "Тестовая Строка." in UTF-8 */
    516    D_STR_W_LEN ("\xd0\xa2\xd0\x95\xd0\xa1\xd0\xa2\xd0\x9e\xd0\x92\xd0\x90\xd0"
    517                 "\xaf \xd0\xa1\xd0\xa2\xd0\xa0\xd0\x9e\xd0\x9a\xd0\x90."), 3}  /* "ТЕСТОВАЯ СТРОКА." in UTF-8 */
    518 };
    519 
    520 
    521 static size_t
    522 check_eq_strings (void)
    523 {
    524   size_t t_failed = 0;
    525   size_t i, j;
    526   int c_failed[sizeof(eq_strings) / sizeof(eq_strings[0])];
    527   static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]);
    528 
    529   memset (c_failed, 0, sizeof(c_failed));
    530 
    531   for (j = 0; j < locale_name_count; j++)
    532   {
    533     set_test_locale (j);  /* setlocale() can be slow! */
    534     for (i = 0; i < n_checks; i++)
    535     {
    536       const struct two_eq_strs *const t = eq_strings + i;
    537       if (c_failed[i])
    538         continue;     /* skip already failed checks */
    539       if (! mhd_str_equal_caseless (t->s1.str, t->s2.str))
    540       {
    541         t_failed++;
    542         c_failed[i] = ! 0;
    543         fprintf (stderr,
    544                  "FAILED: mhd_str_equal_caseless(\"%s\", \"%s\") returned zero, while expected non-zero."
    545                  " Locale: %s\n", n_prnt (t->s1.str), n_prnt (t->s2.str),
    546                  get_current_locale_str ());
    547       }
    548       else if (! mhd_str_equal_caseless (t->s2.str, t->s1.str))
    549       {
    550         t_failed++;
    551         c_failed[i] = ! 0;
    552         fprintf (stderr,
    553                  "FAILED: mhd_str_equal_caseless(\"%s\", \"%s\") returned zero, while expected non-zero."
    554                  " Locale: %s\n", n_prnt (t->s2.str), n_prnt (t->s1.str),
    555                  get_current_locale_str ());
    556       }
    557       if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i])
    558         printf ("PASSED: mhd_str_equal_caseless(\"%s\", \"%s\") != 0 && \\\n"
    559                 "        mhd_str_equal_caseless(\"%s\", \"%s\") != 0\n",
    560                 n_prnt (t->s1.str), n_prnt (t->s2.str),
    561                 n_prnt (t->s2.str), n_prnt (t->s1.str));
    562     }
    563   }
    564   return t_failed;
    565 }
    566 
    567 
    568 static size_t
    569 check_neq_strings (void)
    570 {
    571   size_t t_failed = 0;
    572   size_t i, j;
    573   int c_failed[sizeof(neq_strings) / sizeof(neq_strings[0])];
    574   static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]);
    575 
    576   memset (c_failed, 0, sizeof(c_failed));
    577 
    578   for (j = 0; j < locale_name_count; j++)
    579   {
    580     set_test_locale (j);  /* setlocale() can be slow! */
    581     for (i = 0; i < n_checks; i++)
    582     {
    583       const struct two_neq_strs *const t = neq_strings + i;
    584       if (c_failed[i])
    585         continue;     /* skip already failed checks */
    586       if (mhd_str_equal_caseless (t->s1.str, t->s2.str))
    587       {
    588         t_failed++;
    589         c_failed[i] = ! 0;
    590         fprintf (stderr,
    591                  "FAILED: mhd_str_equal_caseless(\"%s\", \"%s\") returned non-zero, while expected zero."
    592                  " Locale: %s\n", n_prnt (t->s1.str), n_prnt (t->s2.str),
    593                  get_current_locale_str ());
    594       }
    595       else if (mhd_str_equal_caseless (t->s2.str, t->s1.str))
    596       {
    597         t_failed++;
    598         c_failed[i] = ! 0;
    599         fprintf (stderr,
    600                  "FAILED: mhd_str_equal_caseless(\"%s\", \"%s\") returned non-zero, while expected zero."
    601                  " Locale: %s\n", n_prnt (t->s2.str), n_prnt (t->s1.str),
    602                  get_current_locale_str ());
    603       }
    604       if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i])
    605         printf ("PASSED: mhd_str_equal_caseless(\"%s\", \"%s\") == 0 && \\\n"
    606                 "        mhd_str_equal_caseless(\"%s\", \"%s\") == 0\n",
    607                 n_prnt (t->s1.str), n_prnt (t->s2.str),
    608                 n_prnt (t->s2.str), n_prnt (t->s1.str));
    609     }
    610   }
    611   return t_failed;
    612 }
    613 
    614 
    615 static size_t
    616 check_eq_strings_n (void)
    617 {
    618   size_t t_failed = 0;
    619   size_t i, j, k;
    620   int c_failed[sizeof(eq_strings) / sizeof(eq_strings[0])];
    621   static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]);
    622 
    623   memset (c_failed, 0, sizeof(c_failed));
    624 
    625   for (j = 0; j < locale_name_count; j++)
    626   {
    627     set_test_locale (j);  /* setlocale() can be slow! */
    628     for (i = 0; i < n_checks; i++)
    629     {
    630       size_t m_len;
    631       const struct two_eq_strs *const t = eq_strings + i;
    632       m_len = (t->s1.len > t->s2.len) ? t->s1.len : t->s2.len;
    633       for (k = 0; k <= m_len + 1 && ! c_failed[i]; k++)
    634       {
    635         if (! mhd_str_equal_caseless_n (t->s1.str, t->s2.str, k))
    636         {
    637           t_failed++;
    638           c_failed[i] = ! 0;
    639           fprintf (stderr,
    640                    "FAILED: mhd_str_equal_caseless_n(\"%s\", \"%s\", %u) returned zero,"
    641                    " while expected non-zero. Locale: %s\n",
    642                    n_prnt (t->s1.str), n_prnt (t->s2.str), (unsigned int) k,
    643                    get_current_locale_str ());
    644         }
    645         else if (! mhd_str_equal_caseless_n (t->s2.str, t->s1.str, k))
    646         {
    647           t_failed++;
    648           c_failed[i] = ! 0;
    649           fprintf (stderr,
    650                    "FAILED: mhd_str_equal_caseless_n(\"%s\", \"%s\", %u) returned zero,"
    651                    " while expected non-zero. Locale: %s\n",
    652                    n_prnt (t->s2.str), n_prnt (t->s1.str), (unsigned int) k,
    653                    get_current_locale_str ());
    654         }
    655       }
    656       if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i])
    657         printf ("PASSED: mhd_str_equal_caseless_n(\"%s\", \"%s\", N) " \
    658                 "!= 0 && \\\n" \
    659                 "        mhd_str_equal_caseless_n(\"%s\", \"%s\", N) " \
    660                 "!= 0, where N is 0..%u\n",
    661                 n_prnt (t->s1.str), n_prnt (t->s2.str), n_prnt (t->s2.str),
    662                 n_prnt (t->s1.str), (unsigned int) m_len + 1);
    663     }
    664   }
    665   return t_failed;
    666 }
    667 
    668 
    669 static size_t
    670 check_neq_strings_n (void)
    671 {
    672   size_t t_failed = 0;
    673   size_t i, j, k;
    674   int c_failed[sizeof(neq_strings) / sizeof(neq_strings[0])];
    675   static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]);
    676 
    677   memset (c_failed, 0, sizeof(c_failed));
    678 
    679   for (j = 0; j < locale_name_count; j++)
    680   {
    681     set_test_locale (j);  /* setlocale() can be slow! */
    682     for (i = 0; i < n_checks; i++)
    683     {
    684       size_t m_len;
    685       const struct two_neq_strs *const t = neq_strings + i;
    686       m_len = t->s1.len > t->s2.len ? t->s1.len : t->s2.len;
    687       if (t->dif_pos >= m_len)
    688       {
    689         fprintf (stderr,
    690                  "ERROR: neq_strings[%u] has wrong dif_pos (%u): dif_pos is expected to be less than "
    691                  "s1.len (%u) or s2.len (%u).\n", (unsigned int) i, (unsigned
    692                                                                      int) t->
    693                  dif_pos,
    694                  (unsigned int) t->s1.len, (unsigned int) t->s2.len);
    695         exit (99);
    696       }
    697       if (t->dif_pos > t->s1.len)
    698       {
    699         fprintf (stderr,
    700                  "ERROR: neq_strings[%u] has wrong dif_pos (%u): dif_pos is expected to be less or "
    701                  "equal to s1.len (%u).\n", (unsigned int) i, (unsigned
    702                                                                int) t->dif_pos,
    703                  (unsigned int) t->s1.len);
    704         exit (99);
    705       }
    706       if (t->dif_pos > t->s2.len)
    707       {
    708         fprintf (stderr,
    709                  "ERROR: neq_strings[%u] has wrong dif_pos (%u): dif_pos is expected to be less or "
    710                  "equal to s2.len (%u).\n", (unsigned int) i, (unsigned
    711                                                                int) t->dif_pos,
    712                  (unsigned int) t->s2.len);
    713         exit (99);
    714       }
    715       for (k = 0; k <= m_len + 1 && ! c_failed[i]; k++)
    716       {
    717         if (k <= t->dif_pos)
    718         {
    719           if (! mhd_str_equal_caseless_n (t->s1.str, t->s2.str, k))
    720           {
    721             t_failed++;
    722             c_failed[i] = ! 0;
    723             fprintf (stderr,
    724                      "FAILED: mhd_str_equal_caseless_n(\"%s\", \"%s\", %u) returned zero,"
    725                      " while expected non-zero. Locale: %s\n",
    726                      n_prnt (t->s1.str), n_prnt (t->s2.str), (unsigned int) k,
    727                      get_current_locale_str ());
    728           }
    729           else if (! mhd_str_equal_caseless_n (t->s2.str, t->s1.str, k))
    730           {
    731             t_failed++;
    732             c_failed[i] = ! 0;
    733             fprintf (stderr,
    734                      "FAILED: mhd_str_equal_caseless_n(\"%s\", \"%s\", %u) returned zero,"
    735                      " while expected non-zero. Locale: %s\n",
    736                      n_prnt (t->s2.str), n_prnt (t->s1.str), (unsigned int) k,
    737                      get_current_locale_str ());
    738           }
    739         }
    740         else
    741         {
    742           if (mhd_str_equal_caseless_n (t->s1.str, t->s2.str, k))
    743           {
    744             t_failed++;
    745             c_failed[i] = ! 0;
    746             fprintf (stderr,
    747                      "FAILED: mhd_str_equal_caseless_n(\"%s\", \"%s\", %u) returned non-zero,"
    748                      " while expected zero. Locale: %s\n",
    749                      n_prnt (t->s1.str), n_prnt (t->s2.str), (unsigned int) k,
    750                      get_current_locale_str ());
    751           }
    752           else if (mhd_str_equal_caseless_n (t->s2.str, t->s1.str, k))
    753           {
    754             t_failed++;
    755             c_failed[i] = ! 0;
    756             fprintf (stderr,
    757                      "FAILED: mhd_str_equal_caseless_n(\"%s\", \"%s\", %u) returned non-zero,"
    758                      " while expected zero. Locale: %s\n",
    759                      n_prnt (t->s2.str), n_prnt (t->s1.str), (unsigned int) k,
    760                      get_current_locale_str ());
    761           }
    762         }
    763       }
    764       if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i])
    765       {
    766         printf (
    767           "PASSED: mhd_str_equal_caseless_n(\"%s\", \"%s\", N) != 0 && \\\n"
    768           "        mhd_str_equal_caseless_n(\"%s\", \"%s\", N) != 0, where N is 0..%u\n",
    769           n_prnt (t->s1.str), n_prnt (t->s2.str), n_prnt (t->s2.str),
    770           n_prnt (t->s1.str),
    771           (unsigned int) t->dif_pos);
    772 
    773         printf (
    774           "PASSED: mhd_str_equal_caseless_n(\"%s\", \"%s\", N) == 0 && \\\n"
    775           "        mhd_str_equal_caseless_n(\"%s\", \"%s\", N) == 0, where N is %u..%u\n",
    776           n_prnt (t->s1.str), n_prnt (t->s2.str), n_prnt (t->s2.str),
    777           n_prnt (t->s1.str),
    778           (unsigned int) t->dif_pos + 1, (unsigned int) m_len + 1);
    779       }
    780     }
    781   }
    782   return t_failed;
    783 }
    784 
    785 
    786 /*
    787  * Run eq/neq strings tests
    788  */
    789 static int
    790 run_eq_neq_str_tests (void)
    791 {
    792   size_t str_equal_caseless_fails = 0;
    793   size_t str_equal_caseless_n_fails = 0;
    794   size_t res;
    795 
    796   res = check_eq_strings ();
    797   if (res != 0)
    798   {
    799     str_equal_caseless_fails += res;
    800     fprintf (stderr, "FAILED: testcase check_eq_strings() failed.\n\n");
    801   }
    802   else if (verbose > 1)
    803     printf ("PASSED: testcase check_eq_strings() successfully passed.\n\n");
    804 
    805   res = check_neq_strings ();
    806   if (res != 0)
    807   {
    808     str_equal_caseless_fails += res;
    809     fprintf (stderr, "FAILED: testcase check_neq_strings() failed.\n\n");
    810   }
    811   else if (verbose > 1)
    812     printf ("PASSED: testcase check_neq_strings() successfully passed.\n\n");
    813 
    814   if (str_equal_caseless_fails)
    815     fprintf (stderr,
    816              "FAILED: function mhd_str_equal_caseless() failed %lu time%s.\n\n",
    817              (unsigned long) str_equal_caseless_fails,
    818              str_equal_caseless_fails == 1 ? "" :
    819              "s");
    820   else if (verbose > 0)
    821     printf (
    822       "PASSED: function mhd_str_equal_caseless() successfully passed all checks.\n\n");
    823 
    824   res = check_eq_strings_n ();
    825   if (res != 0)
    826   {
    827     str_equal_caseless_n_fails += res;
    828     fprintf (stderr, "FAILED: testcase check_eq_strings_n() failed.\n\n");
    829   }
    830   else if (verbose > 1)
    831     printf ("PASSED: testcase check_eq_strings_n() successfully passed.\n\n");
    832 
    833   res = check_neq_strings_n ();
    834   if (res != 0)
    835   {
    836     str_equal_caseless_n_fails += res;
    837     fprintf (stderr, "FAILED: testcase check_neq_strings_n() failed.\n\n");
    838   }
    839   else if (verbose > 1)
    840     printf ("PASSED: testcase check_neq_strings_n() successfully passed.\n\n");
    841 
    842   if (str_equal_caseless_n_fails)
    843     fprintf (stderr,
    844              "FAILED: function mhd_str_equal_caseless_n() failed %lu time%s.\n\n",
    845              (unsigned long) str_equal_caseless_n_fails,
    846              str_equal_caseless_n_fails == 1 ? "" :
    847              "s");
    848   else if (verbose > 0)
    849     printf (
    850       "PASSED: function mhd_str_equal_caseless_n() successfully passed all checks.\n\n");
    851 
    852   if (str_equal_caseless_fails || str_equal_caseless_n_fails)
    853   {
    854     if (verbose > 0)
    855       printf ("At least one test failed.\n");
    856 
    857     return 1;
    858   }
    859 
    860   if (verbose > 0)
    861     printf ("All tests passed successfully.\n");
    862 
    863   return 0;
    864 }
    865 
    866 
    867 int
    868 main (int argc,
    869       char *argv[])
    870 {
    871   if (mhdt_has_param (argc, argv, "-v") ||
    872       mhdt_has_param (argc, argv, "--verbose") ||
    873       mhdt_has_param (argc, argv, "--verbose1"))
    874     MHDT_set_verbosity (MHDT_VERB_LVL_BASIC);
    875   if (mhdt_has_param (argc, argv, "-vv") ||
    876       mhdt_has_param (argc, argv, "--verbose2"))
    877     MHDT_set_verbosity (MHDT_VERB_LVL_VERBOSE);
    878 
    879   return run_eq_neq_str_tests ();
    880 }