libmicrohttpd2

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

unit_str_compare.c (34358B)


      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",
    546                  n_prnt (t->s1.str),
    547                  n_prnt (t->s2.str),
    548                  get_current_locale_str ());
    549       }
    550       else if (!mhd_str_equal_caseless (t->s2.str, t->s1.str))
    551       {
    552         t_failed++;
    553         c_failed[i] = !0;
    554         fprintf (stderr,
    555                  "FAILED: mhd_str_equal_caseless(\"%s\", \"%s\") returned zero, while expected non-zero."
    556                  " Locale: %s\n",
    557                  n_prnt (t->s2.str),
    558                  n_prnt (t->s1.str),
    559                  get_current_locale_str ());
    560       }
    561       if ((verbose > 1) && (j == locale_name_count - 1) && !c_failed[i])
    562         printf ("PASSED: mhd_str_equal_caseless(\"%s\", \"%s\") != 0 && \\\n"
    563                 "        mhd_str_equal_caseless(\"%s\", \"%s\") != 0\n",
    564                 n_prnt (t->s1.str), n_prnt (t->s2.str),
    565                 n_prnt (t->s2.str), n_prnt (t->s1.str));
    566     }
    567   }
    568   return t_failed;
    569 }
    570 
    571 
    572 static size_t
    573 check_neq_strings (void)
    574 {
    575   size_t t_failed = 0;
    576   size_t i, j;
    577   int c_failed[sizeof(neq_strings) / sizeof(neq_strings[0])];
    578   static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]);
    579 
    580   memset (c_failed, 0, sizeof(c_failed));
    581 
    582   for (j = 0; j < locale_name_count; j++)
    583   {
    584     set_test_locale (j);  /* setlocale() can be slow! */
    585     for (i = 0; i < n_checks; i++)
    586     {
    587       const struct two_neq_strs *const t = neq_strings + i;
    588       if (c_failed[i])
    589         continue;     /* skip already failed checks */
    590       if (mhd_str_equal_caseless (t->s1.str, t->s2.str))
    591       {
    592         t_failed++;
    593         c_failed[i] = !0;
    594         fprintf (stderr,
    595                  "FAILED: mhd_str_equal_caseless(\"%s\", \"%s\") returned non-zero, while expected zero."
    596                  " Locale: %s\n",
    597                  n_prnt (t->s1.str),
    598                  n_prnt (t->s2.str),
    599                  get_current_locale_str ());
    600       }
    601       else if (mhd_str_equal_caseless (t->s2.str, t->s1.str))
    602       {
    603         t_failed++;
    604         c_failed[i] = !0;
    605         fprintf (stderr,
    606                  "FAILED: mhd_str_equal_caseless(\"%s\", \"%s\") returned non-zero, while expected zero."
    607                  " Locale: %s\n",
    608                  n_prnt (t->s2.str),
    609                  n_prnt (t->s1.str),
    610                  get_current_locale_str ());
    611       }
    612       if ((verbose > 1) && (j == locale_name_count - 1) && !c_failed[i])
    613         printf ("PASSED: mhd_str_equal_caseless(\"%s\", \"%s\") == 0 && \\\n"
    614                 "        mhd_str_equal_caseless(\"%s\", \"%s\") == 0\n",
    615                 n_prnt (t->s1.str), n_prnt (t->s2.str),
    616                 n_prnt (t->s2.str), n_prnt (t->s1.str));
    617     }
    618   }
    619   return t_failed;
    620 }
    621 
    622 
    623 static size_t
    624 check_eq_strings_n (void)
    625 {
    626   size_t t_failed = 0;
    627   size_t i, j, k;
    628   int c_failed[sizeof(eq_strings) / sizeof(eq_strings[0])];
    629   static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]);
    630 
    631   memset (c_failed, 0, sizeof(c_failed));
    632 
    633   for (j = 0; j < locale_name_count; j++)
    634   {
    635     set_test_locale (j);  /* setlocale() can be slow! */
    636     for (i = 0; i < n_checks; i++)
    637     {
    638       size_t m_len;
    639       const struct two_eq_strs *const t = eq_strings + i;
    640       m_len = (t->s1.len > t->s2.len) ? t->s1.len : t->s2.len;
    641       for (k = 0; k <= m_len + 1 && !c_failed[i]; k++)
    642       {
    643         if (!mhd_str_equal_caseless_n (t->s1.str, t->s2.str, k))
    644         {
    645           t_failed++;
    646           c_failed[i] = !0;
    647           fprintf (stderr,
    648                    "FAILED: mhd_str_equal_caseless_n(\"%s\", \"%s\", %u) returned zero,"
    649                    " while expected non-zero. Locale: %s\n",
    650                    n_prnt (t->s1.str),
    651                    n_prnt (t->s2.str),
    652                    (unsigned int)k,
    653                    get_current_locale_str ());
    654         }
    655         else if (!mhd_str_equal_caseless_n (t->s2.str, t->s1.str, k))
    656         {
    657           t_failed++;
    658           c_failed[i] = !0;
    659           fprintf (stderr,
    660                    "FAILED: mhd_str_equal_caseless_n(\"%s\", \"%s\", %u) returned zero,"
    661                    " while expected non-zero. Locale: %s\n",
    662                    n_prnt (t->s2.str),
    663                    n_prnt (t->s1.str),
    664                    (unsigned int)k,
    665                    get_current_locale_str ());
    666         }
    667       }
    668       if ((verbose > 1) && (j == locale_name_count - 1) && !c_failed[i])
    669         printf ("PASSED: mhd_str_equal_caseless_n(\"%s\", \"%s\", N) " \
    670                 "!= 0 && \\\n" \
    671                 "        mhd_str_equal_caseless_n(\"%s\", \"%s\", N) " \
    672                 "!= 0, where N is 0..%u\n",
    673                 n_prnt (t->s1.str), n_prnt (t->s2.str), n_prnt (t->s2.str),
    674                 n_prnt (t->s1.str), (unsigned int)m_len + 1);
    675     }
    676   }
    677   return t_failed;
    678 }
    679 
    680 
    681 static size_t
    682 check_neq_strings_n (void)
    683 {
    684   size_t t_failed = 0;
    685   size_t i, j, k;
    686   int c_failed[sizeof(neq_strings) / sizeof(neq_strings[0])];
    687   static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]);
    688 
    689   memset (c_failed, 0, sizeof(c_failed));
    690 
    691   for (j = 0; j < locale_name_count; j++)
    692   {
    693     set_test_locale (j);  /* setlocale() can be slow! */
    694     for (i = 0; i < n_checks; i++)
    695     {
    696       size_t m_len;
    697       const struct two_neq_strs *const t = neq_strings + i;
    698       m_len = t->s1.len > t->s2.len ? t->s1.len : t->s2.len;
    699       if (t->dif_pos >= m_len)
    700       {
    701         fprintf (stderr,
    702                  "ERROR: neq_strings[%u] has wrong dif_pos (%u): dif_pos is expected to be less than "
    703                  "s1.len (%u) or s2.len (%u).\n",
    704                  (unsigned int)i,
    705                  (unsigned
    706                   int)t->
    707                  dif_pos,
    708                  (unsigned int)t->s1.len,
    709                  (unsigned int)t->s2.len);
    710         exit (99);
    711       }
    712       if (t->dif_pos > t->s1.len)
    713       {
    714         fprintf (stderr,
    715                  "ERROR: neq_strings[%u] has wrong dif_pos (%u): dif_pos is expected to be less or "
    716                  "equal to s1.len (%u).\n",
    717                  (unsigned int)i,
    718                  (unsigned
    719                   int)t->dif_pos,
    720                  (unsigned int)t->s1.len);
    721         exit (99);
    722       }
    723       if (t->dif_pos > t->s2.len)
    724       {
    725         fprintf (stderr,
    726                  "ERROR: neq_strings[%u] has wrong dif_pos (%u): dif_pos is expected to be less or "
    727                  "equal to s2.len (%u).\n",
    728                  (unsigned int)i,
    729                  (unsigned
    730                   int)t->dif_pos,
    731                  (unsigned int)t->s2.len);
    732         exit (99);
    733       }
    734       for (k = 0; k <= m_len + 1 && !c_failed[i]; k++)
    735       {
    736         if (k <= t->dif_pos)
    737         {
    738           if (!mhd_str_equal_caseless_n (t->s1.str, t->s2.str, k))
    739           {
    740             t_failed++;
    741             c_failed[i] = !0;
    742             fprintf (stderr,
    743                      "FAILED: mhd_str_equal_caseless_n(\"%s\", \"%s\", %u) returned zero,"
    744                      " while expected non-zero. Locale: %s\n",
    745                      n_prnt (t->s1.str),
    746                      n_prnt (t->s2.str),
    747                      (unsigned int)k,
    748                      get_current_locale_str ());
    749           }
    750           else if (!mhd_str_equal_caseless_n (t->s2.str, t->s1.str, k))
    751           {
    752             t_failed++;
    753             c_failed[i] = !0;
    754             fprintf (stderr,
    755                      "FAILED: mhd_str_equal_caseless_n(\"%s\", \"%s\", %u) returned zero,"
    756                      " while expected non-zero. Locale: %s\n",
    757                      n_prnt (t->s2.str),
    758                      n_prnt (t->s1.str),
    759                      (unsigned int)k,
    760                      get_current_locale_str ());
    761           }
    762         }
    763         else
    764         {
    765           if (mhd_str_equal_caseless_n (t->s1.str, t->s2.str, k))
    766           {
    767             t_failed++;
    768             c_failed[i] = !0;
    769             fprintf (stderr,
    770                      "FAILED: mhd_str_equal_caseless_n(\"%s\", \"%s\", %u) returned non-zero,"
    771                      " while expected zero. Locale: %s\n",
    772                      n_prnt (t->s1.str),
    773                      n_prnt (t->s2.str),
    774                      (unsigned int)k,
    775                      get_current_locale_str ());
    776           }
    777           else if (mhd_str_equal_caseless_n (t->s2.str, t->s1.str, k))
    778           {
    779             t_failed++;
    780             c_failed[i] = !0;
    781             fprintf (stderr,
    782                      "FAILED: mhd_str_equal_caseless_n(\"%s\", \"%s\", %u) returned non-zero,"
    783                      " while expected zero. Locale: %s\n",
    784                      n_prnt (t->s2.str),
    785                      n_prnt (t->s1.str),
    786                      (unsigned int)k,
    787                      get_current_locale_str ());
    788           }
    789         }
    790       }
    791       if ((verbose > 1) && (j == locale_name_count - 1) && !c_failed[i])
    792       {
    793         printf (
    794           "PASSED: mhd_str_equal_caseless_n(\"%s\", \"%s\", N) != 0 && \\\n"
    795           "        mhd_str_equal_caseless_n(\"%s\", \"%s\", N) != 0, where N is 0..%u\n",
    796           n_prnt (t->s1.str),
    797           n_prnt (t->s2.str),
    798           n_prnt (t->s2.str),
    799           n_prnt (t->s1.str),
    800           (unsigned int)t->dif_pos);
    801 
    802         printf (
    803           "PASSED: mhd_str_equal_caseless_n(\"%s\", \"%s\", N) == 0 && \\\n"
    804           "        mhd_str_equal_caseless_n(\"%s\", \"%s\", N) == 0, where N is %u..%u\n",
    805           n_prnt (t->s1.str),
    806           n_prnt (t->s2.str),
    807           n_prnt (t->s2.str),
    808           n_prnt (t->s1.str),
    809           (unsigned int)t->dif_pos + 1,
    810           (unsigned int)m_len + 1);
    811       }
    812     }
    813   }
    814   return t_failed;
    815 }
    816 
    817 
    818 /*
    819  * Run eq/neq strings tests
    820  */
    821 static int
    822 run_eq_neq_str_tests (void)
    823 {
    824   size_t str_equal_caseless_fails = 0;
    825   size_t str_equal_caseless_n_fails = 0;
    826   size_t res;
    827 
    828   res = check_eq_strings ();
    829   if (res != 0)
    830   {
    831     str_equal_caseless_fails += res;
    832     fprintf (stderr, "FAILED: testcase check_eq_strings() failed.\n\n");
    833   }
    834   else if (verbose > 1)
    835     printf ("PASSED: testcase check_eq_strings() successfully passed.\n\n");
    836 
    837   res = check_neq_strings ();
    838   if (res != 0)
    839   {
    840     str_equal_caseless_fails += res;
    841     fprintf (stderr, "FAILED: testcase check_neq_strings() failed.\n\n");
    842   }
    843   else if (verbose > 1)
    844     printf ("PASSED: testcase check_neq_strings() successfully passed.\n\n");
    845 
    846   if (str_equal_caseless_fails)
    847     fprintf (stderr,
    848              "FAILED: function mhd_str_equal_caseless() failed %lu time%s.\n\n",
    849              (unsigned long)str_equal_caseless_fails,
    850              str_equal_caseless_fails == 1 ? "" :
    851              "s");
    852   else if (verbose > 0)
    853     printf (
    854       "PASSED: function mhd_str_equal_caseless() successfully passed all checks.\n\n");
    855 
    856   res = check_eq_strings_n ();
    857   if (res != 0)
    858   {
    859     str_equal_caseless_n_fails += res;
    860     fprintf (stderr, "FAILED: testcase check_eq_strings_n() failed.\n\n");
    861   }
    862   else if (verbose > 1)
    863     printf ("PASSED: testcase check_eq_strings_n() successfully passed.\n\n");
    864 
    865   res = check_neq_strings_n ();
    866   if (res != 0)
    867   {
    868     str_equal_caseless_n_fails += res;
    869     fprintf (stderr, "FAILED: testcase check_neq_strings_n() failed.\n\n");
    870   }
    871   else if (verbose > 1)
    872     printf ("PASSED: testcase check_neq_strings_n() successfully passed.\n\n");
    873 
    874   if (str_equal_caseless_n_fails)
    875     fprintf (stderr,
    876              "FAILED: function mhd_str_equal_caseless_n() failed %lu time%s.\n\n",
    877              (unsigned long)str_equal_caseless_n_fails,
    878              str_equal_caseless_n_fails == 1 ? "" :
    879              "s");
    880   else if (verbose > 0)
    881     printf (
    882       "PASSED: function mhd_str_equal_caseless_n() successfully passed all checks.\n\n");
    883 
    884   if (str_equal_caseless_fails || str_equal_caseless_n_fails)
    885   {
    886     if (verbose > 0)
    887       printf ("At least one test failed.\n");
    888 
    889     return 1;
    890   }
    891 
    892   if (verbose > 0)
    893     printf ("All tests passed successfully.\n");
    894 
    895   return 0;
    896 }
    897 
    898 
    899 int
    900 main (int argc,
    901       char *argv[])
    902 {
    903   if (mhdt_has_param (argc, argv, "-v")
    904       || mhdt_has_param (argc, argv, "--verbose")
    905       || mhdt_has_param (argc, argv, "--verbose1"))
    906     MHDT_set_verbosity (MHDT_VERB_LVL_BASIC);
    907   if (mhdt_has_param (argc, argv, "-vv")
    908       || mhdt_has_param (argc, argv, "--verbose2"))
    909     MHDT_set_verbosity (MHDT_VERB_LVL_VERBOSE);
    910 
    911   return run_eq_neq_str_tests ();
    912 }