diff options
Diffstat (limited to 'tests/unistr')
131 files changed, 139 insertions, 1347 deletions
diff --git a/tests/unistr/test-chr.h b/tests/unistr/test-chr.h index cd5a45e..5a021c2 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-2015 Free Software Foundation, Inc. + Copyright (C) 2008-2010 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,65 +19,32 @@ int main (void) { - 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); + size_t n = 0x100000; + UNIT *input = (UNIT *) malloc (n * sizeof (UNIT)); 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, length, 'a') == input); + ASSERT (U_CHR (input, n, 'a') == input); ASSERT (U_CHR (input, 0, 'a') == NULL); ASSERT (U_CHR (zerosize_ptr (), 0, 'a') == NULL); - 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, n, 'b') == input + 1); + ASSERT (U_CHR (input, n, 'c') == input + 2); + ASSERT (U_CHR (input, n, 'd') == input + 1026); - 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 + 1, n - 1, 'a') == input + n - 1); + ASSERT (U_CHR (input + 1, n - 1, 'e') == input + n - 2); - ASSERT (U_CHR (input, length, 'f') == NULL); - ASSERT (U_CHR (input, length, '\0') == NULL); + ASSERT (U_CHR (input, n, 'f') == NULL); + ASSERT (U_CHR (input, n, '\0') == NULL); /* Check that a very long haystack is handled quickly if the byte is found near the beginning. */ @@ -85,7 +52,7 @@ main (void) size_t repeat = 10000; for (; repeat > 0; repeat--) { - ASSERT (U_CHR (input, length, 'c') == input + 2); + ASSERT (U_CHR (input, n, 'c') == input + 2); } } @@ -107,7 +74,6 @@ 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 aece9b0..e536f48 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-2015 Free Software Foundation, Inc. + Copyright (C) 2008-2010 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 c405099..261fe36 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-2015 Free Software Foundation, Inc. + Copyright (C) 2008-2010 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 261a677..795e0b7 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 bc8fe53..b62fd14 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 d2c3921..2462367 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 8d36636..56924dc 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 a924853..76065dc 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 3cb2958..bb81ff0 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 e454e93..6c1f90d 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 deleted file mode 100644 index 191d74e..0000000 --- a/tests/unistr/test-strchr.h +++ /dev/null @@ -1,161 +0,0 @@ -/* 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 d5fcbe9..485b6f9 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 50d28e1..f8fe5ef 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 44246e5..1684b39 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 fc4494e..0445b6d 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 3a28784..628db94 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 492e7b8..6fa0d12 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 0a5ce8b..1199126 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 deleted file mode 100644 index 417f8b3..0000000 --- a/tests/unistr/test-u-strstr.h +++ /dev/null @@ -1,210 +0,0 @@ -/* 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 deleted file mode 100644 index 6c12484..0000000 --- a/tests/unistr/test-u-strtok.h +++ /dev/null @@ -1,88 +0,0 @@ -/* 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 23adffe..b7a9c10 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 7ffeb57..d71755c 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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,14 +21,11 @@ #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 ab2025b..1ab9019 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 1a7ce04..3993dcd 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 a62502f..d1aa211 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 b109514..168a459 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 5cec88d..13186f3 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 4e99b57..a2d8b10 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 6811033..a1d1214 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 f673ee8..4545add 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 7019b4a..ef0fb68 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 bf93b12..fb1264d 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 32588d5..ff1e6e3 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 f338f76..d9ac6e9 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 8dcf6c1..90e8341 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 a545f29..f3e6305 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 9615999..6bf3ecb 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 5bebcfb..e53ce6b 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 d381d0c..9d6032e 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 deleted file mode 100644 index d33f740..0000000 --- a/tests/unistr/test-u16-strchr.c +++ /dev/null @@ -1,42 +0,0 @@ -/* 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 9c97613..5fc4777 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 6a3d988..ad54a43 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 ac32c5b..e24814a 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 e274d78..e017a11 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 33d1d0b..f0266d1 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 40f6af3..7b8690b 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 36103a2..80371b0 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 fb6f08a..ceeaf2c 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 9a407f0..c875cfc 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 c6ed7c0..b04431b 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 21e302d..102f653 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 85ff647..beeba64 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 deleted file mode 100644 index 8f0f4f1..0000000 --- a/tests/unistr/test-u16-strstr.c +++ /dev/null @@ -1,47 +0,0 @@ -/* 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 deleted file mode 100644 index cbd95ef..0000000 --- a/tests/unistr/test-u16-strtok.c +++ /dev/null @@ -1,37 +0,0 @@ -/* 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 e095643..5b382b2 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 f62c21e..4ef9b9b 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 cfa2104..ba50225 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 49099ec..fdd64df 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 ae274f4..f23aa08 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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,14 +21,11 @@ #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 20c0646..ab41b31 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 376aa73..84450b5 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 73a4b85..d3675dd 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 cf11e6c..49fc995 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 1e038e1..1ebd93e 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 9a87634..d9e066b 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 d0ee0af..cb3052c 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 e582979..7c981b5 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 b0a7498..7d70133 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 898baa2..7b1034c 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 0dd9e30..44f95c0 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 339ffb9..a5852e2 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 a49525d..95187af 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 0051609..120804f 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 04a16a5..9c99c52 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 4b99666..e29683b 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 02f9615..66e7c85 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 deleted file mode 100644 index 054b996..0000000 --- a/tests/unistr/test-u32-strchr.c +++ /dev/null @@ -1,42 +0,0 @@ -/* 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 8b420cf..8364a41 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 4b1fdd0..6d24132 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 f718a82..36954e7 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 b388890..2e22aad 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 c200e65..ede8e54 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 a797398..a349be7 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 0b74531..733f8fc 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 39451f7..79c222e 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 2c78c8f..346bafb 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 f1cad81..d69913d 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 ebe0add..9309c0e 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 7941ab3..6929914 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 deleted file mode 100644 index c291b3c..0000000 --- a/tests/unistr/test-u32-strstr.c +++ /dev/null @@ -1,47 +0,0 @@ -/* 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 deleted file mode 100644 index 04cded7..0000000 --- a/tests/unistr/test-u32-strtok.c +++ /dev/null @@ -1,37 +0,0 @@ -/* 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 65e1985..6faf537 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 deb4560..933fba0 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 acc4c73..0a25177 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 fcf678c..a32d385 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 2d28f9e..7c4b999 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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,14 +21,11 @@ #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 5606f0a..73778c7 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 07b52d9..8a7848e 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 ff89813..2d35b8f 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 2e2c06f..8d1152d 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 3e68b66..75e92d6 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 e57e3ea..8e68550 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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,64 +57,5 @@ 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 cf9ba19..b093aa8 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 9e3b960..f6960a6 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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,169 +24,10 @@ #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 295160d..bcafb05 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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); + ASSERT (ret == 1 || ret == 3); ASSERT (uc == 0xFFFD); } { static const uint8_t input[] = { 0xF3, 0x8F, 0xD0 }; uc = 0xBADFACE; ret = my_u8_mbtouc (&uc, input, 3); - ASSERT (ret == 2); + ASSERT (ret == 1 || ret == 3); ASSERT (uc == 0xFFFD); } } diff --git a/tests/unistr/test-u8-mbtoucr.c b/tests/unistr/test-u8-mbtoucr.c index 7f02e8b..88e08d3 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 eed72b4..d18d8dd 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 4c509aa..c4e06b5 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 9e2a9ba..61f47ef 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 de2f281..e778fed 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 d7403e8..94c0471 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 18f11df..4809626 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 7f4a095..7fa9e84 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 deleted file mode 100644 index ff7abe6..0000000 --- a/tests/unistr/test-u8-strchr.c +++ /dev/null @@ -1,149 +0,0 @@ -/* 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 51a90db..313cd11 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 66dec74..9c25dac 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 73f42dd..ae5c9a4 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 2dd0201..810f975 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 c72b3d2..6da2151 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 d4b3224..3dfa1b0 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 46bee92..bde3000 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 1239f40..5591357 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 b7d248b..bb90041 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 5bd7b5e..f63cdaa 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 5e20beb..64cabdc 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 c59d7b1..98de797 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 deleted file mode 100644 index 3d7be9c..0000000 --- a/tests/unistr/test-u8-strstr.c +++ /dev/null @@ -1,50 +0,0 @@ -/* 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 deleted file mode 100644 index 6745ea8..0000000 --- a/tests/unistr/test-u8-strtok.c +++ /dev/null @@ -1,37 +0,0 @@ -/* 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 5f3ddad..02ef44f 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 26ff002..d148e62 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 f586f04..8fbdc42 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-2015 Free Software Foundation, Inc. + Copyright (C) 2010 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 |