root/maint/gnulib/tests/unistr/test-u32-check.c

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

DEFINITIONS

This source file includes following definitions.
  1. main

   1 /* Test of u32_check() function.
   2    Copyright (C) 2010-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>, 2010.  */
  18 
  19 #include <config.h>
  20 
  21 #include "unistr.h"
  22 
  23 #include "macros.h"
  24 
  25 int
  26 main ()
     /* [previous][next][first][last][top][bottom][index][help] */
  27 {
  28   /* Test empty string.  */
  29   {
  30     static const uint32_t input[] = { 0 };
  31     ASSERT (u32_check (input, 0) == NULL);
  32   }
  33 
  34   /* Test valid non-empty string.  */
  35   {
  36     static const uint32_t input[] = /* "Данило Шеган" */
  37       { 0x0414, 0x0430, 0x043D, 0x0438, 0x043B, 0x043E, 0x0020, 0x0428, 0x0435, 0x0433, 0x0430, 0x043D };
  38     ASSERT (u32_check (input, SIZEOF (input)) == NULL);
  39   }
  40 
  41   /* Test out-of-range character with 1 unit: U+110000.  */
  42   {
  43     static const uint32_t input[] = { 0x0414, 0x0430, 0x110000 };
  44     ASSERT (u32_check (input, SIZEOF (input)) == input + 2);
  45   }
  46 
  47   /* Test surrogate codepoints.  */
  48   {
  49     static const uint32_t input[] = { 0x0414, 0x0430, 0xDBFF, 0xDFFF };
  50     ASSERT (u32_check (input, SIZEOF (input)) == input + 2);
  51   }
  52   {
  53     static const uint32_t input[] = { 0x0414, 0x0430, 0xDBFF };
  54     ASSERT (u32_check (input, SIZEOF (input)) == input + 2);
  55   }
  56   {
  57     static const uint32_t input[] = { 0x0414, 0x0430, 0xDFFF };
  58     ASSERT (u32_check (input, SIZEOF (input)) == input + 2);
  59   }
  60   {
  61     static const uint32_t input[] = { 0x0414, 0x0430, 0xDFFF, 0xDBFF };
  62     ASSERT (u32_check (input, SIZEOF (input)) == input + 2);
  63   }
  64 
  65   return 0;
  66 }

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