Skip to content

Commit 65b9bb5

Browse files
committed
Create regression tests
1 parent b5b2822 commit 65b9bb5

File tree

2 files changed

+136
-0
lines changed

2 files changed

+136
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* #%L
3+
* ImageJ software for multidimensional image processing and analysis.
4+
* %%
5+
* Copyright (C) 2014 - 2018 ImageJ developers.
6+
* %%
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
9+
*
10+
* 1. Redistributions of source code must retain the above copyright notice,
11+
* this list of conditions and the following disclaimer.
12+
* 2. Redistributions in binary form must reproduce the above copyright notice,
13+
* this list of conditions and the following disclaimer in the documentation
14+
* and/or other materials provided with the distribution.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
20+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
* POSSIBILITY OF SUCH DAMAGE.
27+
* #L%
28+
*/
29+
30+
package net.imagej.ops.filter.sharpen;
31+
32+
import java.util.stream.IntStream;
33+
34+
import net.imagej.ops.AbstractOpTest;
35+
import net.imglib2.img.Img;
36+
import net.imglib2.img.array.ArrayImgs;
37+
import net.imglib2.type.numeric.integer.IntType;
38+
39+
import org.junit.Test;
40+
41+
/**
42+
* Tests {@link DefaultSharpen}.
43+
*
44+
* @author Gabe Selzer
45+
*/
46+
public class SharpenTest extends AbstractOpTest {
47+
48+
@Test
49+
public void testRegression() {
50+
int[] range = IntStream.rangeClosed(0, 24).toArray();
51+
int[] regressionData = { -9, -6, -5, -4, -2, 4, 7, 8, 9, 11, 9, 12, 13, 14,
52+
16, 14, 17, 18, 19, 21, 27, 29, 30, 31, 34 };
53+
Img<IntType> img = ArrayImgs.ints(range, 5, 5);
54+
55+
Img<IntType> actual = (Img<IntType>) ops.filter().sharpen(img);
56+
Img<IntType> expected = ArrayImgs.ints(regressionData, 5l, 5l);
57+
58+
assertIterationsEqual(expected, actual);
59+
}
60+
61+
@Test (expected = NegativeArraySizeException.class)
62+
public void testTooFewDimensions() {
63+
int[] range = IntStream.rangeClosed(1, 7).toArray();
64+
Img<IntType> img = ArrayImgs.ints(range, 7);
65+
66+
Img<IntType> output = (Img<IntType>) ops.filter().sharpen(img);
67+
}
68+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* #%L
3+
* ImageJ software for multidimensional image processing and analysis.
4+
* %%
5+
* Copyright (C) 2014 - 2018 ImageJ developers.
6+
* %%
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
9+
*
10+
* 1. Redistributions of source code must retain the above copyright notice,
11+
* this list of conditions and the following disclaimer.
12+
* 2. Redistributions in binary form must reproduce the above copyright notice,
13+
* this list of conditions and the following disclaimer in the documentation
14+
* and/or other materials provided with the distribution.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
20+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
* POSSIBILITY OF SUCH DAMAGE.
27+
* #L%
28+
*/
29+
30+
package net.imagej.ops.filter.smooth;
31+
32+
import java.util.stream.IntStream;
33+
34+
import net.imagej.ops.AbstractOpTest;
35+
import net.imglib2.img.Img;
36+
import net.imglib2.img.array.ArrayImgs;
37+
import net.imglib2.type.numeric.integer.IntType;
38+
39+
import org.junit.Test;
40+
41+
/**
42+
* Tests {@link DefaultSmooth}.
43+
*
44+
* @author Gabe Selzer
45+
*/
46+
public class SmoothTest extends AbstractOpTest {
47+
48+
@Test
49+
public void testRegression() {
50+
int[] range = IntStream.rangeClosed(0, 24).toArray();
51+
int[] regressionData = { 5, 5, 6, 7, 7, 6, 7, 8, 9, 9, 11, 12, 13, 14, 14,
52+
16, 17, 18, 19, 19, 18, 18, 19, 20, 21 };
53+
Img<IntType> img = ArrayImgs.ints(range, 5, 5);
54+
55+
Img<IntType> actual = (Img<IntType>) ops.filter().smooth(img);
56+
Img<IntType> expected = ArrayImgs.ints(regressionData, 5l, 5l);
57+
58+
assertIterationsEqual(expected, actual);
59+
}
60+
61+
@Test(expected = NegativeArraySizeException.class)
62+
public void testTooFewDimensions() {
63+
int[] range = IntStream.rangeClosed(1, 7).toArray();
64+
Img<IntType> img = ArrayImgs.ints(range, 7);
65+
66+
Img<IntType> output = (Img<IntType>) ops.filter().smooth(img);
67+
}
68+
}

0 commit comments

Comments
 (0)