1 |
|
|
/* |
2 |
|
|
Teem: Tools to process and visualize scientific data and images . |
3 |
|
|
Copyright (C) 2013, 2012, 2011, 2010, 2009 University of Chicago |
4 |
|
|
Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann |
5 |
|
|
Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah |
6 |
|
|
|
7 |
|
|
This library is free software; you can redistribute it and/or |
8 |
|
|
modify it under the terms of the GNU Lesser General Public License |
9 |
|
|
(LGPL) as published by the Free Software Foundation; either |
10 |
|
|
version 2.1 of the License, or (at your option) any later version. |
11 |
|
|
The terms of redistributing and/or modifying this software also |
12 |
|
|
include exceptions to the LGPL that facilitate static linking. |
13 |
|
|
|
14 |
|
|
This library is distributed in the hope that it will be useful, |
15 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
17 |
|
|
Lesser General Public License for more details. |
18 |
|
|
|
19 |
|
|
You should have received a copy of the GNU Lesser General Public License |
20 |
|
|
along with this library; if not, write to Free Software Foundation, Inc., |
21 |
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
22 |
|
|
*/ |
23 |
|
|
|
24 |
|
|
|
25 |
|
|
#include "teem/biff.h" |
26 |
|
|
|
27 |
|
|
/* |
28 |
|
|
** Tests: |
29 |
|
|
** biffAdd |
30 |
|
|
** biffAddf |
31 |
|
|
** biffMove |
32 |
|
|
** biffMovef |
33 |
|
|
** biffGet |
34 |
|
|
** biffDone |
35 |
|
|
** biffGetDone |
36 |
|
|
** |
37 |
|
|
** Also uses: |
38 |
|
|
** airMopNew, airMopAdd, airMopError, airMopDone |
39 |
|
|
*/ |
40 |
|
|
|
41 |
|
|
int |
42 |
|
|
main(int argc, const char *argv[]) { |
43 |
|
|
const char *me; |
44 |
|
|
char *tmp; |
45 |
|
|
airArray *mop; |
46 |
|
|
|
47 |
|
|
AIR_UNUSED(argc); |
48 |
|
2 |
me = argv[0]; |
49 |
|
1 |
mop = airMopNew(); |
50 |
|
|
|
51 |
|
|
/* HEY: the creation and comparison of these strings is not very |
52 |
|
|
flexible, especially the hard-coded "good[]" strings */ |
53 |
|
1 |
biffAdd("axis", "the first error axis"); |
54 |
|
1 |
biffAdd("chard", "the first error chard"); |
55 |
|
1 |
biffAdd("chard", "the second error chard"); |
56 |
|
1 |
biffAdd("axis", "the second error axis"); |
57 |
|
1 |
biffAdd("chard", "the third error chard"); |
58 |
|
1 |
biffAdd("bingo", "zero-eth bingo message"); |
59 |
|
1 |
biffMove("bingo", NULL, "chard"); |
60 |
|
1 |
biffAdd("bingo", "the first error bingo"); |
61 |
|
1 |
biffAdd("bingo", "the second bll boo boo boo error bingo"); |
62 |
|
1 |
biffAdd("bingo", "the third error bingo"); |
63 |
|
1 |
biffAdd("axis", "the third error axis"); |
64 |
|
|
{ |
65 |
|
1 |
char good[] = |
66 |
|
|
"[bingo] the third error bingo\n" |
67 |
|
|
"[bingo] the second bll boo boo boo error bingo\n" |
68 |
|
|
"[bingo] the first error bingo\n" |
69 |
|
|
"[bingo] [chard] the third error chard\n" |
70 |
|
|
"[bingo] [chard] the second error chard\n" |
71 |
|
|
"[bingo] [chard] the first error chard\n" |
72 |
|
|
"[bingo] zero-eth bingo message\n"; |
73 |
|
1 |
tmp = biffGet("bingo"); |
74 |
|
1 |
airMopAdd(mop, tmp, airFree, airMopAlways); |
75 |
|
|
|
76 |
|
|
/* an ugly macro */ |
77 |
|
|
#define COMPARE(N) \ |
78 |
|
|
airMopAdd(mop, tmp, airFree, airMopAlways); \ |
79 |
|
|
if (strcmp(tmp, good)) { \ |
80 |
|
|
fprintf(stderr, "%s: %d: #%s# != #%s#\n", me, N, tmp, good); \ |
81 |
|
|
airMopError(mop); \ |
82 |
|
|
exit(1); \ |
83 |
|
|
} |
84 |
|
|
|
85 |
✗✓ |
1 |
COMPARE(1); |
86 |
|
1 |
} |
87 |
|
|
|
88 |
|
|
{ |
89 |
|
1 |
char good[] = ""; |
90 |
|
1 |
tmp = biffGet("chard"); |
91 |
✗✓ |
1 |
COMPARE(2); |
92 |
|
1 |
} |
93 |
|
|
|
94 |
|
|
{ |
95 |
|
1 |
char good[] = |
96 |
|
|
"[axis] the third error axis\n" |
97 |
|
|
"[axis] the second error axis\n" |
98 |
|
|
"[axis] the first error axis\n"; |
99 |
|
1 |
tmp = biffGet("axis"); |
100 |
✗✓ |
1 |
COMPARE(3); |
101 |
|
1 |
} |
102 |
|
|
|
103 |
|
1 |
biffAdd("harold", "the first error harold"); |
104 |
|
1 |
biffAdd("harold", "the second error harold"); |
105 |
|
1 |
biffAdd("harold", "the third error harold"); |
106 |
|
|
{ |
107 |
|
1 |
char good[] = |
108 |
|
|
"[harold] the third error harold\n" |
109 |
|
|
"[harold] the second error harold\n" |
110 |
|
|
"[harold] the first error harold\n"; |
111 |
|
1 |
tmp = biffGetDone("harold"); |
112 |
✗✓ |
1 |
COMPARE(4); |
113 |
|
1 |
} |
114 |
|
|
|
115 |
|
1 |
biffDone("bingo"); |
116 |
|
1 |
biffDone("axis"); |
117 |
|
1 |
biffDone("chard"); |
118 |
|
|
|
119 |
|
1 |
biffAdd("axis", "the first error axis"); |
120 |
|
1 |
biffAdd("axis", "the second error axis"); |
121 |
|
1 |
biffAdd("axis", "the third error axis"); |
122 |
|
1 |
biffAdd("axis", "the fourth error axis"); |
123 |
|
1 |
biffAdd("axis", "the fifth error axis"); |
124 |
|
|
{ |
125 |
|
1 |
char good[] = |
126 |
|
|
"[axis] the fifth error axis\n" |
127 |
|
|
"[axis] the fourth error axis\n" |
128 |
|
|
"[axis] the third error axis\n" |
129 |
|
|
"[axis] the second error axis\n" |
130 |
|
|
"[axis] the first error axis\n"; |
131 |
|
1 |
tmp = biffGetDone("axis"); |
132 |
✗✓ |
1 |
COMPARE(5); |
133 |
|
1 |
} |
134 |
|
|
|
135 |
|
1 |
biffAddf("test", "%s: this is a test of biffAddf %d %g", "me", 1, 4.2); |
136 |
|
|
{ |
137 |
|
1 |
char good[] = "[test] me: this is a test of biffAddf 1 4.2\n"; |
138 |
|
1 |
tmp = biffGetDone("test"); |
139 |
✗✓ |
1 |
COMPARE(6); |
140 |
|
1 |
} |
141 |
|
|
|
142 |
|
1 |
biffAddf("test2", "%s: this is a test of biffAddf %d %g", "me", 1, 4.2); |
143 |
|
1 |
biffMovef("test3", "test2", "%s: testing biffMove %d.", "me", 1729); |
144 |
|
|
{ |
145 |
|
1 |
char good[] = |
146 |
|
|
"[test3] me: testing biffMove 1729.\n" |
147 |
|
|
"[test3] [test2] me: this is a test of biffAddf 1 4.2\n"; |
148 |
|
1 |
tmp = biffGet("test3"); |
149 |
✗✓ |
1 |
COMPARE(7); |
150 |
|
1 |
} |
151 |
|
|
|
152 |
|
1 |
airMopOkay(mop); |
153 |
|
1 |
exit(0); |
154 |
|
|
} |