summaryrefslogtreecommitdiff
path: root/tests/unistr
diff options
context:
space:
mode:
authorManuel A. Fernandez Montecelo <manuel.montezelo@gmail.com>2016-05-27 14:35:16 +0100
committerManuel A. Fernandez Montecelo <manuel.montezelo@gmail.com>2016-05-27 14:35:16 +0100
commit3590c846d4c2febbc05b4ad6b14a06edc549e453 (patch)
treee5d38581c2f36e1cca02efedd2d85044d77f76f9 /tests/unistr
parenta9a31b1de5776a3b08a82101a4fa711294f0dd1d (diff)
Imported Upstream version 0.9.6+really0.9.6upstream/0.9.6+really0.9.6
Diffstat (limited to 'tests/unistr')
-rw-r--r--tests/unistr/test-chr.h72
-rw-r--r--tests/unistr/test-cmp.h2
-rw-r--r--tests/unistr/test-cmp2.h2
-rw-r--r--tests/unistr/test-cpy-alloc.h2
-rw-r--r--tests/unistr/test-cpy.h2
-rw-r--r--tests/unistr/test-move.h2
-rw-r--r--tests/unistr/test-set.h2
-rw-r--r--tests/unistr/test-stpcpy.h2
-rw-r--r--tests/unistr/test-stpncpy.h2
-rw-r--r--tests/unistr/test-strcat.h2
-rw-r--r--tests/unistr/test-strchr.h161
-rw-r--r--tests/unistr/test-strcmp.h2
-rw-r--r--tests/unistr/test-strcpy.h2
-rw-r--r--tests/unistr/test-strdup.h2
-rw-r--r--tests/unistr/test-strncat.h2
-rw-r--r--tests/unistr/test-strncmp.h2
-rw-r--r--tests/unistr/test-strncpy.h2
-rw-r--r--tests/unistr/test-strnlen.h2
-rw-r--r--tests/unistr/test-u-strstr.h210
-rw-r--r--tests/unistr/test-u-strtok.h88
-rw-r--r--tests/unistr/test-u16-check.c2
-rw-r--r--tests/unistr/test-u16-chr.c5
-rw-r--r--tests/unistr/test-u16-cmp.c2
-rw-r--r--tests/unistr/test-u16-cmp2.c2
-rw-r--r--tests/unistr/test-u16-cpy-alloc.c2
-rw-r--r--tests/unistr/test-u16-cpy.c2
-rw-r--r--tests/unistr/test-u16-mblen.c2
-rw-r--r--tests/unistr/test-u16-mbsnlen.c2
-rw-r--r--tests/unistr/test-u16-mbtouc-unsafe.c2
-rw-r--r--tests/unistr/test-u16-mbtouc.c2
-rw-r--r--tests/unistr/test-u16-mbtouc.h2
-rw-r--r--tests/unistr/test-u16-mbtoucr.c2
-rw-r--r--tests/unistr/test-u16-move.c2
-rw-r--r--tests/unistr/test-u16-next.c2
-rw-r--r--tests/unistr/test-u16-prev.c2
-rw-r--r--tests/unistr/test-u16-set.c2
-rw-r--r--tests/unistr/test-u16-stpcpy.c2
-rw-r--r--tests/unistr/test-u16-stpncpy.c2
-rw-r--r--tests/unistr/test-u16-strcat.c2
-rw-r--r--tests/unistr/test-u16-strchr.c42
-rw-r--r--tests/unistr/test-u16-strcmp.c2
-rw-r--r--tests/unistr/test-u16-strcmp.h2
-rw-r--r--tests/unistr/test-u16-strcoll.c2
-rw-r--r--tests/unistr/test-u16-strcpy.c2
-rw-r--r--tests/unistr/test-u16-strdup.c2
-rw-r--r--tests/unistr/test-u16-strlen.c2
-rw-r--r--tests/unistr/test-u16-strmblen.c2
-rw-r--r--tests/unistr/test-u16-strmbtouc.c2
-rw-r--r--tests/unistr/test-u16-strncat.c2
-rw-r--r--tests/unistr/test-u16-strncmp.c2
-rw-r--r--tests/unistr/test-u16-strncpy.c2
-rw-r--r--tests/unistr/test-u16-strnlen.c2
-rw-r--r--tests/unistr/test-u16-strstr.c47
-rw-r--r--tests/unistr/test-u16-strtok.c37
-rw-r--r--tests/unistr/test-u16-to-u32.c2
-rw-r--r--tests/unistr/test-u16-to-u8.c2
-rw-r--r--tests/unistr/test-u16-uctomb.c2
-rw-r--r--tests/unistr/test-u32-check.c2
-rw-r--r--tests/unistr/test-u32-chr.c5
-rw-r--r--tests/unistr/test-u32-cmp.c2
-rw-r--r--tests/unistr/test-u32-cmp2.c2
-rw-r--r--tests/unistr/test-u32-cpy-alloc.c2
-rw-r--r--tests/unistr/test-u32-cpy.c2
-rw-r--r--tests/unistr/test-u32-mblen.c2
-rw-r--r--tests/unistr/test-u32-mbsnlen.c2
-rw-r--r--tests/unistr/test-u32-mbtouc-unsafe.c2
-rw-r--r--tests/unistr/test-u32-mbtouc.c2
-rw-r--r--tests/unistr/test-u32-mbtouc.h2
-rw-r--r--tests/unistr/test-u32-mbtoucr.c2
-rw-r--r--tests/unistr/test-u32-move.c2
-rw-r--r--tests/unistr/test-u32-next.c2
-rw-r--r--tests/unistr/test-u32-prev.c2
-rw-r--r--tests/unistr/test-u32-set.c2
-rw-r--r--tests/unistr/test-u32-stpcpy.c2
-rw-r--r--tests/unistr/test-u32-stpncpy.c2
-rw-r--r--tests/unistr/test-u32-strcat.c2
-rw-r--r--tests/unistr/test-u32-strchr.c42
-rw-r--r--tests/unistr/test-u32-strcmp.c2
-rw-r--r--tests/unistr/test-u32-strcmp.h2
-rw-r--r--tests/unistr/test-u32-strcoll.c2
-rw-r--r--tests/unistr/test-u32-strcpy.c2
-rw-r--r--tests/unistr/test-u32-strdup.c2
-rw-r--r--tests/unistr/test-u32-strlen.c2
-rw-r--r--tests/unistr/test-u32-strmblen.c2
-rw-r--r--tests/unistr/test-u32-strmbtouc.c2
-rw-r--r--tests/unistr/test-u32-strncat.c2
-rw-r--r--tests/unistr/test-u32-strncmp.c2
-rw-r--r--tests/unistr/test-u32-strncpy.c2
-rw-r--r--tests/unistr/test-u32-strnlen.c2
-rw-r--r--tests/unistr/test-u32-strstr.c47
-rw-r--r--tests/unistr/test-u32-strtok.c37
-rw-r--r--tests/unistr/test-u32-to-u16.c2
-rw-r--r--tests/unistr/test-u32-to-u8.c2
-rw-r--r--tests/unistr/test-u32-uctomb.c2
-rw-r--r--tests/unistr/test-u8-check.c2
-rw-r--r--tests/unistr/test-u8-chr.c5
-rw-r--r--tests/unistr/test-u8-cmp.c2
-rw-r--r--tests/unistr/test-u8-cmp2.c2
-rw-r--r--tests/unistr/test-u8-cpy-alloc.c2
-rw-r--r--tests/unistr/test-u8-cpy.c2
-rw-r--r--tests/unistr/test-u8-mblen.c2
-rw-r--r--tests/unistr/test-u8-mbsnlen.c61
-rw-r--r--tests/unistr/test-u8-mbtouc-unsafe.c2
-rw-r--r--tests/unistr/test-u8-mbtouc.c161
-rw-r--r--tests/unistr/test-u8-mbtouc.h6
-rw-r--r--tests/unistr/test-u8-mbtoucr.c2
-rw-r--r--tests/unistr/test-u8-move.c2
-rw-r--r--tests/unistr/test-u8-next.c2
-rw-r--r--tests/unistr/test-u8-prev.c2
-rw-r--r--tests/unistr/test-u8-set.c2
-rw-r--r--tests/unistr/test-u8-stpcpy.c2
-rw-r--r--tests/unistr/test-u8-stpncpy.c2
-rw-r--r--tests/unistr/test-u8-strcat.c2
-rw-r--r--tests/unistr/test-u8-strchr.c149
-rw-r--r--tests/unistr/test-u8-strcmp.c2
-rw-r--r--tests/unistr/test-u8-strcmp.h2
-rw-r--r--tests/unistr/test-u8-strcoll.c2
-rw-r--r--tests/unistr/test-u8-strcpy.c2
-rw-r--r--tests/unistr/test-u8-strdup.c2
-rw-r--r--tests/unistr/test-u8-strlen.c2
-rw-r--r--tests/unistr/test-u8-strmblen.c2
-rw-r--r--tests/unistr/test-u8-strmbtouc.c2
-rw-r--r--tests/unistr/test-u8-strncat.c2
-rw-r--r--tests/unistr/test-u8-strncmp.c2
-rw-r--r--tests/unistr/test-u8-strncpy.c2
-rw-r--r--tests/unistr/test-u8-strnlen.c2
-rw-r--r--tests/unistr/test-u8-strstr.c50
-rw-r--r--tests/unistr/test-u8-strtok.c37
-rw-r--r--tests/unistr/test-u8-to-u16.c2
-rw-r--r--tests/unistr/test-u8-to-u32.c2
-rw-r--r--tests/unistr/test-u8-uctomb.c2
131 files changed, 1347 insertions, 139 deletions
diff --git a/tests/unistr/test-chr.h b/tests/unistr/test-chr.h
index 5a021c2d..cd5a45e6 100644
--- a/tests/unistr/test-chr.h
+++ b/tests/unistr/test-chr.h
@@ -1,5 +1,5 @@
/* Test of uN_chr() functions.
- Copyright (C) 2008-2010 Free Software Foundation, Inc.
+ Copyright (C) 2008-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,32 +19,65 @@
int
main (void)
{
- size_t n = 0x100000;
- UNIT *input = (UNIT *) malloc (n * sizeof (UNIT));
+ size_t size = 0x100000;
+ size_t i;
+ size_t length;
+ UNIT *input;
+ uint32_t *input32 = (uint32_t *) malloc (size * sizeof (uint32_t));
+ ASSERT (input32);
+
+ input32[0] = 'a';
+ input32[1] = 'b';
+ u32_set (input32 + 2, 'c', 1024);
+ for (i = 1026; i < size - 2; i += 63)
+ {
+ size_t last = i + 63 < size - 2 ? i + 63 : size - 2;
+ ucs4_t uc = 'd' | (i - 1026);
+ if (uc >= 0xd800 && uc <= 0xdfff)
+ uc |= 0x100000;
+ u32_set (input32 + i, uc, last - i);
+ }
+
+ input32[size - 2] = 'e';
+ input32[size - 1] = 'a';
+
+ input = U32_TO_U (input32, size, NULL, &length);
ASSERT (input);
- input[0] = 'a';
- input[1] = 'b';
- U_SET (input + 2, 'c', 1024);
- U_SET (input + 1026, 'd', n - 1028);
- input[n - 2] = 'e';
- input[n - 1] = 'a';
-
/* Basic behavior tests. */
- ASSERT (U_CHR (input, n, 'a') == input);
+ ASSERT (U_CHR (input, length, 'a') == input);
ASSERT (U_CHR (input, 0, 'a') == NULL);
ASSERT (U_CHR (zerosize_ptr (), 0, 'a') == NULL);
- ASSERT (U_CHR (input, n, 'b') == input + 1);
- ASSERT (U_CHR (input, n, 'c') == input + 2);
- ASSERT (U_CHR (input, n, 'd') == input + 1026);
+ ASSERT (U_CHR (input, length, 'b') == input + 1);
+ ASSERT (U_CHR (input, length, 'c') == input + 2);
+ ASSERT (U_CHR (input, length, 'd') == input + 1026);
+
+ {
+ UNIT *exp = input + 1026;
+ UNIT *prev = input + 1;
+ for (i = 1026; i < size - 2; i += 63)
+ {
+ UNIT c[6];
+ size_t n;
+ ucs4_t uc = 'd' | (i - 1026);
+ if (uc >= 0xd800 && uc <= 0xdfff)
+ uc |= 0x100000;
+ n = U_UCTOMB (c, uc, 6);
+ ASSERT (exp < input + length - 1);
+ ASSERT (U_CHR (prev, (length - 1) - (prev - input), uc) == exp);
+ ASSERT (memcmp (exp, c, n * sizeof (UNIT)) == 0);
+ prev = exp;
+ exp += n * 63;
+ }
+ }
- ASSERT (U_CHR (input + 1, n - 1, 'a') == input + n - 1);
- ASSERT (U_CHR (input + 1, n - 1, 'e') == input + n - 2);
+ ASSERT (U_CHR (input + 1, length - 1, 'a') == input + length - 1);
+ ASSERT (U_CHR (input + 1, length - 1, 'e') == input + length - 2);
- ASSERT (U_CHR (input, n, 'f') == NULL);
- ASSERT (U_CHR (input, n, '\0') == NULL);
+ ASSERT (U_CHR (input, length, 'f') == NULL);
+ ASSERT (U_CHR (input, length, '\0') == NULL);
/* Check that a very long haystack is handled quickly if the byte is
found near the beginning. */
@@ -52,7 +85,7 @@ main (void)
size_t repeat = 10000;
for (; repeat > 0; repeat--)
{
- ASSERT (U_CHR (input, n, 'c') == input + 2);
+ ASSERT (U_CHR (input, length, 'c') == input + 2);
}
}
@@ -74,6 +107,7 @@ main (void)
byte being searched. */
{
char *page_boundary = (char *) zerosize_ptr ();
+ size_t n;
if (page_boundary != NULL)
{
diff --git a/tests/unistr/test-cmp.h b/tests/unistr/test-cmp.h
index e536f482..aece9b0e 100644
--- a/tests/unistr/test-cmp.h
+++ b/tests/unistr/test-cmp.h
@@ -1,5 +1,5 @@
/* Test of uN_cmp() functions.
- Copyright (C) 2008-2010 Free Software Foundation, Inc.
+ Copyright (C) 2008-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-cmp2.h b/tests/unistr/test-cmp2.h
index 261fe365..c4050994 100644
--- a/tests/unistr/test-cmp2.h
+++ b/tests/unistr/test-cmp2.h
@@ -1,5 +1,5 @@
/* Test of uN_cmp2() functions.
- Copyright (C) 2008-2010 Free Software Foundation, Inc.
+ Copyright (C) 2008-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-cpy-alloc.h b/tests/unistr/test-cpy-alloc.h
index 795e0b77..261a677b 100644
--- a/tests/unistr/test-cpy-alloc.h
+++ b/tests/unistr/test-cpy-alloc.h
@@ -1,5 +1,5 @@
/* Test of uN_cpy_alloc() functions.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-cpy.h b/tests/unistr/test-cpy.h
index b62fd14f..bc8fe539 100644
--- a/tests/unistr/test-cpy.h
+++ b/tests/unistr/test-cpy.h
@@ -1,5 +1,5 @@
/* Test of uN_cpy() functions.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-move.h b/tests/unistr/test-move.h
index 2462367d..d2c39211 100644
--- a/tests/unistr/test-move.h
+++ b/tests/unistr/test-move.h
@@ -1,5 +1,5 @@
/* Test of uN_move() functions.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-set.h b/tests/unistr/test-set.h
index 56924dc3..8d366363 100644
--- a/tests/unistr/test-set.h
+++ b/tests/unistr/test-set.h
@@ -1,5 +1,5 @@
/* Test of uN_set() functions.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-stpcpy.h b/tests/unistr/test-stpcpy.h
index 76065dc4..a9248539 100644
--- a/tests/unistr/test-stpcpy.h
+++ b/tests/unistr/test-stpcpy.h
@@ -1,5 +1,5 @@
/* Test of uN_stpcpy() functions.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-stpncpy.h b/tests/unistr/test-stpncpy.h
index bb81ff00..3cb2958d 100644
--- a/tests/unistr/test-stpncpy.h
+++ b/tests/unistr/test-stpncpy.h
@@ -1,5 +1,5 @@
/* Test of uN_stpncpy() functions.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-strcat.h b/tests/unistr/test-strcat.h
index 6c1f90dc..e454e93e 100644
--- a/tests/unistr/test-strcat.h
+++ b/tests/unistr/test-strcat.h
@@ -1,5 +1,5 @@
/* Test of uN_strcat() functions.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-strchr.h b/tests/unistr/test-strchr.h
new file mode 100644
index 00000000..191d74e3
--- /dev/null
+++ b/tests/unistr/test-strchr.h
@@ -0,0 +1,161 @@
+/* Test of uN_strchr() functions.
+ Copyright (C) 2008-2015 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Paolo Bonzini <bonzini@gnu.org>, 2010.
+ Based on test-chr.h, by Eric Blake and Bruno Haible. */
+
+static void
+test_strchr (void)
+{
+ size_t size = 0x100000;
+ size_t length;
+ size_t i;
+ UNIT *input;
+ uint32_t *input32 = (uint32_t *) malloc ((size + 1) * sizeof (uint32_t));
+ ASSERT (input32);
+
+ input32[0] = 'a';
+ input32[1] = 'b';
+ u32_set (input32 + 2, 'c', 1024);
+ for (i = 1026; i < size - 2; i += 63)
+ {
+ size_t last = i + 63 < size - 2 ? i + 63 : size - 2;
+ ucs4_t uc = 'd' | (i - 1026);
+ if (uc >= 0xd800 && uc <= 0xdfff)
+ uc |= 0x100000;
+ u32_set (input32 + i, uc, last - i);
+ }
+ input32[size - 2] = 'e';
+ input32[size - 1] = 'a';
+ input32[size] = 0;
+
+ input = U32_TO_U (input32, size + 1, NULL, &length);
+ ASSERT (input);
+
+ /* Basic behavior tests. */
+ ASSERT (U_STRCHR (input, 'a') == input);
+ ASSERT (U_STRCHR (input, 'b') == input + 1);
+ ASSERT (U_STRCHR (input, 'c') == input + 2);
+
+ {
+ UNIT *exp = input + 1026;
+ UNIT *prev = input + 2;
+
+ for (i = 1026; i < size - 2; i += 63)
+ {
+ UNIT c[6];
+ size_t n;
+ ucs4_t uc = 'd' | (i - 1026);
+ if (uc >= 0xd800 && uc <= 0xdfff)
+ uc |= 0x100000;
+ n = U_UCTOMB (c, uc, 6);
+ ASSERT (exp < input + length - 2);
+ ASSERT (U_STRCHR (prev, uc) == exp);
+ ASSERT (memcmp (exp, c, n * sizeof (UNIT)) == 0);
+ prev = exp;
+ exp += n * 63;
+ }
+ }
+
+ ASSERT (U_STRCHR (input + 1, 'a') == input + length - 2);
+ ASSERT (U_STRCHR (input + 1, 'e') == input + length - 3);
+
+ ASSERT (U_STRCHR (input, 'f') == NULL);
+ ASSERT (U_STRCHR (input, '\0') == input + length - 1);
+
+ /* Check that a very long haystack is handled quickly if the byte is
+ found near the beginning. */
+ {
+ size_t repeat = 10000;
+ for (; repeat > 0; repeat--)
+ {
+ ASSERT (U_STRCHR (input, 'c') == input + 2);
+ }
+ }
+
+ /* Alignment tests. */
+ {
+ int i, j;
+ for (i = 0; i < 32; i++)
+ {
+ for (j = 0; j < 127; j++)
+ input[i + j] = j + 1;
+ input[i + 128] = 0;
+ for (j = 0; j < 127; j++)
+ {
+ ASSERT (U_STRCHR (input + i, j + 1) == input + i + j);
+ }
+ }
+ }
+
+ /* Check that uN_strchr() does not read past the end of the string. */
+ {
+ char *page_boundary = (char *) zerosize_ptr ();
+ size_t n;
+
+ if (page_boundary != NULL)
+ {
+ for (n = 2; n <= 500 / sizeof (UNIT); n++)
+ {
+ UNIT *mem = (UNIT *) (page_boundary - n * sizeof (UNIT));
+ U_SET (mem, 'X', n - 2);
+ mem[n - 2] = 0;
+ ASSERT (U_STRCHR (mem, 'U') == NULL);
+ mem[n - 2] = 'X';
+ mem[n - 1] = 0;
+ ASSERT (U_STRCHR (mem, 'U') == NULL);
+ }
+ }
+ }
+
+#if 0
+ /* This check is disabled, because uN_strchr() is allowed to read past the
+ first occurrence of the byte being searched. In fact, u8_strchr() does
+ so, on i586 glibc systems: u8_strchr calls strchr, which in
+ glibc/sysdeps/i386/i586/strchr.S loads the second word before the
+ handling of the first word has been completed. */
+ /* Check that uN_strchr() does not read past the first occurrence of the
+ byte being searched. */
+ {
+ char *page_boundary = (char *) zerosize_ptr ();
+ size_t n;
+
+ if (page_boundary != NULL)
+ {
+ for (n = 2; n <= 500 / sizeof (UNIT); n++)
+ {
+ UNIT *mem = (UNIT *) (page_boundary - n * sizeof (UNIT));
+ U_SET (mem, 'X', n - 1);
+ mem[n - 1] = 0;
+ ASSERT (U_STRCHR (mem, 'U') == NULL);
+
+ {
+ size_t i;
+
+ for (i = 0; i < n; i++)
+ {
+ mem[i] = 'U';
+ ASSERT (U_STRCHR (mem, 'U') == mem + i);
+ mem[i] = 'X';
+ }
+ }
+ }
+ }
+ }
+#endif
+
+ free (input);
+}
diff --git a/tests/unistr/test-strcmp.h b/tests/unistr/test-strcmp.h
index 485b6f91..d5fcbe97 100644
--- a/tests/unistr/test-strcmp.h
+++ b/tests/unistr/test-strcmp.h
@@ -1,5 +1,5 @@
/* Test of uN_strcmp() and uN_strcoll() functions.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-strcpy.h b/tests/unistr/test-strcpy.h
index f8fe5efd..50d28e15 100644
--- a/tests/unistr/test-strcpy.h
+++ b/tests/unistr/test-strcpy.h
@@ -1,5 +1,5 @@
/* Test of uN_strcpy() functions.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-strdup.h b/tests/unistr/test-strdup.h
index 1684b39d..44246e59 100644
--- a/tests/unistr/test-strdup.h
+++ b/tests/unistr/test-strdup.h
@@ -1,5 +1,5 @@
/* Test of uN_strdup() functions.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-strncat.h b/tests/unistr/test-strncat.h
index 0445b6d9..fc4494e2 100644
--- a/tests/unistr/test-strncat.h
+++ b/tests/unistr/test-strncat.h
@@ -1,5 +1,5 @@
/* Test of uN_strncat() functions.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-strncmp.h b/tests/unistr/test-strncmp.h
index 628db94c..3a28784c 100644
--- a/tests/unistr/test-strncmp.h
+++ b/tests/unistr/test-strncmp.h
@@ -1,5 +1,5 @@
/* Test of uN_strncmp() functions.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-strncpy.h b/tests/unistr/test-strncpy.h
index 6fa0d12e..492e7b8c 100644
--- a/tests/unistr/test-strncpy.h
+++ b/tests/unistr/test-strncpy.h
@@ -1,5 +1,5 @@
/* Test of uN_strncpy() functions.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-strnlen.h b/tests/unistr/test-strnlen.h
index 1199126c..0a5ce8b9 100644
--- a/tests/unistr/test-strnlen.h
+++ b/tests/unistr/test-strnlen.h
@@ -1,5 +1,5 @@
/* Test of uN_strnlen() functions.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u-strstr.h b/tests/unistr/test-u-strstr.h
new file mode 100644
index 00000000..417f8b33
--- /dev/null
+++ b/tests/unistr/test-u-strstr.h
@@ -0,0 +1,210 @@
+/* Test of uN_strstr() functions.
+ Copyright (C) 2004, 2007-2015 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+static void
+test_u_strstr (void)
+{
+ {
+ const UNIT input[] = { 'f', 'o', 'o', 0 };
+ const UNIT needle[] = { 0 };
+ const UNIT *result = U_STRSTR (input, needle);
+ ASSERT (result == input);
+ }
+
+ {
+ const UNIT input[] = { 'f', 'o', 'o', 0 };
+ const UNIT needle[] = { 'o', 0 };
+ const UNIT *result = U_STRSTR (input, needle);
+ ASSERT (result == input + 1);
+ }
+
+ {
+ const UNIT input[] =
+ { 'A', 'B', 'C', ' ', 'A', 'B', 'C', 'D', 'A', 'B', ' ', 'A', 'B', 'C',
+ 'D', 'A', 'B', 'C', 'D', 'A', 'B', 'D', 'E', 0
+ };
+ const UNIT needle[] = { 'A', 'B', 'C', 'D', 'A', 'B', 'D', 0 };
+ const UNIT *result = U_STRSTR (input, needle);
+ ASSERT (result == input + 15);
+ }
+
+ {
+ const UNIT input[] =
+ { 'A', 'B', 'C', ' ', 'A', 'B', 'C', 'D', 'A', 'B', ' ', 'A', 'B', 'C',
+ 'D', 'A', 'B', 'C', 'D', 'A', 'B', 'D', 'E', 0
+ };
+ const UNIT needle[] = { 'A', 'B', 'C', 'D', 'A', 'B', 'E', 0 };
+ const UNIT *result = U_STRSTR (input, needle);
+ ASSERT (result == NULL);
+ }
+
+ {
+ const UNIT input[] =
+ { 'A', 'B', 'C', ' ', 'A', 'B', 'C', 'D', 'A', 'B', ' ', 'A', 'B', 'C',
+ 'D', 'A', 'B', 'C', 'D', 'A', 'B', 'D', 'E', 0
+ };
+ const UNIT needle[] = { 'A', 'B', 'C', 'D', 'A', 'B', 'C', 'D', 0 };
+ const UNIT *result = U_STRSTR (input, needle);
+ ASSERT (result == input + 11);
+ }
+
+ /* Check that a long periodic needle does not cause false positives. */
+ {
+ const UNIT input[] =
+ { 'F', '_', 'B', 'D', '_', 'C', 'E', '_', 'B', 'D', '_', 'E', 'F',
+ '_', 'B', 'F', '_', 'B', 'D', '_', 'E', 'F', '_', 'B', 'F',
+ '_', 'B', 'D', '_', 'E', 'F', '_', 'B', 'F', '_', 'B', 'D',
+ '_', 'E', 'F', '_', 'B', 'F', '_', 'B', 'D', '_', 'C', '3',
+ '_', '8', '8', '_', '2', '0', '_', 'E', 'F', '_', 'B', 'F',
+ '_', 'B', 'D', '_', 'E', 'F', '_', 'B', 'F', '_', 'B', 'D',
+ '_', 'E', 'F', '_', 'B', 'F', '_', 'B', 'D', '_', 'C', '3',
+ '_', 'A', '7', '_', '2', '0', '_', 'E', 'F', '_', 'B', 'F',
+ '_', 'B', 'D', 0
+ };
+ const UNIT needle[] =
+ { '_', 'E', 'F', '_', 'B', 'F', '_', 'B', 'D', '_', 'E', 'F',
+ '_', 'B', 'F', '_', 'B', 'D', '_', 'E', 'F', '_', 'B', 'F',
+ '_', 'B', 'D', '_', 'E', 'F', '_', 'B', 'F', '_', 'B', 'D',
+ '_', 'E', 'F', '_', 'B', 'F', '_', 'B', 'D', 0
+ };
+ const UNIT *result = U_STRSTR (input, needle);
+ ASSERT (result == NULL);
+ }
+ {
+ const UNIT input[] =
+ { 'F', '_', 'B', 'D', '_', 'C', 'E', '_', 'B', 'D', '_', 'E', 'F',
+ '_', 'B', 'F', '_', 'B', 'D', '_', 'E', 'F', '_', 'B', 'F',
+ '_', 'B', 'D', '_', 'E', 'F', '_', 'B', 'F', '_', 'B', 'D',
+ '_', 'E', 'F', '_', 'B', 'F', '_', 'B', 'D', '_', 'C', '3',
+ '_', '8', '8', '_', '2', '0', '_', 'E', 'F', '_', 'B', 'F',
+ '_', 'B', 'D', '_', 'E', 'F', '_', 'B', 'F', '_', 'B', 'D',
+ '_', 'E', 'F', '_', 'B', 'F', '_', 'B', 'D', '_', 'C', '3',
+ '_', 'A', '7', '_', '2', '0', '_', 'E', 'F', '_', 'B', 'F',
+ '_', 'B', 'D', '_', 'D', 'A', '_', 'B', '5', '_', 'C', '2',
+ '_', 'A', '6', '_', '2', '0', '_', 'E', 'F', '_', 'B', 'F',
+ '_', 'B', 'D', '_', 'E', 'F', '_', 'B', 'F', '_', 'B', 'D',
+ '_', 'E', 'F', '_', 'B', 'F', '_', 'B', 'D', '_', 'E', 'F',
+ '_', 'B', 'F', '_', 'B', 'D', '_', 'E', 'F', '_', 'B', 'F',
+ '_', 'B', 'D', 0
+ };
+ const UNIT needle[] =
+ { '_', 'E', 'F', '_', 'B', 'F', '_', 'B', 'D', '_', 'E', 'F',
+ '_', 'B', 'F', '_', 'B', 'D', '_', 'E', 'F', '_', 'B', 'F',
+ '_', 'B', 'D', '_', 'E', 'F', '_', 'B', 'F', '_', 'B', 'D',
+ '_', 'E', 'F', '_', 'B', 'F', '_', 'B', 'D', 0
+ };
+ const UNIT *result = U_STRSTR (input, needle);
+ ASSERT (result == input + 115);
+ }
+
+ /* Check that a very long haystack is handled quickly if the needle is
+ short and occurs near the beginning. */
+ {
+ size_t repeat = 10000;
+ size_t m = 1000000;
+ const UNIT needle[] =
+ { 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
+ 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
+ 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
+ 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
+ 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
+ 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
+ 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
+ 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
+ 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
+ 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 0
+ };
+ UNIT *haystack = (UNIT *) malloc ((m + 1) * sizeof (UNIT));
+ if (haystack != NULL)
+ {
+ size_t i;
+
+ haystack[0] = 'B';
+ for (i = 1; i < m; i++)
+ haystack[i] = 'A';
+ haystack[m] = '\0';
+
+ for (; repeat > 0; repeat--)
+ {
+ ASSERT (U_STRSTR (haystack, needle) == haystack + 1);
+ }
+
+ free (haystack);
+ }
+ }
+
+ /* Check that a very long needle is discarded quickly if the haystack is
+ short. */
+ {
+ size_t repeat = 10000;
+ size_t m = 1000000;
+ const UNIT haystack[] =
+ { 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
+ 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
+ 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
+ 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
+ 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'B',
+ 'A', 'B', 'A', 'B', 'A', 'B', 'A', 'B', 'A', 'B', 'A', 'B', 'A', 'B',
+ 'A', 'B', 'A', 'B', 'A', 'B', 'A', 'B', 'A', 'B', 'A', 'B', 'A', 'B',
+ 'A', 'B', 'A', 'B', 'A', 'B', 'A', 'B', 'A', 'B', 'A', 'B', 'A', 'B',
+ 'A', 'B', 'A', 'B', 'A', 'B', 'A', 'B', 'A', 'B', 'A', 'B', 'A', 'B',
+ 'A', 'B', 'A', 'B', 'A', 'B', 'A', 'B', 'A', 'B', 0
+ };
+ UNIT *needle = (UNIT *) malloc ((m + 1) * sizeof (UNIT));
+ if (needle != NULL)
+ {
+ size_t i;
+
+ for (i = 0; i < m; i++)
+ needle[i] = 'A';
+ needle[m] = '\0';
+
+ for (; repeat > 0; repeat--)
+ {
+ ASSERT (U_STRSTR (haystack, needle) == NULL);
+ }
+
+ free (needle);
+ }
+ }
+
+ /* Check that the asymptotic worst-case complexity is not quadratic. */
+ {
+ size_t m = 1000000;
+ UNIT *haystack = (UNIT *) malloc ((2 * m + 2) * sizeof (UNIT));
+ UNIT *needle = (UNIT *) malloc ((m + 2) * sizeof (UNIT));
+ if (haystack != NULL && needle != NULL)
+ {
+ size_t i;
+ const UNIT *result;
+
+ for (i = 0; i < 2 * m; i++)
+ haystack[i] = 'A';
+ haystack[2 * m] = 'B';
+ haystack[2 * m + 1] = 0;
+
+ for (i = 0; i < m; i++)
+ needle[i] = 'A';
+ needle[m] = 'B';
+ needle[m + 1] = 0;
+
+ result = U_STRSTR (haystack, needle);
+ ASSERT (result == haystack + m);
+ }
+ free (needle);
+ free (haystack);
+ }
+}
diff --git a/tests/unistr/test-u-strtok.h b/tests/unistr/test-u-strtok.h
new file mode 100644
index 00000000..6c124847
--- /dev/null
+++ b/tests/unistr/test-u-strtok.h
@@ -0,0 +1,88 @@
+/* Test of uN_strtok() functions.
+ Copyright (C) 2015 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+static void
+test_u_strtok (void)
+{
+ {
+ UNIT input[] = { 'f', 'o', 'o', 0 };
+ const UNIT delim[] = { 0 };
+ UNIT *state;
+ const UNIT *result = U_STRTOK (input, delim, &state);
+ ASSERT (result == input);
+ }
+
+ {
+ UNIT input[] =
+ { 'A', 'B', 'C', ' ', 'A', 'B', 'C', 'D', 'A', 'B', ' ', '\t',
+ 'A', 'B', 'C', 'D', 'A', 'B', 'C', 'D', 'A', 'B', 'D', 'E', 0
+ };
+ const UNIT delim[] = { ' ', '\t', 0 };
+ UNIT *state;
+ const UNIT *result;
+ result = U_STRTOK (input, delim, &state);
+ ASSERT (result == input);
+ result = U_STRTOK (NULL, delim, &state);
+ ASSERT (result == input + 4);
+ result = U_STRTOK (NULL, delim, &state);
+ ASSERT (result == input + 12);
+ result = U_STRTOK (NULL, delim, &state);
+ ASSERT (result == NULL);
+ }
+
+ /* Check for multibyte delimiters. */
+ {
+ ucs4_t u_input[] =
+ { 'A', 'B', 'C', 0x3000, 'A', 'B', 'C', 'D', 'A', 'B', 0x3000, 0x3001,
+ 'A', 'B', 'C', 'D', 'A', 'B', 'C', 'D', 'A', 'B', 'D', 'E', 0
+ };
+ ucs4_t u_delim[] = { 0x3000, 0x3001, 0 };
+ size_t input_len = 6 * SIZEOF (u_input);
+ UNIT *input = (UNIT *) malloc (input_len);
+ size_t delim_len = 6 * SIZEOF (u_delim);
+ UNIT *delim = (UNIT *) malloc (delim_len);
+ UNIT *state;
+ const UNIT *result;
+ UNIT *ptr, *first_ptr, *second_ptr;
+ size_t i;
+ for (i = 0, ptr = input; i < SIZEOF (u_input) && u_input[i] != 0; i++)
+ {
+ int ret = U_UCTOMB (ptr, u_input[i], input_len - (ptr - input));
+ if (i == 4)
+ first_ptr = ptr;
+ if (i == 12)
+ second_ptr = ptr;
+ ptr += ret;
+ }
+ *ptr = 0;
+ for (i = 0, ptr = delim; i < SIZEOF (u_delim) && u_delim[i] != 0; i++)
+ {
+ int ret = U_UCTOMB (ptr, u_delim[i], delim_len - (ptr - delim));
+ ptr += ret;
+ }
+ *ptr = 0;
+ result = U_STRTOK (input, delim, &state);
+ ASSERT (result == input);
+ result = U_STRTOK (NULL, delim, &state);
+ ASSERT (result == first_ptr);
+ result = U_STRTOK (NULL, delim, &state);
+ ASSERT (result == second_ptr);
+ result = U_STRTOK (NULL, delim, &state);
+ ASSERT (result == NULL);
+ free (input);
+ free (delim);
+ }
+}
diff --git a/tests/unistr/test-u16-check.c b/tests/unistr/test-u16-check.c
index b7a9c103..23adffe4 100644
--- a/tests/unistr/test-u16-check.c
+++ b/tests/unistr/test-u16-check.c
@@ -1,5 +1,5 @@
/* Test of u16_check() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u16-chr.c b/tests/unistr/test-u16-chr.c
index d71755c1..7ffeb57a 100644
--- a/tests/unistr/test-u16-chr.c
+++ b/tests/unistr/test-u16-chr.c
@@ -1,5 +1,5 @@
/* Test of u16_chr() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -21,11 +21,14 @@
#include "unistr.h"
#include <stdlib.h>
+#include <string.h>
#include "zerosize-ptr.h"
#include "macros.h"
#define UNIT uint16_t
+#define U_UCTOMB u16_uctomb
+#define U32_TO_U u32_to_u16
#define U_CHR u16_chr
#define U_SET u16_set
#include "test-chr.h"
diff --git a/tests/unistr/test-u16-cmp.c b/tests/unistr/test-u16-cmp.c
index 1ab9019a..ab2025bc 100644
--- a/tests/unistr/test-u16-cmp.c
+++ b/tests/unistr/test-u16-cmp.c
@@ -1,5 +1,5 @@
/* Test of u16_cmp() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u16-cmp2.c b/tests/unistr/test-u16-cmp2.c
index 3993dcdd..1a7ce045 100644
--- a/tests/unistr/test-u16-cmp2.c
+++ b/tests/unistr/test-u16-cmp2.c
@@ -1,5 +1,5 @@
/* Test of u16_cmp2() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u16-cpy-alloc.c b/tests/unistr/test-u16-cpy-alloc.c
index d1aa2116..a62502f3 100644
--- a/tests/unistr/test-u16-cpy-alloc.c
+++ b/tests/unistr/test-u16-cpy-alloc.c
@@ -1,5 +1,5 @@
/* Test of u16_cpy_alloc() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u16-cpy.c b/tests/unistr/test-u16-cpy.c
index 168a459a..b109514e 100644
--- a/tests/unistr/test-u16-cpy.c
+++ b/tests/unistr/test-u16-cpy.c
@@ -1,5 +1,5 @@
/* Test of u16_cpy() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u16-mblen.c b/tests/unistr/test-u16-mblen.c
index 13186f3f..5cec88d4 100644
--- a/tests/unistr/test-u16-mblen.c
+++ b/tests/unistr/test-u16-mblen.c
@@ -1,5 +1,5 @@
/* Test of u16_mblen() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u16-mbsnlen.c b/tests/unistr/test-u16-mbsnlen.c
index a2d8b10f..4e99b570 100644
--- a/tests/unistr/test-u16-mbsnlen.c
+++ b/tests/unistr/test-u16-mbsnlen.c
@@ -1,5 +1,5 @@
/* Test of u16_mbsnlen() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u16-mbtouc-unsafe.c b/tests/unistr/test-u16-mbtouc-unsafe.c
index a1d12149..68110336 100644
--- a/tests/unistr/test-u16-mbtouc-unsafe.c
+++ b/tests/unistr/test-u16-mbtouc-unsafe.c
@@ -1,5 +1,5 @@
/* Test of u16_mbtouc_unsafe() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u16-mbtouc.c b/tests/unistr/test-u16-mbtouc.c
index 4545add7..f673ee8c 100644
--- a/tests/unistr/test-u16-mbtouc.c
+++ b/tests/unistr/test-u16-mbtouc.c
@@ -1,5 +1,5 @@
/* Test of u16_mbtouc() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u16-mbtouc.h b/tests/unistr/test-u16-mbtouc.h
index ef0fb68a..7019b4a1 100644
--- a/tests/unistr/test-u16-mbtouc.h
+++ b/tests/unistr/test-u16-mbtouc.h
@@ -1,5 +1,5 @@
/* Test of u16_mbtouc() and u16_mbtouc_unsafe() functions.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u16-mbtoucr.c b/tests/unistr/test-u16-mbtoucr.c
index fb1264d9..bf93b127 100644
--- a/tests/unistr/test-u16-mbtoucr.c
+++ b/tests/unistr/test-u16-mbtoucr.c
@@ -1,5 +1,5 @@
/* Test of u16_mbtoucr() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u16-move.c b/tests/unistr/test-u16-move.c
index ff1e6e35..32588d57 100644
--- a/tests/unistr/test-u16-move.c
+++ b/tests/unistr/test-u16-move.c
@@ -1,5 +1,5 @@
/* Test of u16_move() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u16-next.c b/tests/unistr/test-u16-next.c
index d9ac6e93..f338f768 100644
--- a/tests/unistr/test-u16-next.c
+++ b/tests/unistr/test-u16-next.c
@@ -1,5 +1,5 @@
/* Test of u16_next() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u16-prev.c b/tests/unistr/test-u16-prev.c
index 90e83418..8dcf6c12 100644
--- a/tests/unistr/test-u16-prev.c
+++ b/tests/unistr/test-u16-prev.c
@@ -1,5 +1,5 @@
/* Test of u16_prev() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u16-set.c b/tests/unistr/test-u16-set.c
index f3e63052..a545f29b 100644
--- a/tests/unistr/test-u16-set.c
+++ b/tests/unistr/test-u16-set.c
@@ -1,5 +1,5 @@
/* Test of u16_set() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u16-stpcpy.c b/tests/unistr/test-u16-stpcpy.c
index 6bf3ecb1..9615999d 100644
--- a/tests/unistr/test-u16-stpcpy.c
+++ b/tests/unistr/test-u16-stpcpy.c
@@ -1,5 +1,5 @@
/* Test of u16_stpcpy() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u16-stpncpy.c b/tests/unistr/test-u16-stpncpy.c
index e53ce6be..5bebcfb1 100644
--- a/tests/unistr/test-u16-stpncpy.c
+++ b/tests/unistr/test-u16-stpncpy.c
@@ -1,5 +1,5 @@
/* Test of u16_stpncpy() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u16-strcat.c b/tests/unistr/test-u16-strcat.c
index 9d6032eb..d381d0cd 100644
--- a/tests/unistr/test-u16-strcat.c
+++ b/tests/unistr/test-u16-strcat.c
@@ -1,5 +1,5 @@
/* Test of u16_strcat() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u16-strchr.c b/tests/unistr/test-u16-strchr.c
new file mode 100644
index 00000000..d33f7405
--- /dev/null
+++ b/tests/unistr/test-u16-strchr.c
@@ -0,0 +1,42 @@
+/* Test of u16_strchr() function.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Paolo Bonzini <bonzini@gnu.org>, 2010. */
+
+#include <config.h>
+
+#include "unistr.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "zerosize-ptr.h"
+#include "macros.h"
+
+#define UNIT uint16_t
+#define U_UCTOMB u16_uctomb
+#define U32_TO_U u32_to_u16
+#define U_STRCHR u16_strchr
+#define U_SET u16_set
+#include "test-strchr.h"
+
+int
+main (void)
+{
+ test_strchr ();
+
+ return 0;
+}
diff --git a/tests/unistr/test-u16-strcmp.c b/tests/unistr/test-u16-strcmp.c
index 5fc47774..9c976139 100644
--- a/tests/unistr/test-u16-strcmp.c
+++ b/tests/unistr/test-u16-strcmp.c
@@ -1,5 +1,5 @@
/* Test of u16_strcmp() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u16-strcmp.h b/tests/unistr/test-u16-strcmp.h
index ad54a437..6a3d988c 100644
--- a/tests/unistr/test-u16-strcmp.h
+++ b/tests/unistr/test-u16-strcmp.h
@@ -1,5 +1,5 @@
/* Test of u16_strcmp() and u16_strcoll() functions.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u16-strcoll.c b/tests/unistr/test-u16-strcoll.c
index e24814a1..ac32c5bc 100644
--- a/tests/unistr/test-u16-strcoll.c
+++ b/tests/unistr/test-u16-strcoll.c
@@ -1,5 +1,5 @@
/* Test of u16_strcoll() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u16-strcpy.c b/tests/unistr/test-u16-strcpy.c
index e017a112..e274d784 100644
--- a/tests/unistr/test-u16-strcpy.c
+++ b/tests/unistr/test-u16-strcpy.c
@@ -1,5 +1,5 @@
/* Test of u16_strcpy() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u16-strdup.c b/tests/unistr/test-u16-strdup.c
index f0266d1b..33d1d0b4 100644
--- a/tests/unistr/test-u16-strdup.c
+++ b/tests/unistr/test-u16-strdup.c
@@ -1,5 +1,5 @@
/* Test of u16_strdup() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u16-strlen.c b/tests/unistr/test-u16-strlen.c
index 7b8690be..40f6af33 100644
--- a/tests/unistr/test-u16-strlen.c
+++ b/tests/unistr/test-u16-strlen.c
@@ -1,5 +1,5 @@
/* Test of u16_strlen() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u16-strmblen.c b/tests/unistr/test-u16-strmblen.c
index 80371b0a..36103a20 100644
--- a/tests/unistr/test-u16-strmblen.c
+++ b/tests/unistr/test-u16-strmblen.c
@@ -1,5 +1,5 @@
/* Test of u16_strmblen() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u16-strmbtouc.c b/tests/unistr/test-u16-strmbtouc.c
index ceeaf2cd..fb6f08a5 100644
--- a/tests/unistr/test-u16-strmbtouc.c
+++ b/tests/unistr/test-u16-strmbtouc.c
@@ -1,5 +1,5 @@
/* Test of u16_strmbtouc() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u16-strncat.c b/tests/unistr/test-u16-strncat.c
index c875cfc8..9a407f0e 100644
--- a/tests/unistr/test-u16-strncat.c
+++ b/tests/unistr/test-u16-strncat.c
@@ -1,5 +1,5 @@
/* Test of u16_strncat() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u16-strncmp.c b/tests/unistr/test-u16-strncmp.c
index b04431bd..c6ed7c08 100644
--- a/tests/unistr/test-u16-strncmp.c
+++ b/tests/unistr/test-u16-strncmp.c
@@ -1,5 +1,5 @@
/* Test of u16_strncmp() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u16-strncpy.c b/tests/unistr/test-u16-strncpy.c
index 102f6534..21e302dc 100644
--- a/tests/unistr/test-u16-strncpy.c
+++ b/tests/unistr/test-u16-strncpy.c
@@ -1,5 +1,5 @@
/* Test of u16_strncpy() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u16-strnlen.c b/tests/unistr/test-u16-strnlen.c
index beeba64b..85ff647c 100644
--- a/tests/unistr/test-u16-strnlen.c
+++ b/tests/unistr/test-u16-strnlen.c
@@ -1,5 +1,5 @@
/* Test of u16_strnlen() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u16-strstr.c b/tests/unistr/test-u16-strstr.c
new file mode 100644
index 00000000..8f0f4f15
--- /dev/null
+++ b/tests/unistr/test-u16-strstr.c
@@ -0,0 +1,47 @@
+/* Test of u16_strstr() function.
+ Copyright (C) 2011-2015 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Pádraig Brady <P@draigBrady.com>, 2011. */
+
+#include <config.h>
+
+#include "unistr.h"
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <signal.h> /* For signal. */
+#include <unistd.h> /* For alarm. */
+
+#include "macros.h"
+
+#define UNIT uint16_t
+#define U_STRSTR u16_strstr
+#include "test-u-strstr.h"
+
+int
+main (void)
+{
+#if HAVE_DECL_ALARM
+ /* Declare failure if test takes too long, by using default abort
+ caused by SIGALRM. */
+ signal (SIGALRM, SIG_DFL);
+ alarm (10);
+#endif
+
+ test_u_strstr ();
+
+ return 0;
+}
diff --git a/tests/unistr/test-u16-strtok.c b/tests/unistr/test-u16-strtok.c
new file mode 100644
index 00000000..cbd95efa
--- /dev/null
+++ b/tests/unistr/test-u16-strtok.c
@@ -0,0 +1,37 @@
+/* Test of u16_strtok() function.
+ Copyright (C) 2015 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+#include "unistr.h"
+
+#include <stdint.h>
+#include <stdlib.h>
+
+#include "macros.h"
+
+#define UNIT uint16_t
+#define U_STRTOK u16_strtok
+#define U_UCTOMB u16_uctomb
+#include "test-u-strtok.h"
+
+int
+main (void)
+{
+ test_u_strtok ();
+
+ return 0;
+}
diff --git a/tests/unistr/test-u16-to-u32.c b/tests/unistr/test-u16-to-u32.c
index 5b382b2f..e0956432 100644
--- a/tests/unistr/test-u16-to-u32.c
+++ b/tests/unistr/test-u16-to-u32.c
@@ -1,5 +1,5 @@
/* Test of u16_to_u32() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u16-to-u8.c b/tests/unistr/test-u16-to-u8.c
index 4ef9b9b6..f62c21e2 100644
--- a/tests/unistr/test-u16-to-u8.c
+++ b/tests/unistr/test-u16-to-u8.c
@@ -1,5 +1,5 @@
/* Test of u16_to_u8() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u16-uctomb.c b/tests/unistr/test-u16-uctomb.c
index ba502254..cfa2104e 100644
--- a/tests/unistr/test-u16-uctomb.c
+++ b/tests/unistr/test-u16-uctomb.c
@@ -1,5 +1,5 @@
/* Test of u16_uctomb() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-check.c b/tests/unistr/test-u32-check.c
index fdd64df6..49099ece 100644
--- a/tests/unistr/test-u32-check.c
+++ b/tests/unistr/test-u32-check.c
@@ -1,5 +1,5 @@
/* Test of u32_check() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-chr.c b/tests/unistr/test-u32-chr.c
index f23aa084..ae274f47 100644
--- a/tests/unistr/test-u32-chr.c
+++ b/tests/unistr/test-u32-chr.c
@@ -1,5 +1,5 @@
/* Test of u32_chr() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -21,11 +21,14 @@
#include "unistr.h"
#include <stdlib.h>
+#include <string.h>
#include "zerosize-ptr.h"
#include "macros.h"
#define UNIT uint32_t
+#define U_UCTOMB(s, uc, n) (*(s) = (uc), 1)
+#define U32_TO_U(s, n, result, length) (*(length) = (n), (s))
#define U_CHR u32_chr
#define U_SET u32_set
#include "test-chr.h"
diff --git a/tests/unistr/test-u32-cmp.c b/tests/unistr/test-u32-cmp.c
index ab41b31f..20c0646a 100644
--- a/tests/unistr/test-u32-cmp.c
+++ b/tests/unistr/test-u32-cmp.c
@@ -1,5 +1,5 @@
/* Test of u32_cmp() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-cmp2.c b/tests/unistr/test-u32-cmp2.c
index 84450b56..376aa730 100644
--- a/tests/unistr/test-u32-cmp2.c
+++ b/tests/unistr/test-u32-cmp2.c
@@ -1,5 +1,5 @@
/* Test of u32_cmp2() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-cpy-alloc.c b/tests/unistr/test-u32-cpy-alloc.c
index d3675dd7..73a4b859 100644
--- a/tests/unistr/test-u32-cpy-alloc.c
+++ b/tests/unistr/test-u32-cpy-alloc.c
@@ -1,5 +1,5 @@
/* Test of u32_cpy_alloc() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-cpy.c b/tests/unistr/test-u32-cpy.c
index 49fc9951..cf11e6ca 100644
--- a/tests/unistr/test-u32-cpy.c
+++ b/tests/unistr/test-u32-cpy.c
@@ -1,5 +1,5 @@
/* Test of u32_cpy() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-mblen.c b/tests/unistr/test-u32-mblen.c
index 1ebd93eb..1e038e14 100644
--- a/tests/unistr/test-u32-mblen.c
+++ b/tests/unistr/test-u32-mblen.c
@@ -1,5 +1,5 @@
/* Test of u32_mblen() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-mbsnlen.c b/tests/unistr/test-u32-mbsnlen.c
index d9e066ba..9a876346 100644
--- a/tests/unistr/test-u32-mbsnlen.c
+++ b/tests/unistr/test-u32-mbsnlen.c
@@ -1,5 +1,5 @@
/* Test of u32_mbsnlen() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-mbtouc-unsafe.c b/tests/unistr/test-u32-mbtouc-unsafe.c
index cb3052cb..d0ee0afb 100644
--- a/tests/unistr/test-u32-mbtouc-unsafe.c
+++ b/tests/unistr/test-u32-mbtouc-unsafe.c
@@ -1,5 +1,5 @@
/* Test of u32_mbtouc_unsafe() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-mbtouc.c b/tests/unistr/test-u32-mbtouc.c
index 7c981b5c..e5829794 100644
--- a/tests/unistr/test-u32-mbtouc.c
+++ b/tests/unistr/test-u32-mbtouc.c
@@ -1,5 +1,5 @@
/* Test of u32_mbtouc() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-mbtouc.h b/tests/unistr/test-u32-mbtouc.h
index 7d701334..b0a74988 100644
--- a/tests/unistr/test-u32-mbtouc.h
+++ b/tests/unistr/test-u32-mbtouc.h
@@ -1,5 +1,5 @@
/* Test of u32_mbtouc() and u32_mbtouc_unsafe() functions.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-mbtoucr.c b/tests/unistr/test-u32-mbtoucr.c
index 7b1034c5..898baa27 100644
--- a/tests/unistr/test-u32-mbtoucr.c
+++ b/tests/unistr/test-u32-mbtoucr.c
@@ -1,5 +1,5 @@
/* Test of u32_mbtoucr() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-move.c b/tests/unistr/test-u32-move.c
index 44f95c00..0dd9e30b 100644
--- a/tests/unistr/test-u32-move.c
+++ b/tests/unistr/test-u32-move.c
@@ -1,5 +1,5 @@
/* Test of u32_move() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-next.c b/tests/unistr/test-u32-next.c
index a5852e2c..339ffb98 100644
--- a/tests/unistr/test-u32-next.c
+++ b/tests/unistr/test-u32-next.c
@@ -1,5 +1,5 @@
/* Test of u32_next() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-prev.c b/tests/unistr/test-u32-prev.c
index 95187afa..a49525d7 100644
--- a/tests/unistr/test-u32-prev.c
+++ b/tests/unistr/test-u32-prev.c
@@ -1,5 +1,5 @@
/* Test of u32_prev() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-set.c b/tests/unistr/test-u32-set.c
index 120804f1..00516098 100644
--- a/tests/unistr/test-u32-set.c
+++ b/tests/unistr/test-u32-set.c
@@ -1,5 +1,5 @@
/* Test of u32_set() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-stpcpy.c b/tests/unistr/test-u32-stpcpy.c
index 9c99c52a..04a16a5b 100644
--- a/tests/unistr/test-u32-stpcpy.c
+++ b/tests/unistr/test-u32-stpcpy.c
@@ -1,5 +1,5 @@
/* Test of u32_stpcpy() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-stpncpy.c b/tests/unistr/test-u32-stpncpy.c
index e29683bd..4b996667 100644
--- a/tests/unistr/test-u32-stpncpy.c
+++ b/tests/unistr/test-u32-stpncpy.c
@@ -1,5 +1,5 @@
/* Test of u32_stpncpy() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-strcat.c b/tests/unistr/test-u32-strcat.c
index 66e7c853..02f9615d 100644
--- a/tests/unistr/test-u32-strcat.c
+++ b/tests/unistr/test-u32-strcat.c
@@ -1,5 +1,5 @@
/* Test of u32_strcat() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-strchr.c b/tests/unistr/test-u32-strchr.c
new file mode 100644
index 00000000..054b9963
--- /dev/null
+++ b/tests/unistr/test-u32-strchr.c
@@ -0,0 +1,42 @@
+/* Test of u32_strchr() function.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Paolo Bonzini <bonzini@gnu.org>, 2010. */
+
+#include <config.h>
+
+#include "unistr.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "zerosize-ptr.h"
+#include "macros.h"
+
+#define UNIT uint32_t
+#define U_UCTOMB(s, uc, n) (*(s) = (uc), 1)
+#define U32_TO_U(s, n, result, length) (*(length) = (n), (s))
+#define U_STRCHR u32_strchr
+#define U_SET u32_set
+#include "test-strchr.h"
+
+int
+main (void)
+{
+ test_strchr ();
+
+ return 0;
+}
diff --git a/tests/unistr/test-u32-strcmp.c b/tests/unistr/test-u32-strcmp.c
index 8364a415..8b420cf8 100644
--- a/tests/unistr/test-u32-strcmp.c
+++ b/tests/unistr/test-u32-strcmp.c
@@ -1,5 +1,5 @@
/* Test of u32_strcmp() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-strcmp.h b/tests/unistr/test-u32-strcmp.h
index 6d24132e..4b1fdd03 100644
--- a/tests/unistr/test-u32-strcmp.h
+++ b/tests/unistr/test-u32-strcmp.h
@@ -1,5 +1,5 @@
/* Test of u32_strcmp() and u32_strcoll() functions.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-strcoll.c b/tests/unistr/test-u32-strcoll.c
index 36954e73..f718a82f 100644
--- a/tests/unistr/test-u32-strcoll.c
+++ b/tests/unistr/test-u32-strcoll.c
@@ -1,5 +1,5 @@
/* Test of u32_strcoll() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-strcpy.c b/tests/unistr/test-u32-strcpy.c
index 2e22aad4..b388890d 100644
--- a/tests/unistr/test-u32-strcpy.c
+++ b/tests/unistr/test-u32-strcpy.c
@@ -1,5 +1,5 @@
/* Test of u32_strcpy() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-strdup.c b/tests/unistr/test-u32-strdup.c
index ede8e544..c200e651 100644
--- a/tests/unistr/test-u32-strdup.c
+++ b/tests/unistr/test-u32-strdup.c
@@ -1,5 +1,5 @@
/* Test of u32_strdup() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-strlen.c b/tests/unistr/test-u32-strlen.c
index a349be75..a7973987 100644
--- a/tests/unistr/test-u32-strlen.c
+++ b/tests/unistr/test-u32-strlen.c
@@ -1,5 +1,5 @@
/* Test of u32_strlen() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-strmblen.c b/tests/unistr/test-u32-strmblen.c
index 733f8fc8..0b745314 100644
--- a/tests/unistr/test-u32-strmblen.c
+++ b/tests/unistr/test-u32-strmblen.c
@@ -1,5 +1,5 @@
/* Test of u32_strmblen() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-strmbtouc.c b/tests/unistr/test-u32-strmbtouc.c
index 79c222e0..39451f79 100644
--- a/tests/unistr/test-u32-strmbtouc.c
+++ b/tests/unistr/test-u32-strmbtouc.c
@@ -1,5 +1,5 @@
/* Test of u32_strmbtouc() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-strncat.c b/tests/unistr/test-u32-strncat.c
index 346bafb7..2c78c8f9 100644
--- a/tests/unistr/test-u32-strncat.c
+++ b/tests/unistr/test-u32-strncat.c
@@ -1,5 +1,5 @@
/* Test of u32_strncat() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-strncmp.c b/tests/unistr/test-u32-strncmp.c
index d69913da..f1cad819 100644
--- a/tests/unistr/test-u32-strncmp.c
+++ b/tests/unistr/test-u32-strncmp.c
@@ -1,5 +1,5 @@
/* Test of u32_strncmp() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-strncpy.c b/tests/unistr/test-u32-strncpy.c
index 9309c0ed..ebe0addf 100644
--- a/tests/unistr/test-u32-strncpy.c
+++ b/tests/unistr/test-u32-strncpy.c
@@ -1,5 +1,5 @@
/* Test of u32_strncpy() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-strnlen.c b/tests/unistr/test-u32-strnlen.c
index 69299148..7941ab3f 100644
--- a/tests/unistr/test-u32-strnlen.c
+++ b/tests/unistr/test-u32-strnlen.c
@@ -1,5 +1,5 @@
/* Test of u32_strnlen() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-strstr.c b/tests/unistr/test-u32-strstr.c
new file mode 100644
index 00000000..c291b3c4
--- /dev/null
+++ b/tests/unistr/test-u32-strstr.c
@@ -0,0 +1,47 @@
+/* Test of u32_strstr() function.
+ Copyright (C) 2011-2015 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Pádraig Brady <P@draigBrady.com>, 2011. */
+
+#include <config.h>
+
+#include "unistr.h"
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <signal.h> /* For signal. */
+#include <unistd.h> /* For alarm. */
+
+#include "macros.h"
+
+#define UNIT uint32_t
+#define U_STRSTR u32_strstr
+#include "test-u-strstr.h"
+
+int
+main (void)
+{
+#if HAVE_DECL_ALARM
+ /* Declare failure if test takes too long, by using default abort
+ caused by SIGALRM. */
+ signal (SIGALRM, SIG_DFL);
+ alarm (10);
+#endif
+
+ test_u_strstr ();
+
+ return 0;
+}
diff --git a/tests/unistr/test-u32-strtok.c b/tests/unistr/test-u32-strtok.c
new file mode 100644
index 00000000..04cded78
--- /dev/null
+++ b/tests/unistr/test-u32-strtok.c
@@ -0,0 +1,37 @@
+/* Test of u32_strtok() function.
+ Copyright (C) 2015 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+#include "unistr.h"
+
+#include <stdint.h>
+#include <stdlib.h>
+
+#include "macros.h"
+
+#define UNIT uint32_t
+#define U_STRTOK u32_strtok
+#define U_UCTOMB u32_uctomb
+#include "test-u-strtok.h"
+
+int
+main (void)
+{
+ test_u_strtok ();
+
+ return 0;
+}
diff --git a/tests/unistr/test-u32-to-u16.c b/tests/unistr/test-u32-to-u16.c
index 6faf5379..65e19856 100644
--- a/tests/unistr/test-u32-to-u16.c
+++ b/tests/unistr/test-u32-to-u16.c
@@ -1,5 +1,5 @@
/* Test of u32_to_u16() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-to-u8.c b/tests/unistr/test-u32-to-u8.c
index 933fba09..deb45603 100644
--- a/tests/unistr/test-u32-to-u8.c
+++ b/tests/unistr/test-u32-to-u8.c
@@ -1,5 +1,5 @@
/* Test of u32_to_u8() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u32-uctomb.c b/tests/unistr/test-u32-uctomb.c
index 0a25177b..acc4c73f 100644
--- a/tests/unistr/test-u32-uctomb.c
+++ b/tests/unistr/test-u32-uctomb.c
@@ -1,5 +1,5 @@
/* Test of u32_uctomb() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u8-check.c b/tests/unistr/test-u8-check.c
index a32d3850..fcf678cd 100644
--- a/tests/unistr/test-u8-check.c
+++ b/tests/unistr/test-u8-check.c
@@ -1,5 +1,5 @@
/* Test of u8_check() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u8-chr.c b/tests/unistr/test-u8-chr.c
index 7c4b9990..2d28f9e7 100644
--- a/tests/unistr/test-u8-chr.c
+++ b/tests/unistr/test-u8-chr.c
@@ -1,5 +1,5 @@
/* Test of u8_chr() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -21,11 +21,14 @@
#include "unistr.h"
#include <stdlib.h>
+#include <string.h>
#include "zerosize-ptr.h"
#include "macros.h"
#define UNIT uint8_t
+#define U_UCTOMB u8_uctomb
+#define U32_TO_U u32_to_u8
#define U_CHR u8_chr
#define U_SET u8_set
#include "test-chr.h"
diff --git a/tests/unistr/test-u8-cmp.c b/tests/unistr/test-u8-cmp.c
index 73778c71..5606f0ae 100644
--- a/tests/unistr/test-u8-cmp.c
+++ b/tests/unistr/test-u8-cmp.c
@@ -1,5 +1,5 @@
/* Test of u8_cmp() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u8-cmp2.c b/tests/unistr/test-u8-cmp2.c
index 8a7848e8..07b52d92 100644
--- a/tests/unistr/test-u8-cmp2.c
+++ b/tests/unistr/test-u8-cmp2.c
@@ -1,5 +1,5 @@
/* Test of u8_cmp2() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u8-cpy-alloc.c b/tests/unistr/test-u8-cpy-alloc.c
index 2d35b8f4..ff898138 100644
--- a/tests/unistr/test-u8-cpy-alloc.c
+++ b/tests/unistr/test-u8-cpy-alloc.c
@@ -1,5 +1,5 @@
/* Test of u8_cpy_alloc() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u8-cpy.c b/tests/unistr/test-u8-cpy.c
index 8d1152dc..2e2c06f3 100644
--- a/tests/unistr/test-u8-cpy.c
+++ b/tests/unistr/test-u8-cpy.c
@@ -1,5 +1,5 @@
/* Test of u8_cpy() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u8-mblen.c b/tests/unistr/test-u8-mblen.c
index 75e92d68..3e68b665 100644
--- a/tests/unistr/test-u8-mblen.c
+++ b/tests/unistr/test-u8-mblen.c
@@ -1,5 +1,5 @@
/* Test of u8_mblen() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u8-mbsnlen.c b/tests/unistr/test-u8-mbsnlen.c
index 8e68550c..e57e3ea8 100644
--- a/tests/unistr/test-u8-mbsnlen.c
+++ b/tests/unistr/test-u8-mbsnlen.c
@@ -1,5 +1,5 @@
/* Test of u8_mbsnlen() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -57,5 +57,64 @@ main ()
}
}
+ /* Test behaviour required by ISO 10646-1, sections R.7 and 2.3c, namely,
+ that a "malformed sequence" is interpreted in the same way as
+ "a character that is outside the adopted subset".
+ Reference:
+ Markus Kuhn: UTF-8 decoder capability and stress test
+ <http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt>
+ <http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html>
+ */
+ /* 3.1. Test that each unexpected continuation byte is signalled as a
+ malformed sequence of its own. */
+ {
+ static const uint8_t input[] = { '"', 0x80, 0xBF, 0x80, 0xBF, '"' };
+ ASSERT (u8_mbsnlen (input, 6) == 6);
+ }
+ /* 3.2. Lonely start characters. */
+ {
+ ucs4_t c;
+ uint8_t input[2];
+
+ for (c = 0xC0; c <= 0xFF; c++)
+ {
+ input[0] = c;
+ input[1] = ' ';
+
+ ASSERT (u8_mbsnlen (input, 2) == 2);
+ }
+ }
+ /* 3.3. Sequences with last continuation byte missing. */
+ /* 3.3.1. 2-byte sequence with last byte missing. */
+ {
+ static const uint8_t input[] = { '"', 0xC0, '"' };
+ ASSERT (u8_mbsnlen (input, 3) == 3);
+ }
+ /* 3.3.6. 2-byte sequence with last byte missing. */
+ {
+ static const uint8_t input[] = { '"', 0xDF, '"' };
+ ASSERT (u8_mbsnlen (input, 3) == 3);
+ }
+ /* 3.3.2. 3-byte sequence with last byte missing. */
+ {
+ static const uint8_t input[] = { '"', 0xE0, 0x80, '"' };
+ ASSERT (u8_mbsnlen (input, 4) == 3);
+ }
+ /* 3.3.7. 3-byte sequence with last byte missing. */
+ {
+ static const uint8_t input[] = { '"', 0xEF, 0xBF, '"' };
+ ASSERT (u8_mbsnlen (input, 4) == 3);
+ }
+ /* 3.3.3. 4-byte sequence with last byte missing. */
+ {
+ static const uint8_t input[] = { '"', 0xF0, 0x80, 0x80, '"' };
+ ASSERT (u8_mbsnlen (input, 5) == 3);
+ }
+ /* 3.3.8. 4-byte sequence with last byte missing. */
+ {
+ static const uint8_t input[] = { '"', 0xF7, 0xBF, 0xBF, '"' };
+ ASSERT (u8_mbsnlen (input, 5) == 3);
+ }
+
return 0;
}
diff --git a/tests/unistr/test-u8-mbtouc-unsafe.c b/tests/unistr/test-u8-mbtouc-unsafe.c
index b093aa81..cf9ba19c 100644
--- a/tests/unistr/test-u8-mbtouc-unsafe.c
+++ b/tests/unistr/test-u8-mbtouc-unsafe.c
@@ -1,5 +1,5 @@
/* Test of u8_mbtouc_unsafe() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u8-mbtouc.c b/tests/unistr/test-u8-mbtouc.c
index f6960a68..9e3b9601 100644
--- a/tests/unistr/test-u8-mbtouc.c
+++ b/tests/unistr/test-u8-mbtouc.c
@@ -1,5 +1,5 @@
/* Test of u8_mbtouc() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -24,10 +24,169 @@
#include "test-u8-mbtouc.h"
+static void
+test_safe_function (int (*my_u8_mbtouc) (ucs4_t *, const uint8_t *, size_t))
+{
+ ucs4_t uc;
+ int ret;
+
+ /* Test behaviour required by ISO 10646-1, sections R.7 and 2.3c, namely,
+ that a "malformed sequence" is interpreted in the same way as
+ "a character that is outside the adopted subset".
+ Reference:
+ Markus Kuhn: UTF-8 decoder capability and stress test
+ <http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt>
+ <http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html>
+ */
+ /* 3.1. Test that each unexpected continuation byte is signalled as a
+ malformed sequence of its own. */
+ {
+ static const uint8_t input[] = { '"', 0x80, 0xBF, 0x80, 0xBF, '"' };
+ uc = 0xBADFACE;
+ ret = my_u8_mbtouc (&uc, input, 6);
+ ASSERT (ret == 1);
+ ASSERT (uc == 0x0022);
+ uc = 0xBADFACE;
+ ret = my_u8_mbtouc (&uc, input + 1, 5);
+ ASSERT (ret == 1);
+ ASSERT (uc == 0xFFFD);
+ uc = 0xBADFACE;
+ ret = my_u8_mbtouc (&uc, input + 2, 4);
+ ASSERT (ret == 1);
+ ASSERT (uc == 0xFFFD);
+ uc = 0xBADFACE;
+ ret = my_u8_mbtouc (&uc, input + 3, 3);
+ ASSERT (ret == 1);
+ ASSERT (uc == 0xFFFD);
+ uc = 0xBADFACE;
+ ret = my_u8_mbtouc (&uc, input + 4, 2);
+ ASSERT (ret == 1);
+ ASSERT (uc == 0xFFFD);
+ uc = 0xBADFACE;
+ ret = my_u8_mbtouc (&uc, input + 5, 1);
+ ASSERT (ret == 1);
+ ASSERT (uc == 0x0022);
+ }
+ /* 3.2. Lonely start characters. */
+ {
+ ucs4_t c;
+ uint8_t input[2];
+
+ for (c = 0xC0; c <= 0xFF; c++)
+ {
+ input[0] = c;
+ input[1] = ' ';
+
+ uc = 0xBADFACE;
+ ret = my_u8_mbtouc (&uc, input, 2);
+ ASSERT (ret == 1);
+ ASSERT (uc == 0xFFFD);
+ }
+ }
+ /* 3.3. Sequences with last continuation byte missing. */
+ /* 3.3.1. 2-byte sequence with last byte missing. */
+ {
+ static const uint8_t input[] = { '"', 0xC0, '"' };
+ uc = 0xBADFACE;
+ ret = my_u8_mbtouc (&uc, input, 3);
+ ASSERT (ret == 1);
+ ASSERT (uc == 0x0022);
+ uc = 0xBADFACE;
+ ret = my_u8_mbtouc (&uc, input + 1, 2);
+ ASSERT (ret == 1);
+ ASSERT (uc == 0xFFFD);
+ uc = 0xBADFACE;
+ ret = my_u8_mbtouc (&uc, input + 2, 1);
+ ASSERT (ret == 1);
+ ASSERT (uc == 0x0022);
+ }
+ /* 3.3.6. 2-byte sequence with last byte missing. */
+ {
+ static const uint8_t input[] = { '"', 0xDF, '"' };
+ uc = 0xBADFACE;
+ ret = my_u8_mbtouc (&uc, input, 3);
+ ASSERT (ret == 1);
+ ASSERT (uc == 0x0022);
+ uc = 0xBADFACE;
+ ret = my_u8_mbtouc (&uc, input + 1, 2);
+ ASSERT (ret == 1);
+ ASSERT (uc == 0xFFFD);
+ uc = 0xBADFACE;
+ ret = my_u8_mbtouc (&uc, input + 2, 1);
+ ASSERT (ret == 1);
+ ASSERT (uc == 0x0022);
+ }
+ /* 3.3.2. 3-byte sequence with last byte missing. */
+ {
+ static const uint8_t input[] = { '"', 0xE0, 0x80, '"' };
+ uc = 0xBADFACE;
+ ret = my_u8_mbtouc (&uc, input, 4);
+ ASSERT (ret == 1);
+ ASSERT (uc == 0x0022);
+ uc = 0xBADFACE;
+ ret = my_u8_mbtouc (&uc, input + 1, 3);
+ ASSERT (ret == 2);
+ ASSERT (uc == 0xFFFD);
+ uc = 0xBADFACE;
+ ret = my_u8_mbtouc (&uc, input + 3, 1);
+ ASSERT (ret == 1);
+ ASSERT (uc == 0x0022);
+ }
+ /* 3.3.7. 3-byte sequence with last byte missing. */
+ {
+ static const uint8_t input[] = { '"', 0xEF, 0xBF, '"' };
+ uc = 0xBADFACE;
+ ret = my_u8_mbtouc (&uc, input, 4);
+ ASSERT (ret == 1);
+ ASSERT (uc == 0x0022);
+ uc = 0xBADFACE;
+ ret = my_u8_mbtouc (&uc, input + 1, 3);
+ ASSERT (ret == 2);
+ ASSERT (uc == 0xFFFD);
+ uc = 0xBADFACE;
+ ret = my_u8_mbtouc (&uc, input + 3, 1);
+ ASSERT (ret == 1);
+ ASSERT (uc == 0x0022);
+ }
+ /* 3.3.3. 4-byte sequence with last byte missing. */
+ {
+ static const uint8_t input[] = { '"', 0xF0, 0x80, 0x80, '"' };
+ uc = 0xBADFACE;
+ ret = my_u8_mbtouc (&uc, input, 5);
+ ASSERT (ret == 1);
+ ASSERT (uc == 0x0022);
+ uc = 0xBADFACE;
+ ret = my_u8_mbtouc (&uc, input + 1, 4);
+ ASSERT (ret == 3);
+ ASSERT (uc == 0xFFFD);
+ uc = 0xBADFACE;
+ ret = my_u8_mbtouc (&uc, input + 4, 1);
+ ASSERT (ret == 1);
+ ASSERT (uc == 0x0022);
+ }
+ /* 3.3.8. 4-byte sequence with last byte missing. */
+ {
+ static const uint8_t input[] = { '"', 0xF7, 0xBF, 0xBF, '"' };
+ uc = 0xBADFACE;
+ ret = my_u8_mbtouc (&uc, input, 5);
+ ASSERT (ret == 1);
+ ASSERT (uc == 0x0022);
+ uc = 0xBADFACE;
+ ret = my_u8_mbtouc (&uc, input + 1, 4);
+ ASSERT (ret == 3);
+ ASSERT (uc == 0xFFFD);
+ uc = 0xBADFACE;
+ ret = my_u8_mbtouc (&uc, input + 4, 1);
+ ASSERT (ret == 1);
+ ASSERT (uc == 0x0022);
+ }
+}
+
int
main ()
{
test_function (u8_mbtouc);
+ test_safe_function (u8_mbtouc);
return 0;
}
diff --git a/tests/unistr/test-u8-mbtouc.h b/tests/unistr/test-u8-mbtouc.h
index bcafb052..295160d5 100644
--- a/tests/unistr/test-u8-mbtouc.h
+++ b/tests/unistr/test-u8-mbtouc.h
@@ -1,5 +1,5 @@
/* Test of u8_mbtouc() and u8_mbtouc_unsafe() functions.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -166,14 +166,14 @@ test_function (int (*my_u8_mbtouc) (ucs4_t *, const uint8_t *, size_t))
static const uint8_t input[] = { 0xF3, 0xD0, 0xBF };
uc = 0xBADFACE;
ret = my_u8_mbtouc (&uc, input, 3);
- ASSERT (ret == 1 || ret == 3);
+ ASSERT (ret == 1);
ASSERT (uc == 0xFFFD);
}
{
static const uint8_t input[] = { 0xF3, 0x8F, 0xD0 };
uc = 0xBADFACE;
ret = my_u8_mbtouc (&uc, input, 3);
- ASSERT (ret == 1 || ret == 3);
+ ASSERT (ret == 2);
ASSERT (uc == 0xFFFD);
}
}
diff --git a/tests/unistr/test-u8-mbtoucr.c b/tests/unistr/test-u8-mbtoucr.c
index 88e08d39..7f02e8b8 100644
--- a/tests/unistr/test-u8-mbtoucr.c
+++ b/tests/unistr/test-u8-mbtoucr.c
@@ -1,5 +1,5 @@
/* Test of u8_mbtoucr() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u8-move.c b/tests/unistr/test-u8-move.c
index d18d8dd2..eed72b46 100644
--- a/tests/unistr/test-u8-move.c
+++ b/tests/unistr/test-u8-move.c
@@ -1,5 +1,5 @@
/* Test of u8_move() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u8-next.c b/tests/unistr/test-u8-next.c
index c4e06b59..4c509aa4 100644
--- a/tests/unistr/test-u8-next.c
+++ b/tests/unistr/test-u8-next.c
@@ -1,5 +1,5 @@
/* Test of u8_next() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u8-prev.c b/tests/unistr/test-u8-prev.c
index 61f47ef8..9e2a9ba6 100644
--- a/tests/unistr/test-u8-prev.c
+++ b/tests/unistr/test-u8-prev.c
@@ -1,5 +1,5 @@
/* Test of u8_prev() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u8-set.c b/tests/unistr/test-u8-set.c
index e778fed9..de2f2810 100644
--- a/tests/unistr/test-u8-set.c
+++ b/tests/unistr/test-u8-set.c
@@ -1,5 +1,5 @@
/* Test of u8_set() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u8-stpcpy.c b/tests/unistr/test-u8-stpcpy.c
index 94c04715..d7403e87 100644
--- a/tests/unistr/test-u8-stpcpy.c
+++ b/tests/unistr/test-u8-stpcpy.c
@@ -1,5 +1,5 @@
/* Test of u8_stpcpy() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u8-stpncpy.c b/tests/unistr/test-u8-stpncpy.c
index 4809626b..18f11df5 100644
--- a/tests/unistr/test-u8-stpncpy.c
+++ b/tests/unistr/test-u8-stpncpy.c
@@ -1,5 +1,5 @@
/* Test of u8_stpncpy() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u8-strcat.c b/tests/unistr/test-u8-strcat.c
index 7fa9e84e..7f4a0959 100644
--- a/tests/unistr/test-u8-strcat.c
+++ b/tests/unistr/test-u8-strcat.c
@@ -1,5 +1,5 @@
/* Test of u8_strcat() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u8-strchr.c b/tests/unistr/test-u8-strchr.c
new file mode 100644
index 00000000..ff7abe6c
--- /dev/null
+++ b/tests/unistr/test-u8-strchr.c
@@ -0,0 +1,149 @@
+/* Test of u8_strchr() function.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Paolo Bonzini <bonzini@gnu.org>, 2010. */
+
+#include <config.h>
+
+#include "unistr.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "zerosize-ptr.h"
+#include "macros.h"
+
+#define UNIT uint8_t
+#define U_UCTOMB u8_uctomb
+#define U32_TO_U u32_to_u8
+#define U_STRCHR u8_strchr
+#define U_SET u8_set
+#include "test-strchr.h"
+
+int
+main (void)
+{
+ test_strchr ();
+
+ /* Check that u8_strchr() does not read past the end of the string. */
+ {
+ char *page_boundary = (char *) zerosize_ptr ();
+
+ if (page_boundary != NULL)
+ {
+ UNIT *mem;
+
+ mem = (UNIT *) (page_boundary - 1 * sizeof (UNIT));
+ mem[0] = 0;
+ ASSERT (u8_strchr (mem, 0x55) == NULL);
+ ASSERT (u8_strchr (mem, 0x123) == NULL);
+ ASSERT (u8_strchr (mem, 0x3456) == NULL);
+ ASSERT (u8_strchr (mem, 0x23456) == NULL);
+
+ mem = (UNIT *) (page_boundary - 2 * sizeof (UNIT));
+ mem[0] = 0x50;
+ mem[1] = 0;
+ ASSERT (u8_strchr (mem, 0x55) == NULL);
+ ASSERT (u8_strchr (mem, 0x123) == NULL);
+ ASSERT (u8_strchr (mem, 0x3456) == NULL);
+ ASSERT (u8_strchr (mem, 0x23456) == NULL);
+
+ mem = (UNIT *) (page_boundary - 3 * sizeof (UNIT));
+ mem[0] = 0x50;
+ mem[1] = 0x50;
+ mem[2] = 0;
+ ASSERT (u8_strchr (mem, 0x55) == NULL);
+ ASSERT (u8_strchr (mem, 0x123) == NULL);
+ ASSERT (u8_strchr (mem, 0x3456) == NULL);
+ ASSERT (u8_strchr (mem, 0x23456) == NULL);
+
+ mem = (UNIT *) (page_boundary - 3 * sizeof (UNIT));
+ mem[0] = 0xC4; mem[1] = 0xA0; /* U+0120 */
+ mem[2] = 0;
+ ASSERT (u8_strchr (mem, 0x55) == NULL);
+ ASSERT (u8_strchr (mem, 0x123) == NULL);
+ ASSERT (u8_strchr (mem, 0x3456) == NULL);
+ ASSERT (u8_strchr (mem, 0x23456) == NULL);
+
+ mem = (UNIT *) (page_boundary - 3 * sizeof (UNIT));
+ mem[0] = 0xC5; mem[1] = 0xA3; /* U+0163 */
+ mem[2] = 0;
+ ASSERT (u8_strchr (mem, 0x55) == NULL);
+ ASSERT (u8_strchr (mem, 0x123) == NULL);
+ ASSERT (u8_strchr (mem, 0x3456) == NULL);
+ ASSERT (u8_strchr (mem, 0x23456) == NULL);
+
+ mem = (UNIT *) (page_boundary - 4 * sizeof (UNIT));
+ mem[0] = 0x50;
+ mem[1] = 0x50;
+ mem[2] = 0x50;
+ mem[3] = 0;
+ ASSERT (u8_strchr (mem, 0x55) == NULL);
+ ASSERT (u8_strchr (mem, 0x123) == NULL);
+ ASSERT (u8_strchr (mem, 0x3456) == NULL);
+ ASSERT (u8_strchr (mem, 0x23456) == NULL);
+
+ mem = (UNIT *) (page_boundary - 4 * sizeof (UNIT));
+ mem[0] = 0x50;
+ mem[1] = 0xC5; mem[2] = 0xA3; /* U+0163 */
+ mem[3] = 0;
+ ASSERT (u8_strchr (mem, 0x55) == NULL);
+ ASSERT (u8_strchr (mem, 0x123) == NULL);
+ ASSERT (u8_strchr (mem, 0x3456) == NULL);
+ ASSERT (u8_strchr (mem, 0x23456) == NULL);
+ ASSERT (u8_strchr (mem, 0x163) == mem + 1);
+
+ mem = (UNIT *) (page_boundary - 4 * sizeof (UNIT));
+ mem[0] = 0xE3; mem[1] = 0x91; mem[2] = 0x00; /* U+3450 */
+ mem[3] = 0;
+ ASSERT (u8_strchr (mem, 0x55) == NULL);
+ ASSERT (u8_strchr (mem, 0x123) == NULL);
+ ASSERT (u8_strchr (mem, 0x3456) == NULL);
+ ASSERT (u8_strchr (mem, 0x23456) == NULL);
+
+ mem = (UNIT *) (page_boundary - 4 * sizeof (UNIT));
+ mem[0] = 0xE3; mem[1] = 0x92; mem[2] = 0x96; /* U+3496 */
+ mem[3] = 0;
+ ASSERT (u8_strchr (mem, 0x55) == NULL);
+ ASSERT (u8_strchr (mem, 0x123) == NULL);
+ ASSERT (u8_strchr (mem, 0x3456) == NULL);
+ ASSERT (u8_strchr (mem, 0x23456) == NULL);
+
+ mem = (UNIT *) (page_boundary - 5 * sizeof (UNIT));
+ mem[0] = 0x50;
+ mem[1] = 0x50;
+ mem[2] = 0x50;
+ mem[3] = 0x50;
+ mem[4] = 0;
+ ASSERT (u8_strchr (mem, 0x55) == NULL);
+ ASSERT (u8_strchr (mem, 0x123) == NULL);
+ ASSERT (u8_strchr (mem, 0x3456) == NULL);
+ ASSERT (u8_strchr (mem, 0x23456) == NULL);
+
+ mem = (UNIT *) (page_boundary - 5 * sizeof (UNIT));
+ mem[0] = 0x50;
+ mem[1] = 0xE3; mem[2] = 0x92; mem[3] = 0x96; /* U+3496 */
+ mem[4] = 0;
+ ASSERT (u8_strchr (mem, 0x55) == NULL);
+ ASSERT (u8_strchr (mem, 0x123) == NULL);
+ ASSERT (u8_strchr (mem, 0x3456) == NULL);
+ ASSERT (u8_strchr (mem, 0x23456) == NULL);
+ ASSERT (u8_strchr (mem, 0x3496) == mem + 1);
+ }
+ }
+
+ return 0;
+}
diff --git a/tests/unistr/test-u8-strcmp.c b/tests/unistr/test-u8-strcmp.c
index 313cd110..51a90db3 100644
--- a/tests/unistr/test-u8-strcmp.c
+++ b/tests/unistr/test-u8-strcmp.c
@@ -1,5 +1,5 @@
/* Test of u8_strcmp() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u8-strcmp.h b/tests/unistr/test-u8-strcmp.h
index 9c25dac4..66dec745 100644
--- a/tests/unistr/test-u8-strcmp.h
+++ b/tests/unistr/test-u8-strcmp.h
@@ -1,5 +1,5 @@
/* Test of u8_strcmp() and u8_strcoll() functions.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u8-strcoll.c b/tests/unistr/test-u8-strcoll.c
index ae5c9a4e..73f42ddc 100644
--- a/tests/unistr/test-u8-strcoll.c
+++ b/tests/unistr/test-u8-strcoll.c
@@ -1,5 +1,5 @@
/* Test of u8_strcoll() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u8-strcpy.c b/tests/unistr/test-u8-strcpy.c
index 810f9750..2dd02013 100644
--- a/tests/unistr/test-u8-strcpy.c
+++ b/tests/unistr/test-u8-strcpy.c
@@ -1,5 +1,5 @@
/* Test of u8_strcpy() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u8-strdup.c b/tests/unistr/test-u8-strdup.c
index 6da21515..c72b3d28 100644
--- a/tests/unistr/test-u8-strdup.c
+++ b/tests/unistr/test-u8-strdup.c
@@ -1,5 +1,5 @@
/* Test of u8_strdup() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u8-strlen.c b/tests/unistr/test-u8-strlen.c
index 3dfa1b01..d4b32243 100644
--- a/tests/unistr/test-u8-strlen.c
+++ b/tests/unistr/test-u8-strlen.c
@@ -1,5 +1,5 @@
/* Test of u8_strlen() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u8-strmblen.c b/tests/unistr/test-u8-strmblen.c
index bde3000e..46bee920 100644
--- a/tests/unistr/test-u8-strmblen.c
+++ b/tests/unistr/test-u8-strmblen.c
@@ -1,5 +1,5 @@
/* Test of u8_strmblen() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u8-strmbtouc.c b/tests/unistr/test-u8-strmbtouc.c
index 55913575..1239f40b 100644
--- a/tests/unistr/test-u8-strmbtouc.c
+++ b/tests/unistr/test-u8-strmbtouc.c
@@ -1,5 +1,5 @@
/* Test of u8_strmbtouc() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u8-strncat.c b/tests/unistr/test-u8-strncat.c
index bb90041f..b7d248b3 100644
--- a/tests/unistr/test-u8-strncat.c
+++ b/tests/unistr/test-u8-strncat.c
@@ -1,5 +1,5 @@
/* Test of u8_strncat() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u8-strncmp.c b/tests/unistr/test-u8-strncmp.c
index f63cdaa2..5bd7b5e5 100644
--- a/tests/unistr/test-u8-strncmp.c
+++ b/tests/unistr/test-u8-strncmp.c
@@ -1,5 +1,5 @@
/* Test of u8_strncmp() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u8-strncpy.c b/tests/unistr/test-u8-strncpy.c
index 64cabdc4..5e20beb9 100644
--- a/tests/unistr/test-u8-strncpy.c
+++ b/tests/unistr/test-u8-strncpy.c
@@ -1,5 +1,5 @@
/* Test of u8_strncpy() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u8-strnlen.c b/tests/unistr/test-u8-strnlen.c
index 98de7977..c59d7b18 100644
--- a/tests/unistr/test-u8-strnlen.c
+++ b/tests/unistr/test-u8-strnlen.c
@@ -1,5 +1,5 @@
/* Test of u8_strnlen() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u8-strstr.c b/tests/unistr/test-u8-strstr.c
new file mode 100644
index 00000000..3d7be9c3
--- /dev/null
+++ b/tests/unistr/test-u8-strstr.c
@@ -0,0 +1,50 @@
+/* Test of u8_strstr() function.
+ Copyright (C) 2011-2015 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Pádraig Brady <P@draigBrady.com>, 2011. */
+
+#include <config.h>
+
+#include "unistr.h"
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <signal.h> /* For signal. */
+#include <unistd.h> /* For alarm. */
+
+#include "macros.h"
+
+#define UNIT uint8_t
+#define U_STRSTR u8_strstr
+#include "test-u-strstr.h"
+
+int
+main (void)
+{
+#if HAVE_DECL_ALARM
+ /* Declare failure if test takes too long, by using default abort
+ caused by SIGALRM. Note since we defer to strstr() in this
+ case, we're assuming that we're running this test on the
+ same system that we did the check to ensure it has linear
+ performance characteristics. */
+ signal (SIGALRM, SIG_DFL);
+ alarm (5);
+#endif
+
+ test_u_strstr ();
+
+ return 0;
+}
diff --git a/tests/unistr/test-u8-strtok.c b/tests/unistr/test-u8-strtok.c
new file mode 100644
index 00000000..6745ea8a
--- /dev/null
+++ b/tests/unistr/test-u8-strtok.c
@@ -0,0 +1,37 @@
+/* Test of u8_strtok() function.
+ Copyright (C) 2015 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+#include "unistr.h"
+
+#include <stdint.h>
+#include <stdlib.h>
+
+#include "macros.h"
+
+#define UNIT uint8_t
+#define U_STRTOK u8_strtok
+#define U_UCTOMB u8_uctomb
+#include "test-u-strtok.h"
+
+int
+main (void)
+{
+ test_u_strtok ();
+
+ return 0;
+}
diff --git a/tests/unistr/test-u8-to-u16.c b/tests/unistr/test-u8-to-u16.c
index 02ef44fe..5f3ddadd 100644
--- a/tests/unistr/test-u8-to-u16.c
+++ b/tests/unistr/test-u8-to-u16.c
@@ -1,5 +1,5 @@
/* Test of u8_to_u16() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u8-to-u32.c b/tests/unistr/test-u8-to-u32.c
index d148e62a..26ff0029 100644
--- a/tests/unistr/test-u8-to-u32.c
+++ b/tests/unistr/test-u8-to-u32.c
@@ -1,5 +1,5 @@
/* Test of u8_to_u32() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistr/test-u8-uctomb.c b/tests/unistr/test-u8-uctomb.c
index 8fbdc429..f586f04d 100644
--- a/tests/unistr/test-u8-uctomb.c
+++ b/tests/unistr/test-u8-uctomb.c
@@ -1,5 +1,5 @@
/* Test of u8_uctomb() function.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by