GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
Line | Branch | Exec | Source |
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 |
#include <teem/nrrd.h> |
||
25 |
#include <teem/ell.h> /* nrrd doesn't depend on ell but the tests don't need |
||
26 |
to be constrained by the same dependency order; |
||
27 |
included here for the macros */ |
||
28 |
|||
29 |
/* |
||
30 |
** Tests: |
||
31 |
** NRRD_COORD_UPDATE, NRRD_COORD_INCR, NRRD_INDEX_GEN, NRRD_COORD_GEN |
||
32 |
*/ |
||
33 |
|||
34 |
int |
||
35 |
main() { |
||
36 |
2 |
size_t II, *coord0, *ctmp0, *size0, |
|
37 |
coord1[1], ctmp1[1], size1[1], |
||
38 |
coord2[2], ctmp2[2], size2[2], |
||
39 |
coord3[3], ctmp3[3], size3[3], |
||
40 |
coord4[4], ctmp4[4], size4[4]; |
||
41 |
1 |
char sbuff[NRRD_DIM_MAX*AIR_STRLEN_SMALL], |
|
42 |
scomp[NRRD_DIM_MAX*AIR_STRLEN_SMALL], |
||
43 |
sigab[NRRD_DIM_MAX*AIR_STRLEN_SMALL], /* index gen and back */ |
||
44 |
swhat[NRRD_DIM_MAX*AIR_STRLEN_SMALL]; |
||
45 |
unsigned int ii, jj, kk, ll; |
||
46 |
|||
47 |
/* This macro makes sure the given length-N coord##N vector is what it |
||
48 |
should be ("want"), via string comparison after the output of |
||
49 |
airSprintVecSize_t. Also uses NRRD_INDEX_GEN and NRRD_COORD_GEN |
||
50 |
to go from coord##N to a linear index II and back to ctmp##N, |
||
51 |
and makes sure that that too matches "want" */ |
||
52 |
#define CHECK(N, want) \ |
||
53 |
airSprintVecSize_t(swhat, size##N, N); \ |
||
54 |
airSprintVecSize_t(sbuff, coord##N, N); \ |
||
55 |
if (strcmp(sbuff, want)) { \ |
||
56 |
fprintf(stderr, "for %s: got %s but wanted %s\n", \ |
||
57 |
swhat, sbuff, want); \ |
||
58 |
return 1; \ |
||
59 |
} \ |
||
60 |
NRRD_INDEX_GEN(II, coord##N, size##N, N); \ |
||
61 |
NRRD_COORD_GEN(ctmp##N, size##N, N, II); \ |
||
62 |
airSprintVecSize_t(sigab, ctmp##N, N); \ |
||
63 |
if (strcmp(sbuff, want)) { \ |
||
64 |
fprintf(stderr, "for %s: NRRD_{INDEX,COORD}_GEN gave %s but want %s\n", \ |
||
65 |
swhat, sbuff, want); \ |
||
66 |
return 1; \ |
||
67 |
} |
||
68 |
|||
69 |
|||
70 |
/* actually airTime will always be positive; this is just to thwart the |
||
71 |
compiler thinking coord0 and size0 are necessarily NULL */ |
||
72 |
✓✗ | 1 |
if (airTime() > -100) { |
73 |
coord0 = NULL; |
||
74 |
ctmp0 = NULL; |
||
75 |
size0 = NULL; |
||
76 |
1 |
} else { |
|
77 |
coord0 = coord1; |
||
78 |
ctmp0 = ctmp1; |
||
79 |
size0 = size1; |
||
80 |
} |
||
81 |
|||
82 |
/* http://teem.svn.sourceforge.net/viewvc/teem/teem/trunk/src/nrrd/nrrdMacros.h?r1=3931&r2=4587 |
||
83 |
BUG: previous version causes array subscript is below array bounds. */ |
||
84 |
|||
85 |
/* 00000000000000000000000000000000000000000000000 */ |
||
86 |
/* using coord0 == size0 == NULL here is to make sure that its not even |
||
87 |
accessed */ |
||
88 |
✗✓✗✗ |
2 |
NRRD_COORD_UPDATE(coord0, size0, 0); |
89 |
✗✓✗✓ ✗✓✗✓ |
6 |
CHECK(0, "[]"); |
90 |
|||
91 |
/* 11111111111111111111111111111111111111111111111 */ |
||
92 |
|||
93 |
#define RUN1 \ |
||
94 |
coord1[0] = 0; \ |
||
95 |
for (ii=0; ii<size1[0]; ii++) { \ |
||
96 |
if (ii) { \ |
||
97 |
/* don't increment on the very first time, otherwise do */ \ |
||
98 |
NRRD_COORD_INCR(coord1, size1, 1, 0); \ |
||
99 |
} \ |
||
100 |
airSprintVecSize_t(sbuff, coord1, 1); \ |
||
101 |
sprintf(scomp, "[%u]", ii); \ |
||
102 |
CHECK(1, scomp); \ |
||
103 |
} \ |
||
104 |
|||
105 |
1 |
size1[0] = 1; |
|
106 |
✓✓✗✓ ✗✗✗✗ ✗✓✓✓ ✓✓✗✓ |
15 |
RUN1; |
107 |
|||
108 |
1 |
size1[0] = 10; |
|
109 |
✓✓✓✓ ✗✓✗✗ ✗✓✓✓ ✓✓✗✓ |
159 |
RUN1; |
110 |
|||
111 |
/* 22222222222222222222222222222222222222222222222 */ |
||
112 |
|||
113 |
#define RUN2 \ |
||
114 |
coord2[0] = coord2[1] = 0; \ |
||
115 |
for (jj=0; jj<size2[1]; jj++) { \ |
||
116 |
for (ii=0; ii<size2[0]; ii++) { \ |
||
117 |
if (ii || jj) { \ |
||
118 |
/* don't increment on the very first time, otherwise do */ \ |
||
119 |
NRRD_COORD_INCR(coord2, size2, 2, 0); \ |
||
120 |
} \ |
||
121 |
airSprintVecSize_t(sbuff, coord2, 2); \ |
||
122 |
sprintf(scomp, "[%u,%u]", ii, jj); \ |
||
123 |
CHECK(2, scomp); \ |
||
124 |
} \ |
||
125 |
} |
||
126 |
|||
127 |
1 |
ELL_2V_SET(size2, 1, 1); |
|
128 |
✓✓✓✓ ✗✓✗✗ ✗✗✗✗ ✗✓✓✓ ✓✓✗✓ |
23 |
RUN2; |
129 |
|||
130 |
1 |
ELL_2V_SET(size2, 1, 20); |
|
131 |
✓✓✓✓ ✓✓✓✓ ✓✗✓✓ ✗✓✓✓ ✓✓✗✓ |
574 |
RUN2; |
132 |
|||
133 |
1 |
ELL_2V_SET(size2, 20, 1); |
|
134 |
✓✓✓✓ ✓✓✓✗ ✗✓✗✓ ✗✓✓✓ ✓✓✗✓ |
460 |
RUN2; |
135 |
|||
136 |
1 |
ELL_2V_SET(size2, 20, 20); |
|
137 |
✓✓✓✓ ✓✓✓✓ ✓✓✓✓ ✗✓✓✓ ✓✓✗✓ |
9314 |
RUN2; |
138 |
|||
139 |
/* 33333333333333333333333333333333333333333333333 */ |
||
140 |
|||
141 |
#define RUN3 \ |
||
142 |
coord3[0] = coord3[1] = coord3[2] = 0; \ |
||
143 |
for (kk=0; kk<size3[2]; kk++) { \ |
||
144 |
for (jj=0; jj<size3[1]; jj++) { \ |
||
145 |
for (ii=0; ii<size3[0]; ii++) { \ |
||
146 |
if (ii || jj || kk) { \ |
||
147 |
/* don't increment on the very first time, otherwise do */ \ |
||
148 |
NRRD_COORD_INCR(coord3, size3, 3, 0); \ |
||
149 |
} \ |
||
150 |
airSprintVecSize_t(sbuff, coord3, 3); \ |
||
151 |
sprintf(scomp, "[%u,%u,%u]", ii, jj, kk); \ |
||
152 |
CHECK(3, scomp); \ |
||
153 |
} \ |
||
154 |
} \ |
||
155 |
} |
||
156 |
|||
157 |
1 |
ELL_3V_SET(size3, 1, 1, 1); |
|
158 |
✓✓✓✓ ✓✓✗✓ ✗✗✗✗ ✗✗✗✓ ✓✓✓✓ ✗✓ |
31 |
RUN3; |
159 |
|||
160 |
1 |
ELL_3V_SET(size3, 20, 1, 1); |
|
161 |
✓✓✓✓ ✓✓✓✓ ✓✗✗✓ ✗✓✗✓ ✓✓✓✓ ✗✓ |
544 |
RUN3; |
162 |
|||
163 |
1 |
ELL_3V_SET(size3, 1, 20, 1); |
|
164 |
✓✓✓✓ ✓✓✓✓ ✓✗✓✓ ✗✓✗✓ ✓✓✓✓ ✗✓ |
677 |
RUN3; |
165 |
|||
166 |
1 |
ELL_3V_SET(size3, 1, 1, 20); |
|
167 |
✓✓✓✓ ✓✓✓✓ ✓✓✓✗ ✓✓✗✓ ✓✓✓✓ ✗✓ |
791 |
RUN3; |
168 |
|||
169 |
1 |
ELL_3V_SET(size3, 20, 20, 20); |
|
170 |
✓✓✓✓ ✓✓✓✓ ✓✓✓✓ ✓✓✗✓ ✓✓✓✓ ✗✓ |
218911 |
RUN3; |
171 |
|||
172 |
/* 44444444444444444444444444444444444444444444444 */ |
||
173 |
|||
174 |
#define RUN4 \ |
||
175 |
coord4[0] = coord4[1] = coord4[2] = coord4[3] = 0; \ |
||
176 |
for (ll=0; ll<size4[3]; ll++) { \ |
||
177 |
for (kk=0; kk<size4[2]; kk++) { \ |
||
178 |
for (jj=0; jj<size4[1]; jj++) { \ |
||
179 |
for (ii=0; ii<size4[0]; ii++) { \ |
||
180 |
if (ii || jj || kk || ll) { \ |
||
181 |
/* don't increment on the very first time, otherwise do */ \ |
||
182 |
NRRD_COORD_INCR(coord4, size4, 4, 0); \ |
||
183 |
} \ |
||
184 |
airSprintVecSize_t(sbuff, coord4, 4); \ |
||
185 |
sprintf(scomp, "[%u,%u,%u,%u]", ii, jj, kk, ll); \ |
||
186 |
CHECK(4, scomp); \ |
||
187 |
} \ |
||
188 |
} \ |
||
189 |
} \ |
||
190 |
} |
||
191 |
|||
192 |
1 |
ELL_4V_SET(size4, 1, 1, 1, 1); |
|
193 |
✓✓✓✓ ✓✓✓✓ ✗✓✗✗ ✗✗✗✗ ✗✓✓✓ ✓✓✗✓ |
39 |
RUN4; |
194 |
|||
195 |
1 |
ELL_4V_SET(size4, 20, 1, 1, 1); |
|
196 |
✓✓✓✓ ✓✓✓✓ ✓✓✓✗ ✗✓✗✓ ✗✓✓✓ ✓✓✗✓ |
628 |
RUN4; |
197 |
|||
198 |
1 |
ELL_4V_SET(size4, 1, 20, 1, 1); |
|
199 |
✓✓✓✓ ✓✓✓✓ ✓✓✓✗ ✓✓✗✓ ✗✓✓✓ ✓✓✗✓ |
761 |
RUN4; |
200 |
|||
201 |
1 |
ELL_4V_SET(size4, 1, 1, 20, 1); |
|
202 |
✓✓✓✓ ✓✓✓✓ ✓✓✓✗ ✓✓✗✓ ✗✓✓✓ ✓✓✗✓ |
894 |
RUN4; |
203 |
|||
204 |
1 |
ELL_4V_SET(size4, 1, 1, 1, 20); |
|
205 |
✓✓✓✓ ✓✓✓✓ ✓✓✓✓ ✓✗✓✓ ✗✓✓✓ ✓✓✗✓ |
1008 |
RUN4; |
206 |
|||
207 |
1 |
ELL_4V_SET(size4, 20, 20, 20, 20); |
|
208 |
✓✓✓✓ ✓✓✓✓ ✓✓✓✓ ✓✓✓✓ ✗✓✓✓ ✓✓✗✓ |
5018908 |
RUN4; |
209 |
|||
210 |
1 |
return 0; |
|
211 |
1 |
} |
Generated by: GCOVR (Version 3.3) |