Last change
on this file since 3613 was 3611, checked in by bird, 7 months ago |
vendor/sed/current: GNU sed 4.9 (sed-4.9.tar.xz sha256:6e226b732e1cd739464ad6862bd1a1aba42d7982922da7a53519631d24975181)
|
File size:
1.3 KB
|
Line | |
---|
1 | /* Test of type-safe arrays that grow dynamically.
|
---|
2 | Copyright (C) 2021-2022 Free Software Foundation, Inc.
|
---|
3 |
|
---|
4 | This program is free software; you can redistribute it and/or modify
|
---|
5 | it under the terms of the GNU General Public License as published by
|
---|
6 | the Free Software Foundation; either version 2, or (at your option)
|
---|
7 | any later version.
|
---|
8 |
|
---|
9 | This program is distributed in the hope that it will be useful,
|
---|
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
12 | GNU General Public License for more details.
|
---|
13 |
|
---|
14 | You should have received a copy of the GNU General Public License
|
---|
15 | along with this program; if not, see <https://www.gnu.org/licenses/>. */
|
---|
16 |
|
---|
17 | /* Written by Bruno Haible <[email protected]>, 2021. */
|
---|
18 |
|
---|
19 | #include <config.h>
|
---|
20 |
|
---|
21 | #define DYNARRAY_STRUCT int_sequence
|
---|
22 | #define DYNARRAY_ELEMENT int
|
---|
23 | #define DYNARRAY_PREFIX intseq_
|
---|
24 | #include "dynarray.h"
|
---|
25 |
|
---|
26 | #include "macros.h"
|
---|
27 |
|
---|
28 | #define N 100000
|
---|
29 |
|
---|
30 | static int
|
---|
31 | value_at (long long int i)
|
---|
32 | {
|
---|
33 | return (i % 13) + ((i * i) % 251);
|
---|
34 | }
|
---|
35 |
|
---|
36 | int
|
---|
37 | main ()
|
---|
38 | {
|
---|
39 | struct int_sequence s;
|
---|
40 | int i;
|
---|
41 |
|
---|
42 | intseq_init (&s);
|
---|
43 | for (i = 0; i < N; i++)
|
---|
44 | intseq_add (&s, value_at (i));
|
---|
45 | for (i = N - 1; i >= N / 2; i--)
|
---|
46 | {
|
---|
47 | ASSERT (* intseq_at (&s, i) == value_at (i));
|
---|
48 | intseq_remove_last (&s);
|
---|
49 | }
|
---|
50 | intseq_free (&s);
|
---|
51 |
|
---|
52 | return 0;
|
---|
53 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.