1 /* Test of type-safe arrays that grow dynamically.
2 Copyright (C) 2021 Free Software Foundation, Inc.
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)
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.
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/>. */
17 /* Written by Bruno Haible <bruno@clisp.org>, 2021. */
21 #define DYNARRAY_STRUCT int_sequence
22 #define DYNARRAY_ELEMENT int
23 #define DYNARRAY_PREFIX intseq_
31 value_at (long long int i)
33 return (i % 13) + ((i * i) % 251);
39 struct int_sequence s;
43 for (i = 0; i < N; i++)
44 intseq_add (&s, value_at (i));
45 for (i = N - 1; i >= N / 2; i--)
47 ASSERT (* intseq_at (&s, i) == value_at (i));
48 intseq_remove_last (&s);