Skip to content

Commit e102430

Browse files
committed
Add test for MapNeighborhoodNativeTypeExtended
Signed-off-by: squareys <[email protected]>
1 parent 8d5cb4d commit e102430

File tree

1 file changed

+55
-7
lines changed

1 file changed

+55
-7
lines changed

src/test/java/net/imagej/ops/map/neighborhood/MapNeighborhoodTest.java

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,29 @@ public void testMapNeighborhoodsArrayImage2D() {
112112
}
113113
}
114114

115+
/**
116+
* Test if every neighborhood pixel of the 2D image was really accessed during
117+
* the map operation.
118+
*
119+
* @see MapNeighborhoodNativeTypeExtended
120+
*/
121+
@Test
122+
public void testMapNeighborhoodsArrayImageAlias2D() {
123+
in = generateByteTestImg(true, 7, 7);
124+
out = generateByteTestImg(false, 7, 7);
125+
126+
final Op functional =
127+
ops.op(MapNeighborhoodNativeTypeExtended.class, out, in,
128+
new CountNeighbors(), new RectangleShape(1, false));
129+
functional.run();
130+
131+
int index = 0;
132+
for (ByteType t : out) {
133+
assertEquals("Index " + index + ": ", 9, t.get());
134+
index++;
135+
}
136+
}
137+
115138
/**
116139
* Test if every neighborhood pixel of the 1D image was really accessed during
117140
* the map operation.
@@ -128,22 +151,22 @@ public void testMapNeighborhoodsArrayImage1D() {
128151
new CountNeighborsWithAccess(), 1);
129152
functional.run();
130153

131-
final byte[] expected =
132-
new byte[] { 2, 3, 3, 3, 3, 3, 2 };
154+
final byte[] expected = new byte[] { 2, 3, 3, 3, 3, 3, 2 };
133155

134156
int index = 0;
135157
for (ByteType t : out) {
136158
assertEquals("Index " + index + ": ", expected[index++], t.get());
137159
}
138160
}
139-
161+
140162
/**
141-
* TODO
163+
* Test if every neighborhood pixel of the 1D image was really accessed during
164+
* the map operation.
142165
*
143166
* @see MapNeighborhoodNativeTypeExtended
144167
*/
145168
@Test
146-
public void testMapNeighborhoodsArrayImageAlias() {
169+
public void testMapNeighborhoodsArrayImageAlias1D() {
147170
in = generateByteTestImg(true, 7);
148171
out = generateByteTestImg(false, 7);
149172

@@ -154,8 +177,8 @@ public void testMapNeighborhoodsArrayImageAlias() {
154177

155178
int index = 0;
156179
for (ByteType t : out) {
157-
assertEquals("Index " + index, 3, t.get());
158-
index ++;
180+
assertEquals("Index " + index + ": ", 3, t.get());
181+
index++;
159182
}
160183
}
161184

@@ -184,6 +207,29 @@ public void testMapNeighborhoodsArrayImage3D() {
184207
assertEquals("Index " + index + ": ", expected[index++], t.get());
185208
}
186209
}
210+
211+
/**
212+
* Test if every neighborhood pixel of the 3D image was really accessed during
213+
* the map operation.
214+
*
215+
* @see MapNeighborhoodNativeTypeExtended
216+
*/
217+
@Test
218+
public void testMapNeighborhoodsArrayImageAlias3D() {
219+
in = generateByteTestImg(true, 7, 7, 7);
220+
out = generateByteTestImg(false, 7, 7, 7);
221+
222+
final Op functional =
223+
ops.op(MapNeighborhoodNativeTypeExtended.class, out, in,
224+
new CountNeighbors(), new RectangleShape(1, false));
225+
functional.run();
226+
227+
int index = 0;
228+
for (ByteType t : out) {
229+
assertEquals("Index " + index + ": ", 27, t.get());
230+
index++;
231+
}
232+
}
187233

188234
/**
189235
* Test if every neighborhood pixel of the 2D image was really accessed during
@@ -210,6 +256,8 @@ public void testMapNeighborhoodsWithCenterAccessArrayImage2D() {
210256
assertEquals("Index " + index + ": ", expected[index++], t.get());
211257
}
212258
}
259+
260+
213261

214262
/**
215263
* Function which increments the output value for every pixel in the

0 commit comments

Comments
 (0)