Mercurial > gnulib
annotate tests/unistr/test-cpy.h @ 40057:b06060465f09
maint: Run 'make update-copyright'
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Tue, 01 Jan 2019 00:25:11 +0100 |
parents | 10eb9086bea0 |
children |
rev | line source |
---|---|
12651
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
1 /* Test of uN_cpy() functions. |
40057
b06060465f09
maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents:
19484
diff
changeset
|
2 Copyright (C) 2010-2019 Free Software Foundation, Inc. |
12651
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3 |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
4 This program is free software: you can redistribute it and/or modify |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
5 it under the terms of the GNU General Public License as published by |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
6 the Free Software Foundation; either version 3 of the License, or |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
7 (at your option) any later version. |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
8 |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
9 This program is distributed in the hope that it will be useful, |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
12 GNU General Public License for more details. |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
13 |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
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/>. */ |
12651
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
16 |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
17 /* Written by Bruno Haible <bruno@clisp.org>, 2010. */ |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
18 |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
19 int |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
20 main () |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
21 { |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
22 /* Test small copying operations. */ |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
23 { |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
24 static const UNIT src[] = { 'c', 'l', 'i', 'm', 'a', 't', 'e' }; |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
25 size_t n; |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
26 |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
27 for (n = 0; n <= SIZEOF (src); n++) |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
28 { |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
29 UNIT dest[1 + SIZEOF (src) + 1] = |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
30 { MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC }; |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
31 UNIT *ret; |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
32 size_t i; |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
33 |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
34 ret = U_CPY (dest + 1, src, n); |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
35 ASSERT (ret == dest + 1); |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
36 ASSERT (dest[0] == MAGIC); |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
37 for (i = 0; i < n; i++) |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
38 ASSERT (dest[1 + i] == src[i]); |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
39 ASSERT (dest[1 + n] == MAGIC); |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
40 } |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
41 } |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
42 |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
43 return 0; |
3d09c52b3dd5
Tests for module 'unistr/u8-cpy'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
44 } |