Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • main
  • master
2 results

Target

Select target project
  • c19028886/tp-3-rayane-chorfi
  • s21226517/image-template
  • s23026062/image-sahin
  • t21233923/image-template
  • z23012739/image-template
  • a23026569/image-template-amroun-said
  • boukenze.b/image-template-tp-4
  • l3_s3_infoamu/s3/programmation-2/tp-4-manipulation-dimages
  • c22029830/image-template-rafi
  • m22023183/image-template
  • l3_s3_infoamu/s3/programmation-2/image-template
  • a19029459/image-template
  • a19021078/image-template
  • b23003912/image-template-tp-4-baron-law-yoann
  • alaboure/image-template
  • saddem.r/image-template
  • b21229750/image-template-tp-4
17 results
Select Git revision
  • main
  • master
2 results
Show changes
This diff is collapsed.
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.*;
public class ByteGrayColorTest {
@Test
@Disabled
public void testGetLuminosity_whenColorCreatedWithGrayLevel(){
ByteGrayColor black = new ByteGrayColor(0);
ByteGrayColor white = new ByteGrayColor(255);
assertThat(black.getLuminosity()).isCloseTo(0., within(.01));
assertThat(white.getLuminosity()).isCloseTo(1., within(.01));
}
@Test
@Disabled
public void testGetLuminosity_whenColorCreatedWithLuminosity(){
ByteGrayColor color1 = new ByteGrayColor(.25);
ByteGrayColor color2 = new ByteGrayColor(.75);
assertThat(color1.getLuminosity()).isCloseTo(.25, within(.01));
assertThat(color2.getLuminosity()).isCloseTo(.75, within(.01));
}
@Test
@Disabled
public void testCompareTo_whenColorsCreatedWithGrayLevel(){
ByteGrayColor color1 = new ByteGrayColor(100);
ByteGrayColor color2 = new ByteGrayColor(150);
ByteGrayColor color3 = new ByteGrayColor(200);
ByteGrayColor sameGrayLevelAsColor1 = new ByteGrayColor(100);
assertThat(color1.compareTo(color2)).isNegative();
assertThat(color2.compareTo(color3)).isNegative();
assertThat(color1.compareTo(color3)).isNegative();
assertThat(color2.compareTo(color1)).isPositive();
assertThat(color1.compareTo(sameGrayLevelAsColor1)).isZero();
assertThat(color1.compareTo(color2)).isEqualTo(sameGrayLevelAsColor1.compareTo(color2));
}
@Test
@Disabled
public void testCompareTo_whenColorsCreatedWithLuminosity(){
ByteGrayColor color1 = new ByteGrayColor(0.20);
ByteGrayColor color2 = new ByteGrayColor(0.60);
ByteGrayColor color3 = new ByteGrayColor(0.80);
ByteGrayColor sameLuminosityAsColor1 = new ByteGrayColor(0.20);
assertThat(color1.compareTo(color2)).isNegative();
assertThat(color2.compareTo(color3)).isNegative();
assertThat(color1.compareTo(color3)).isNegative();
assertThat(color2.compareTo(color1)).isPositive();
assertThat(color1.compareTo(sameLuminosityAsColor1)).isZero();
assertThat(color1.compareTo(color2)).isEqualTo(sameLuminosityAsColor1.compareTo(color2));
}
@Test
@Disabled
public void testCompareTo_whenColorsCreatedWithLuminosityAndGrayLevel(){
ByteGrayColor color1 = new ByteGrayColor(0.);
ByteGrayColor color2 = new ByteGrayColor(150);
ByteGrayColor color3 = new ByteGrayColor(1.);
assertThat(color1.compareTo(color2)).isNegative();
assertThat(color2.compareTo(color3)).isNegative();
assertThat(color1.compareTo(color3)).isNegative();
assertThat(color2.compareTo(color1)).isPositive();
}
}
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.*;
class MatrixGrayImageTest {
@Test
@Disabled
void testGetWidth() {
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
@Disabled
void testGetHeight() {
assertThat(new MatrixGrayImage(0,0).getHeight()).isEqualTo(0);
assertThat(new MatrixGrayImage(10,20).getHeight()).isEqualTo(20);
assertThat(new MatrixGrayImage(400,300).getHeight()).isEqualTo(300);
}
@Test
@Disabled
void testGetPixel_whenPixelHasBeenSet() {
GrayColor grey1 = new ByteGrayColor(0.2);
GrayColor grey2 = new ByteGrayColor(0.8);
MatrixGrayImage image = new MatrixGrayImage(10, 10);
image.setPixel(grey1, 1, 1);
assertThat(image.getPixelGrayColor(1,1)).isEqualTo(grey1);
image.setPixel(grey2, 3, 9);
assertThat(image.getPixelGrayColor(3,9)).isEqualTo(grey2);
}
}
\ No newline at end of file
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import java.io.PrintStream;
public class StandardOutputSandbox implements Runnable {
static String NEW_LINE = System.getProperty("line.separator");
private Runnable runnable;
private OutputStream outputStream;
StandardOutputSandbox(Runnable runnable) {
this.runnable = runnable;
}
public void run(){
outputStream = new ByteArrayOutputStream();
PrintStream printStream = new PrintStream(outputStream);
System.setOut(printStream);
runnable.run();
PrintStream originalOut = System.out;
System.setOut(originalOut);
}
String getProducedOutput() {
return outputStream.toString();
}
}
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
class TestCohort {
private static Cohort cohort = new Cohort("L2 informatique");
@BeforeAll
static void addStudentsToCohort(){
Student paulCalcul = new Student("Paul", "Calcul");
Student pierreKiroul = new Student("Pierre", "Kiroul");
pierreKiroul.addResult("Programmation 2", TestGrade.ten);
pierreKiroul.addResult("Structures discrètes", TestGrade.zero);
paulCalcul.addResult("Programmation 2", TestGrade.ten);
paulCalcul.addResult("Structures discrètes", TestGrade.twenty);
cohort.addStudent(paulCalcul);
cohort.addStudent(pierreKiroul);
}
@Test
void testGetStudents(){
assertEquals(List.of(TestStudent.paulCalcul, TestStudent.pierreKiroul), cohort.getStudents());
}
@Test
void testPrintStudentsResults() {
StandardOutputSandbox standardOutputSandbox = new StandardOutputSandbox(() ->cohort.printStudentsResults());
String expectedOutput = "L2 informatique" + StandardOutputSandbox.NEW_LINE + StandardOutputSandbox.NEW_LINE
+ "Paul Calcul" + StandardOutputSandbox.NEW_LINE
+ "Programmation 2 : 10.0/20" + StandardOutputSandbox.NEW_LINE
+ "Structures discrètes : 20.0/20" + StandardOutputSandbox.NEW_LINE
+ "Note moyenne : 15.0/20" + StandardOutputSandbox.NEW_LINE + StandardOutputSandbox.NEW_LINE
+ "Pierre Kiroul" + StandardOutputSandbox.NEW_LINE
+ "Programmation 2 : 10.0/20" + StandardOutputSandbox.NEW_LINE
+ "Structures discrètes : 0.0/20" + StandardOutputSandbox.NEW_LINE
+ "Note moyenne : 5.0/20" + StandardOutputSandbox.NEW_LINE + StandardOutputSandbox.NEW_LINE;
standardOutputSandbox.run();
assertEquals(expectedOutput, standardOutputSandbox.getProducedOutput());
}
}
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import org.junit.jupiter.api.Test;
import java.util.List;
class TestGrade {
static Grade twenty = new Grade(20);
static Grade zero = new Grade(0);
static Grade ten = new Grade(10);
private static List<Grade> grades = List.of(zero, twenty, ten);
private static List<Grade> gradesZero = List.of(zero, zero);
@Test
void testGetValue() {
assertEquals(20, twenty.getValue());
assertEquals(0, zero.getValue());
}
@Test
void testToString() {
assertEquals("20.0/20", twenty.toString());
assertEquals("0.0/20", zero.toString());
}
@Test
void testAverageGrade(){
assertEquals(ten, Grade.averageGrade(grades));
assertEquals(zero, Grade.averageGrade(gradesZero));
}
}
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.util.List;
class TestStudent {
private static Student arnaudLabourel = new Student("Arnaud", "Labourel");
static Student paulCalcul = new Student("Paul", "Calcul");
static Student pierreKiroul = new Student("Pierre", "Kiroul");
@BeforeAll
static void addResultsToStudents(){
arnaudLabourel.addResult("Programmation 2", TestGrade.twenty);
arnaudLabourel.addResult("Structures discrètes", TestGrade.twenty);
pierreKiroul.addResult("Programmation 2", TestGrade.ten);
pierreKiroul.addResult("Structures discrètes", TestGrade.zero);
paulCalcul.addResult("Programmation 2", TestGrade.ten);
paulCalcul.addResult("Structures discrètes", TestGrade.twenty);
}
@Test
void testToString() {
assertEquals("Paul Calcul", paulCalcul.toString());
assertEquals("Pierre Kiroul", pierreKiroul.toString());
}
@Test
void testGetGrades() {
assertEquals(List.of(TestGrade.twenty, TestGrade.twenty), arnaudLabourel.getGrades());
assertEquals(List.of(TestGrade.ten, TestGrade.zero), pierreKiroul.getGrades());
assertEquals(List.of(TestGrade.ten, TestGrade.twenty), paulCalcul.getGrades());
}
@Test
void testGetAverageGrade() {
assertEquals(TestGrade.twenty, arnaudLabourel.averageGrade());
assertEquals(new Grade(5), pierreKiroul.averageGrade());
assertEquals(new Grade(15), paulCalcul.averageGrade());
}
@Test
void testPrintResults() {
StandardOutputSandbox standardOutputSandbox = new StandardOutputSandbox(() ->arnaudLabourel.printResults());
String expectedOutput =
"Arnaud Labourel" + StandardOutputSandbox.NEW_LINE
+ "Programmation 2 : 20.0/20" + StandardOutputSandbox.NEW_LINE
+ "Structures discrètes : 20.0/20" + StandardOutputSandbox.NEW_LINE
+ "Note moyenne : 20.0/20" + StandardOutputSandbox.NEW_LINE;
standardOutputSandbox.run();
assertEquals(expectedOutput, standardOutputSandbox.getProducedOutput());
}
}
\ No newline at end of file
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
class TestTeachingUnitResult {
private static TeachingUnitResult twentyAtProg =
new TeachingUnitResult("Programmation 2", TestGrade.twenty);
private static TeachingUnitResult zeroAtStructDiscrete =
new TeachingUnitResult("Structures discrètes", TestGrade.zero);
@Test
void testGetGrade() {
assertEquals(TestGrade.twenty, twentyAtProg.getGrade());
assertEquals(TestGrade.zero, zeroAtStructDiscrete.getGrade());
}
@Test
void testToString() {
assertEquals("Programmation 2 : 20.0/20", twentyAtProg.toString());
assertEquals("Structures discrètes : 0.0/20", zeroAtStructDiscrete.toString());
}
}