Skip to content
Snippets Groups Projects
Commit 34d2d5d4 authored by Justin's avatar Justin
Browse files

Made coding style more uniform

parent 445ad987
No related branches found
No related tags found
No related merge requests found
......@@ -4,15 +4,13 @@ import static org.junit.Assert.*;
import java.io.File;
import java.io.IOException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class JunitTest {
public class NonogramTest {
private int Height1=8;
private static final int HEIGHT1=8;
private int Width1=8;
private static final int WIDTH1=8;
private boolean [][] testImageData1 ={
{false,false,true,true,true,true,false,false},
......@@ -25,9 +23,9 @@ public class JunitTest {
{false,false,true,true,true,true,false,false},
};
private int Height2=8;
private static final int HEIGHT2=8;
private int Width2=8;
private static final int WIDTH2=8;
private boolean [][] testImageData2 ={
{true,true,true,true,true,true,true,true},
......@@ -40,9 +38,9 @@ public class JunitTest {
{true,true,true,true,true,true,true,true},
};
private int Height3=8;
private static final int HEIGHT3=8;
private int Width3=8;
private static final int WIDTH3=8;
private boolean [][] testImageData3 ={
{false,false,false,true,true,false,false,false},
......@@ -55,87 +53,73 @@ public class JunitTest {
{false,false,false,true,true,false,false,false},
};
@Before
public void setUp() throws Exception {
}
@After
public void tearDown() throws Exception {
}
@Test
public void testNonogram() throws IOException {
Nonogram test= new Nonogram(new File("test.png") );
Nonogram test = new Nonogram(new File("test.png") );
assertEquals(Height1,test.getHeight());
assertEquals(Width1,test.getWidth());
assertEquals(HEIGHT1,test.getHeight());
assertEquals(WIDTH1,test.getWidth());
for (int y = 0; y < test.getHeight(); y++) {
for (int x = 0; x < test.getWidth(); x++) {
assertEquals(test.getPixel(y,x),testImageData1[y][x]);
}
assertEquals(test.getPixel(y, x), testImageData1[y][x]);
}
}
Nonogram test2= new Nonogram(new File("square.png") );
assertEquals(Height2,test2.getHeight());
assertEquals(Width2,test2.getWidth());
assertEquals(HEIGHT2,test2.getHeight());
assertEquals(WIDTH2,test2.getWidth());
for (int y = 0; y < test2.getHeight(); y++) {
for (int x = 0; x < test2.getWidth(); x++) {
assertEquals(test2.getPixel(y,x),testImageData2[y][x]);
}
assertEquals(test2.getPixel(y, x), testImageData2[y][x]);
}
}
Nonogram test3= new Nonogram(new File("cross.png") );
assertEquals(Height3,test3.getHeight());
assertEquals(Width3,test3.getWidth());
assertEquals(HEIGHT3,test3.getHeight());
assertEquals(WIDTH3,test3.getWidth());
for (int y = 0; y < test3.getHeight(); y++) {
for (int x = 0; x < test3.getWidth(); x++) {
assertEquals(test3.getPixel(y,x),testImageData3[y][x]);
}
assertEquals(test3.getPixel(y, x), testImageData3[y][x]);
}
}
Nonogram test4= new Nonogram(new File("test.bmp") );
assertEquals(Height1,test4.getHeight());
assertEquals(Width1,test4.getWidth());
assertEquals(HEIGHT1,test4.getHeight());
assertEquals(WIDTH1,test4.getWidth());
for (int y = 0; y < test4.getHeight(); y++) {
for (int x = 0; x < test4.getWidth(); x++) {
assertEquals(test4.getPixel(y,x),testImageData1[y][x]);
}
assertEquals(test4.getPixel(y, x), testImageData1[y][x]);
}
}
Nonogram test5= new Nonogram(new File("square.bmp") );
assertEquals(Height2,test5.getHeight());
assertEquals(Width2,test5.getWidth());
assertEquals(HEIGHT2,test5.getHeight());
assertEquals(WIDTH2,test5.getWidth());
for (int y = 0; y < test5.getHeight(); y++) {
for (int x = 0; x < test5.getWidth(); x++) {
assertEquals(test5.getPixel(y,x),testImageData2[y][x]);
}
assertEquals(test5.getPixel(y, x), testImageData2[y][x]);
}
}
Nonogram test6= new Nonogram(new File("cross.bmp") );
assertEquals(Height3,test6.getHeight());
assertEquals(Width3,test6.getWidth());
assertEquals(HEIGHT3,test6.getHeight());
assertEquals(WIDTH3,test6.getWidth());
for (int y = 0; y < test6.getHeight(); y++) {
for (int x = 0; x < test6.getWidth(); x++) {
assertEquals(test6.getPixel(y,x),testImageData3[y][x]);
}
assertEquals(test6.getPixel(y, x), testImageData3[y][x]);
}
}
......@@ -144,14 +128,12 @@ public class JunitTest {
@Test(expected=NullPointerException.class)
public void testException() throws IOException {
Nonogram test7= new Nonogram(new File("empty.bmp") );
new Nonogram(new File("empty.bmp") );
}
@Test(expected=IOException.class)
public void testException2() throws IOException {
Nonogram test8= new Nonogram(new File("blue.bmp") );
new Nonogram(new File("blue.bmp") );
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment