Skip to content

Commit 4fd7698

Browse files
committed
Updated SimpleNoise test to use org.juint.Assert instead of jupiter
1 parent ba90059 commit 4fd7698

File tree

1 file changed

+34
-35
lines changed

1 file changed

+34
-35
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,49 @@
11
package src.test.java.com.generation;
22

3-
import static org.junit.jupiter.api.Assertions.*;
4-
53
import java.awt.Color;
64
import java.awt.image.BufferedImage;
75
import java.io.IOException;
86
import java.io.InputStream;
97

108
import javax.imageio.ImageIO;
119

12-
import org.junit.jupiter.api.Test;
10+
import org.junit.Assert;
11+
import org.junit.Test;
1312

1413
import src.main.java.com.generation.SimplexNoise;
1514

1615
public class SimplexNoiseTest {
1716

18-
@Test
19-
public void testGenerateHeightMap() {
20-
21-
final int WIDTH = 256;
22-
final int HEIGHT = 256;
23-
final int X = 0;
24-
final int Y = 0;
25-
final String RESOURCE_NAME = "src/test/java/com/generation/expected-result.png";
26-
27-
float[][] heightmap = new SimplexNoise(50, 0.3F, 1111111111111111L).generateHeightMap(X, Y, WIDTH, HEIGHT);
28-
BufferedImage image = null;
29-
30-
try(InputStream in = this.getClass().getClassLoader().getResourceAsStream(RESOURCE_NAME)) {
31-
32-
image = ImageIO.read(in);
33-
34-
assertEquals(WIDTH, image.getWidth());
35-
assertEquals(HEIGHT, image.getHeight());
36-
37-
} catch(IOException | IllegalArgumentException exception) {
38-
39-
fail(exception);
40-
}
41-
42-
for(int x = 0; x < WIDTH; x++) {
43-
44-
for(int y = 0; y < HEIGHT; y++) {
45-
46-
assertEquals(new Color(image.getRGB(x, y)).getRed(), (int)(heightmap[x][y] * 255));
47-
}
48-
}
49-
}
17+
@Test
18+
public void testGenerateHeightMap() {
19+
20+
final int WIDTH = 256;
21+
final int HEIGHT = 256;
22+
final int X = 0;
23+
final int Y = 0;
24+
final String RESOURCE_NAME = "src/test/java/com/generation/expected-result.png";
25+
26+
float[][] heightmap = new SimplexNoise(50, 0.3F, 1111111111111111L).generateHeightMap(X, Y, WIDTH, HEIGHT);
27+
BufferedImage image = null;
28+
29+
try (InputStream in = this.getClass().getClassLoader().getResourceAsStream(RESOURCE_NAME)) {
30+
31+
image = ImageIO.read(in);
32+
33+
Assert.assertEquals(WIDTH, image.getWidth());
34+
Assert.assertEquals(HEIGHT, image.getHeight());
35+
36+
} catch (IOException | IllegalArgumentException exception) {
37+
38+
Assert.fail(exception.toString());
39+
}
40+
41+
for (int x = 0; x < WIDTH; x++) {
42+
43+
for (int y = 0; y < HEIGHT; y++) {
44+
45+
Assert.assertEquals(new Color(image.getRGB(x, y)).getRed(), (int) (heightmap[x][y] * 255));
46+
}
47+
}
48+
}
5049
}

0 commit comments

Comments
 (0)