root/maint/gnulib/tests/test-mbsncasecmp.c

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

DEFINITIONS

This source file includes following definitions.
  1. main

   1 /* Test of case-insensitive string comparison function.
   2    Copyright (C) 2007-2021 Free Software Foundation, Inc.
   3 
   4    This program is free software: you can redistribute it and/or modify
   5    it under the terms of the GNU General Public License as published by
   6    the Free Software Foundation; either version 3 of the License, or
   7    (at your option) any later version.
   8 
   9    This program is distributed in the hope that it will be useful,
  10    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12    GNU General Public License for more details.
  13 
  14    You should have received a copy of the GNU General Public License
  15    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
  16 
  17 /* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
  18 
  19 #include <config.h>
  20 
  21 #include <string.h>
  22 
  23 #include <locale.h>
  24 
  25 #include "macros.h"
  26 
  27 int
  28 main ()
     /* [previous][next][first][last][top][bottom][index][help] */
  29 {
  30   /* configure should already have checked that the locale is supported.  */
  31   if (setlocale (LC_ALL, "") == NULL)
  32     return 1;
  33 
  34   ASSERT (mbsncasecmp ("paragraph", "Paragraph", 1000000) == 0);
  35   ASSERT (mbsncasecmp ("paragraph", "Paragraph", 9) == 0);
  36 
  37   ASSERT (mbsncasecmp ("paragrapH", "parAgRaph", 1000000) == 0);
  38   ASSERT (mbsncasecmp ("paragrapH", "parAgRaph", 9) == 0);
  39 
  40   ASSERT (mbsncasecmp ("paragraph", "paraLyzed", 10) < 0);
  41   ASSERT (mbsncasecmp ("paragraph", "paraLyzed", 9) < 0);
  42   ASSERT (mbsncasecmp ("paragraph", "paraLyzed", 5) < 0);
  43   ASSERT (mbsncasecmp ("paragraph", "paraLyzed", 4) == 0);
  44   ASSERT (mbsncasecmp ("paraLyzed", "paragraph", 10) > 0);
  45   ASSERT (mbsncasecmp ("paraLyzed", "paragraph", 9) > 0);
  46   ASSERT (mbsncasecmp ("paraLyzed", "paragraph", 5) > 0);
  47   ASSERT (mbsncasecmp ("paraLyzed", "paragraph", 4) == 0);
  48 
  49   ASSERT (mbsncasecmp ("para", "paragraph", 10) < 0);
  50   ASSERT (mbsncasecmp ("para", "paragraph", 9) < 0);
  51   ASSERT (mbsncasecmp ("para", "paragraph", 5) < 0);
  52   ASSERT (mbsncasecmp ("para", "paragraph", 4) == 0);
  53   ASSERT (mbsncasecmp ("paragraph", "para", 10) > 0);
  54   ASSERT (mbsncasecmp ("paragraph", "para", 9) > 0);
  55   ASSERT (mbsncasecmp ("paragraph", "para", 5) > 0);
  56   ASSERT (mbsncasecmp ("paragraph", "para", 4) == 0);
  57 
  58   /* The following tests shows how mbsncasecmp() is different from
  59      strncasecmp().  */
  60 
  61   ASSERT (mbsncasecmp ("\303\266zg\303\274r", "\303\226ZG\303\234R", 99) == 0); /* özgür */
  62   ASSERT (mbsncasecmp ("\303\226ZG\303\234R", "\303\266zg\303\274r", 99) == 0); /* özgür */
  63 
  64   /* This test shows how strings of different size can compare equal.  */
  65   ASSERT (mbsncasecmp ("turkish", "TURK\304\260SH", 7) == 0);
  66   ASSERT (mbsncasecmp ("TURK\304\260SH", "turkish", 7) == 0);
  67 
  68   return 0;
  69 }

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