diff --git a/src/test/java/ByteGrayColorTest.java b/src/test/java/ByteGrayColorTest.java new file mode 100644 index 0000000000000000000000000000000000000000..37039a566eb5218893ea69070f1eeec99619bf4d --- /dev/null +++ b/src/test/java/ByteGrayColorTest.java @@ -0,0 +1,22 @@ +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; + +public class ByteGrayColorTest { + @Test + public void testGetLuminosity_whenColorCreatedWithGrayLevel(){ + ByteGrayColor black = new ByteGrayColor(0); + ByteGrayColor white = new ByteGrayColor(255); + assertThat(black.getLuminosity(), is(closeTo(0.,.0001))); + assertThat(white.getLuminosity(), is(closeTo(1.,.0001))); + } + + @Test + public void testGetLuminosity_whenColorCreatedWithLuminosity(){ + ByteGrayColor color1 = new ByteGrayColor(.25); + ByteGrayColor color2 = new ByteGrayColor(.75); + assertThat(color1.getLuminosity(), is(closeTo(.25,.0001))); + assertThat(color2.getLuminosity(), is(closeTo(.75,.0001))); + } +} diff --git a/src/test/java/MatrixGrayImageTest.java b/src/test/java/MatrixGrayImageTest.java index f44a46125b187f81d145ce46bd99cda1c528febd..0aaa7f8958ffbe5249d8c3d3a62441ddb016eaa5 100644 --- a/src/test/java/MatrixGrayImageTest.java +++ b/src/test/java/MatrixGrayImageTest.java @@ -1,20 +1,22 @@ import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; + class MatrixGrayImageTest { @Test void getWidth() { - assertEquals(0, new MatrixGrayImage(0,0).getWidth()); - assertEquals(10, new MatrixGrayImage(10,20).getWidth()); - assertEquals(400, new MatrixGrayImage(400,300).getWidth()); + assertThat(new MatrixGrayImage(0,0).getWidth(), is(equalTo(0))); + assertThat(new MatrixGrayImage(10,20).getWidth(), is(equalTo(10))); + assertThat(new MatrixGrayImage(400,300).getWidth(), is(equalTo(400))); } @Test void getHeight() { - assertEquals(0, new MatrixGrayImage(0,0).getHeight()); - assertEquals(20, new MatrixGrayImage(10,20).getHeight()); - assertEquals(300, new MatrixGrayImage(400,300).getHeight()); + assertThat(new MatrixGrayImage(0,0).getWidth(), is(equalTo(0))); + assertThat(new MatrixGrayImage(10,20).getWidth(), is(equalTo(20))); + assertThat(new MatrixGrayImage(400,300).getWidth(), is(equalTo(300))); } } \ No newline at end of file