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

changement hamcrest -> assertJ pour les tests

parent e70fd64e
Branches
No related tags found
No related merge requests found
......@@ -13,9 +13,9 @@ repositories {
}
dependencies {
testImplementation('org.junit.jupiter:junit-jupiter-api:5.7.2',
'org.hamcrest:hamcrest-library:2.2', 'net.obvj:junit-utils:1.3.1')
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.2'
testImplementation('org.junit.jupiter:junit-jupiter-api:5.8.1',
'org.assertj:assertj-core:3.21.0')
testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.8.1')
}
test {
......
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.assertj.core.api.Assertions.*;
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)));
assertThat(black.getLuminosity()).isCloseTo(0., within(.01));
assertThat(white.getLuminosity()).isCloseTo(1., within(.01));
}
@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)));
assertThat(color1.getLuminosity()).isCloseTo(.25, within(.01));
assertThat(color2.getLuminosity()).isCloseTo(.75, within(.01));
}
}
\ No newline at end of file
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.assertj.core.api.Assertions.*;
class MatrixGrayImageTest {
@Test
void 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)));
assertThat(new MatrixGrayImage(0,0).getWidth()).isEqualTo(0);
assertThat(new MatrixGrayImage(10,20).getWidth()).isEqualTo(10);
assertThat(new MatrixGrayImage(400,300).getWidth()).isEqualTo(400);
}
@Test
void 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)));
assertThat(new MatrixGrayImage(0,0).getHeight()).isEqualTo(0);
assertThat(new MatrixGrayImage(10,20).getHeight()).isEqualTo(20);
assertThat(new MatrixGrayImage(400,300).getHeight()).isEqualTo(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