Mercurial > hg > octave-shane > gnulib-hg
annotate tests/test-i-ring.c @ 17593:d1e383af69e2
manywarnings: remove -Wmudflap
* m4/manywarnings.m4 (gl_MANYWARN_ALL_GCC): Remove -Wmudflap, since
it is no longer supported in gcc-4.9-to-be.
author | Jim Meyering <meyering@fb.com> |
---|---|
date | Thu, 02 Jan 2014 16:55:04 -0800 |
parents | 344018b6e5d7 |
children |
rev | line source |
---|---|
9323
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
1 /* Test the simple ring buffer. |
17587 | 2 Copyright (C) 2006-2014 Free Software Foundation, Inc. |
9323
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3 |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
4 This program is free software: you can redistribute it and/or modify |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
5 it under the terms of the GNU General Public License as published by |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
6 the Free Software Foundation; either version 3 of the License, or |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
7 (at your option) any later version. |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
8 |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
9 This program is distributed in the hope that it will be useful, |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
12 GNU General Public License for more details. |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
13 |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
14 You should have received a copy of the GNU General Public License |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
16 |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
17 /* written by Jim Meyering */ |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
18 |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
19 #include <config.h> |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
20 |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
21 #include "i-ring.h" |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
22 |
12496
a48d3d749ca5
Refactor common macros used in tests.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
23 #include "macros.h" |
9323
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
24 |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
25 int |
12197
e45d9bb2233e
tests: avoid several compiler warnings
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
26 main (void) |
9323
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
27 { |
9393
8aa3af4621aa
* tests/test-i-ring.c: Work for C89.
Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
parents:
9323
diff
changeset
|
28 int o; |
9323
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
29 I_ring ir; |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
30 i_ring_init (&ir, -1); |
9393
8aa3af4621aa
* tests/test-i-ring.c: Work for C89.
Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
parents:
9323
diff
changeset
|
31 o = i_ring_push (&ir, 1); |
9323
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
32 ASSERT (o == -1); |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
33 o = i_ring_push (&ir, 2); |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
34 ASSERT (o == -1); |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
35 o = i_ring_push (&ir, 3); |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
36 ASSERT (o == -1); |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
37 o = i_ring_push (&ir, 4); |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
38 ASSERT (o == -1); |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
39 o = i_ring_push (&ir, 5); |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
40 ASSERT (o == 1); |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
41 o = i_ring_push (&ir, 6); |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
42 ASSERT (o == 2); |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
43 o = i_ring_push (&ir, 7); |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
44 ASSERT (o == 3); |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
45 |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
46 o = i_ring_pop (&ir); |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
47 ASSERT (o == 7); |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
48 o = i_ring_pop (&ir); |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
49 ASSERT (o == 6); |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
50 o = i_ring_pop (&ir); |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
51 ASSERT (o == 5); |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
52 o = i_ring_pop (&ir); |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
53 ASSERT (o == 4); |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
54 ASSERT (i_ring_empty (&ir)); |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
55 |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
56 o = i_ring_push (&ir, 8); |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
57 ASSERT (o == -1); |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
58 o = i_ring_pop (&ir); |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
59 ASSERT (o == 8); |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
60 ASSERT (i_ring_empty (&ir)); |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
61 |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
62 return 0; |
1fe2e97a1130
Put unit test for i-ring module into a normal test module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
63 } |