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

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

DEFINITIONS

This source file includes following definitions.
  1. main

   1 /* Test of conversion of wide string to string.
   2    Copyright (C) 2019-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>, 2019.  */
  18 
  19 #include <config.h>
  20 
  21 #include <wchar.h>
  22 
  23 #include "signature.h"
  24 SIGNATURE_CHECK (wcstok, wchar_t *,
  25                  (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr));
  26 
  27 #include <string.h>
  28 
  29 #include "macros.h"
  30 
  31 int
  32 main ()
     /* [previous][next][first][last][top][bottom][index][help] */
  33 {
  34   wchar_t string[] = L"hello  world!";
  35   wchar_t delim[] = L" ";
  36   wchar_t *ptr;
  37   wchar_t *ret;
  38 
  39   ret = wcstok (string, delim, &ptr);
  40   ASSERT (ret == string);
  41   ASSERT (memcmp (string, L"hello\0 world!", 14 * sizeof (wchar_t)) == 0);
  42   ASSERT (ptr == string + 6);
  43 
  44   ret = wcstok (NULL, delim, &ptr);
  45   ASSERT (ret == string + 7);
  46   ASSERT (memcmp (string, L"hello\0 world!", 14 * sizeof (wchar_t)) == 0);
  47   ASSERT (ptr == NULL || *ptr == L'\0');
  48 
  49   ret = wcstok (NULL, delim, &ptr);
  50   ASSERT (ret == NULL);
  51 
  52   return 0;
  53 }

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