Mercurial > gnulib
annotate tests/unistr/test-chr.h @ 40224:5d9b82ca550a
tests: Free allocated memory.
Reported by <deltatau@protonmail.com> via Assaf Gordon.
* tests/test-astrxfrm.c (main): Free allocated memory.
* tests/test-bitset.c (compare, check_attributes): Free allocated
bitsets.
* tests/test-filenamecat.c (main): Free allocated memory.
* tests/test-freadahead.c (main): Free allocated memory and close stdin.
* tests/test-freadptr.c (main): Likewise.
* tests/test-freadptr2.c (main): Free allocated memory.
* tests/test-freadseek.c (main): Likewise.
* tests/test-gc-arcfour.c (main): Close allocated context.
* tests/test-gc-arctwo.c (main): Likewise.
* tests/test-gc-des.c (main): Close all allocated contexts.
* tests/test-pipe-filter-gi1.c (main): Free allocated memory.
* tests/test-pipe-filter-ii1.c (main): Likewise.
* tests/test-posix_spawn_file_actions_addchdir.c (main): Destroy the
allocated file actions.
* tests/test-posix_spawn_file_actions_addclose.c (main): Likewise.
* tests/test-posix_spawn_file_actions_adddup2.c (main): Likewise.
* tests/test-posix_spawn_file_actions_addopen.c (main): Likewise.
* tests/test-sameacls.c (main): Free allocated memory and ACLs.
* tests/test-strfmon_l.c (main): Free allocated locales.
* tests/test-striconveh.c (main): Free allocated iconv_t objects.
* tests/uniconv/test-u8-conv-to-enc.c (main): Free allocated memory.
* tests/uniconv/test-u16-conv-to-enc.c (main): Likewise.
* tests/uniconv/test-u32-conv-to-enc.c (main): Likewise.
* tests/unistr/test-chr.h (main): Free input32.
* tests/unistr/test-strchr.h (test_strchr): Likewise.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 10 Mar 2019 14:05:09 +0100 |
parents | b06060465f09 |
children |
rev | line source |
---|---|
12666
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
1 /* Test of uN_chr() functions. |
40057
b06060465f09
maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents:
19484
diff
changeset
|
2 Copyright (C) 2008-2019 Free Software Foundation, Inc. |
12666
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3 |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
4 This program is free software: you can redistribute it and/or modify |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
5 it under the terms of the GNU General Public License as published by |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
6 the Free Software Foundation; either version 3 of the License, or |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
7 (at your option) any later version. |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
8 |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
9 This program is distributed in the hope that it will be useful, |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
12 GNU General Public License for more details. |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
13 |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
14 You should have received a copy of the GNU General Public License |
19190 | 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
12666
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
16 |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
17 /* Written by Eric Blake and Bruno Haible <bruno@clisp.org>, 2010. */ |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
18 |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
19 int |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
20 main (void) |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
21 { |
13473
4ba511abfe7b
unistr/u*-chr: test multibyte sequences more
Paolo Bonzini <pbonzini@redhat.com>
parents:
13472
diff
changeset
|
22 size_t size = 0x100000; |
13472
5538ea968fcb
unistr/u*-chr: test multibyte sequences
Paolo Bonzini <pbonzini@redhat.com>
parents:
13471
diff
changeset
|
23 size_t i; |
13471
7ade914695f0
unistr/u*-chr: prepare for multibyte tests
Paolo Bonzini <pbonzini@redhat.com>
parents:
12666
diff
changeset
|
24 size_t length; |
7ade914695f0
unistr/u*-chr: prepare for multibyte tests
Paolo Bonzini <pbonzini@redhat.com>
parents:
12666
diff
changeset
|
25 UNIT *input; |
13473
4ba511abfe7b
unistr/u*-chr: test multibyte sequences more
Paolo Bonzini <pbonzini@redhat.com>
parents:
13472
diff
changeset
|
26 uint32_t *input32 = (uint32_t *) malloc (size * sizeof (uint32_t)); |
13471
7ade914695f0
unistr/u*-chr: prepare for multibyte tests
Paolo Bonzini <pbonzini@redhat.com>
parents:
12666
diff
changeset
|
27 ASSERT (input32); |
12666
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
28 |
13471
7ade914695f0
unistr/u*-chr: prepare for multibyte tests
Paolo Bonzini <pbonzini@redhat.com>
parents:
12666
diff
changeset
|
29 input32[0] = 'a'; |
7ade914695f0
unistr/u*-chr: prepare for multibyte tests
Paolo Bonzini <pbonzini@redhat.com>
parents:
12666
diff
changeset
|
30 input32[1] = 'b'; |
7ade914695f0
unistr/u*-chr: prepare for multibyte tests
Paolo Bonzini <pbonzini@redhat.com>
parents:
12666
diff
changeset
|
31 u32_set (input32 + 2, 'c', 1024); |
13473
4ba511abfe7b
unistr/u*-chr: test multibyte sequences more
Paolo Bonzini <pbonzini@redhat.com>
parents:
13472
diff
changeset
|
32 for (i = 1026; i < size - 2; i += 63) |
13472
5538ea968fcb
unistr/u*-chr: test multibyte sequences
Paolo Bonzini <pbonzini@redhat.com>
parents:
13471
diff
changeset
|
33 { |
13473
4ba511abfe7b
unistr/u*-chr: test multibyte sequences more
Paolo Bonzini <pbonzini@redhat.com>
parents:
13472
diff
changeset
|
34 size_t last = i + 63 < size - 2 ? i + 63 : size - 2; |
13472
5538ea968fcb
unistr/u*-chr: test multibyte sequences
Paolo Bonzini <pbonzini@redhat.com>
parents:
13471
diff
changeset
|
35 ucs4_t uc = 'd' | (i - 1026); |
5538ea968fcb
unistr/u*-chr: test multibyte sequences
Paolo Bonzini <pbonzini@redhat.com>
parents:
13471
diff
changeset
|
36 if (uc >= 0xd800 && uc <= 0xdfff) |
5538ea968fcb
unistr/u*-chr: test multibyte sequences
Paolo Bonzini <pbonzini@redhat.com>
parents:
13471
diff
changeset
|
37 uc |= 0x100000; |
5538ea968fcb
unistr/u*-chr: test multibyte sequences
Paolo Bonzini <pbonzini@redhat.com>
parents:
13471
diff
changeset
|
38 u32_set (input32 + i, uc, last - i); |
5538ea968fcb
unistr/u*-chr: test multibyte sequences
Paolo Bonzini <pbonzini@redhat.com>
parents:
13471
diff
changeset
|
39 } |
5538ea968fcb
unistr/u*-chr: test multibyte sequences
Paolo Bonzini <pbonzini@redhat.com>
parents:
13471
diff
changeset
|
40 |
13473
4ba511abfe7b
unistr/u*-chr: test multibyte sequences more
Paolo Bonzini <pbonzini@redhat.com>
parents:
13472
diff
changeset
|
41 input32[size - 2] = 'e'; |
4ba511abfe7b
unistr/u*-chr: test multibyte sequences more
Paolo Bonzini <pbonzini@redhat.com>
parents:
13472
diff
changeset
|
42 input32[size - 1] = 'a'; |
13471
7ade914695f0
unistr/u*-chr: prepare for multibyte tests
Paolo Bonzini <pbonzini@redhat.com>
parents:
12666
diff
changeset
|
43 |
13473
4ba511abfe7b
unistr/u*-chr: test multibyte sequences more
Paolo Bonzini <pbonzini@redhat.com>
parents:
13472
diff
changeset
|
44 input = U32_TO_U (input32, size, NULL, &length); |
13471
7ade914695f0
unistr/u*-chr: prepare for multibyte tests
Paolo Bonzini <pbonzini@redhat.com>
parents:
12666
diff
changeset
|
45 ASSERT (input); |
12666
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
46 |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
47 /* Basic behavior tests. */ |
13472
5538ea968fcb
unistr/u*-chr: test multibyte sequences
Paolo Bonzini <pbonzini@redhat.com>
parents:
13471
diff
changeset
|
48 ASSERT (U_CHR (input, length, 'a') == input); |
12666
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
49 |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
50 ASSERT (U_CHR (input, 0, 'a') == NULL); |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
51 ASSERT (U_CHR (zerosize_ptr (), 0, 'a') == NULL); |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
52 |
13472
5538ea968fcb
unistr/u*-chr: test multibyte sequences
Paolo Bonzini <pbonzini@redhat.com>
parents:
13471
diff
changeset
|
53 ASSERT (U_CHR (input, length, 'b') == input + 1); |
5538ea968fcb
unistr/u*-chr: test multibyte sequences
Paolo Bonzini <pbonzini@redhat.com>
parents:
13471
diff
changeset
|
54 ASSERT (U_CHR (input, length, 'c') == input + 2); |
5538ea968fcb
unistr/u*-chr: test multibyte sequences
Paolo Bonzini <pbonzini@redhat.com>
parents:
13471
diff
changeset
|
55 ASSERT (U_CHR (input, length, 'd') == input + 1026); |
12666
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
56 |
13473
4ba511abfe7b
unistr/u*-chr: test multibyte sequences more
Paolo Bonzini <pbonzini@redhat.com>
parents:
13472
diff
changeset
|
57 { |
4ba511abfe7b
unistr/u*-chr: test multibyte sequences more
Paolo Bonzini <pbonzini@redhat.com>
parents:
13472
diff
changeset
|
58 UNIT *exp = input + 1026; |
4ba511abfe7b
unistr/u*-chr: test multibyte sequences more
Paolo Bonzini <pbonzini@redhat.com>
parents:
13472
diff
changeset
|
59 UNIT *prev = input + 1; |
4ba511abfe7b
unistr/u*-chr: test multibyte sequences more
Paolo Bonzini <pbonzini@redhat.com>
parents:
13472
diff
changeset
|
60 for (i = 1026; i < size - 2; i += 63) |
4ba511abfe7b
unistr/u*-chr: test multibyte sequences more
Paolo Bonzini <pbonzini@redhat.com>
parents:
13472
diff
changeset
|
61 { |
4ba511abfe7b
unistr/u*-chr: test multibyte sequences more
Paolo Bonzini <pbonzini@redhat.com>
parents:
13472
diff
changeset
|
62 UNIT c[6]; |
4ba511abfe7b
unistr/u*-chr: test multibyte sequences more
Paolo Bonzini <pbonzini@redhat.com>
parents:
13472
diff
changeset
|
63 size_t n; |
4ba511abfe7b
unistr/u*-chr: test multibyte sequences more
Paolo Bonzini <pbonzini@redhat.com>
parents:
13472
diff
changeset
|
64 ucs4_t uc = 'd' | (i - 1026); |
4ba511abfe7b
unistr/u*-chr: test multibyte sequences more
Paolo Bonzini <pbonzini@redhat.com>
parents:
13472
diff
changeset
|
65 if (uc >= 0xd800 && uc <= 0xdfff) |
4ba511abfe7b
unistr/u*-chr: test multibyte sequences more
Paolo Bonzini <pbonzini@redhat.com>
parents:
13472
diff
changeset
|
66 uc |= 0x100000; |
4ba511abfe7b
unistr/u*-chr: test multibyte sequences more
Paolo Bonzini <pbonzini@redhat.com>
parents:
13472
diff
changeset
|
67 n = U_UCTOMB (c, uc, 6); |
4ba511abfe7b
unistr/u*-chr: test multibyte sequences more
Paolo Bonzini <pbonzini@redhat.com>
parents:
13472
diff
changeset
|
68 ASSERT (exp < input + length - 1); |
4ba511abfe7b
unistr/u*-chr: test multibyte sequences more
Paolo Bonzini <pbonzini@redhat.com>
parents:
13472
diff
changeset
|
69 ASSERT (U_CHR (prev, (length - 1) - (prev - input), uc) == exp); |
4ba511abfe7b
unistr/u*-chr: test multibyte sequences more
Paolo Bonzini <pbonzini@redhat.com>
parents:
13472
diff
changeset
|
70 ASSERT (memcmp (exp, c, n * sizeof (UNIT)) == 0); |
4ba511abfe7b
unistr/u*-chr: test multibyte sequences more
Paolo Bonzini <pbonzini@redhat.com>
parents:
13472
diff
changeset
|
71 prev = exp; |
4ba511abfe7b
unistr/u*-chr: test multibyte sequences more
Paolo Bonzini <pbonzini@redhat.com>
parents:
13472
diff
changeset
|
72 exp += n * 63; |
4ba511abfe7b
unistr/u*-chr: test multibyte sequences more
Paolo Bonzini <pbonzini@redhat.com>
parents:
13472
diff
changeset
|
73 } |
4ba511abfe7b
unistr/u*-chr: test multibyte sequences more
Paolo Bonzini <pbonzini@redhat.com>
parents:
13472
diff
changeset
|
74 } |
4ba511abfe7b
unistr/u*-chr: test multibyte sequences more
Paolo Bonzini <pbonzini@redhat.com>
parents:
13472
diff
changeset
|
75 |
13472
5538ea968fcb
unistr/u*-chr: test multibyte sequences
Paolo Bonzini <pbonzini@redhat.com>
parents:
13471
diff
changeset
|
76 ASSERT (U_CHR (input + 1, length - 1, 'a') == input + length - 1); |
5538ea968fcb
unistr/u*-chr: test multibyte sequences
Paolo Bonzini <pbonzini@redhat.com>
parents:
13471
diff
changeset
|
77 ASSERT (U_CHR (input + 1, length - 1, 'e') == input + length - 2); |
12666
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
78 |
13472
5538ea968fcb
unistr/u*-chr: test multibyte sequences
Paolo Bonzini <pbonzini@redhat.com>
parents:
13471
diff
changeset
|
79 ASSERT (U_CHR (input, length, 'f') == NULL); |
5538ea968fcb
unistr/u*-chr: test multibyte sequences
Paolo Bonzini <pbonzini@redhat.com>
parents:
13471
diff
changeset
|
80 ASSERT (U_CHR (input, length, '\0') == NULL); |
12666
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
81 |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
82 /* Check that a very long haystack is handled quickly if the byte is |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
83 found near the beginning. */ |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
84 { |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
85 size_t repeat = 10000; |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
86 for (; repeat > 0; repeat--) |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
87 { |
13472
5538ea968fcb
unistr/u*-chr: test multibyte sequences
Paolo Bonzini <pbonzini@redhat.com>
parents:
13471
diff
changeset
|
88 ASSERT (U_CHR (input, length, 'c') == input + 2); |
12666
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
89 } |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
90 } |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
91 |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
92 /* Alignment tests. */ |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
93 { |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
94 int i, j; |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
95 for (i = 0; i < 32; i++) |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
96 { |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
97 for (j = 0; j < 128; j++) |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
98 input[i + j] = j; |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
99 for (j = 0; j < 128; j++) |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
100 { |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
101 ASSERT (U_CHR (input + i, 128, j) == input + i + j); |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
102 } |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
103 } |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
104 } |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
105 |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
106 /* Check that uN_chr() does not read past the first occurrence of the |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
107 byte being searched. */ |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
108 { |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
109 char *page_boundary = (char *) zerosize_ptr (); |
13473
4ba511abfe7b
unistr/u*-chr: test multibyte sequences more
Paolo Bonzini <pbonzini@redhat.com>
parents:
13472
diff
changeset
|
110 size_t n; |
12666
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
111 |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
112 if (page_boundary != NULL) |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
113 { |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
114 for (n = 1; n <= 500 / sizeof (UNIT); n++) |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
115 { |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
116 UNIT *mem = (UNIT *) (page_boundary - n * sizeof (UNIT)); |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
117 U_SET (mem, 'X', n); |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
118 ASSERT (U_CHR (mem, n, 'U') == NULL); |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
119 |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
120 { |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
121 size_t i; |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
122 |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
123 for (i = 0; i < n; i++) |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
124 { |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
125 mem[i] = 'U'; |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
126 ASSERT (U_CHR (mem, 4000, 'U') == mem + i); |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
127 mem[i] = 'X'; |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
128 } |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
129 } |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
130 } |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
131 } |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
132 } |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
133 |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
134 free (input); |
40224
5d9b82ca550a
tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents:
40057
diff
changeset
|
135 if (sizeof (UNIT) != sizeof (uint32_t)) |
5d9b82ca550a
tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents:
40057
diff
changeset
|
136 free (input32); |
12666
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
137 |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
138 return 0; |
d7d641a49b10
Tests for module 'unistr/u8-chr'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
139 } |