Skip to content
Snippets Groups Projects
Commit e70fd64e authored by LABOUREL Arnaud's avatar LABOUREL Arnaud
Browse files

Ajout tests

parent 3dc150fd
No related branches found
No related tags found
No related merge requests found
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)));
}
}
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment