summaryrefslogtreecommitdiff
path: root/tests/unistr/test-u-strtok.h
diff options
context:
space:
mode:
authorStephen Kitt <skitt@debian.org>2016-05-27 10:11:04 +0200
committerManuel A. Fernandez Montecelo <manuel.montezelo@gmail.com>2016-05-27 14:28:33 +0100
commit752fd7247bc223bcea35bd89cf56d1c08ead9ba6 (patch)
treeb4a428f847a963738faaf24c8eff070fdb03a3a5 /tests/unistr/test-u-strtok.h
parent9f7d4fa477ff2a51d7c932b13d57ac22dc033105 (diff)
parenta9a31b1de5776a3b08a82101a4fa711294f0dd1d (diff)
Imported Debian patch 0.9.6+really0.9.3-0.1debian/0.9.6+really0.9.3-0.1
Diffstat (limited to 'tests/unistr/test-u-strtok.h')
-rw-r--r--tests/unistr/test-u-strtok.h88
1 files changed, 0 insertions, 88 deletions
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);
- }
-}