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
1 result

Target

Select target project
  • z20026252/M1-INFO-FSI-TP-template
  • alaboure/M1-INFO-FSI-TP-template
  • d23022755/M1-INFO-FSI-TP-template
  • m19025211/m-1-info-fsi-tp-template-mededji
  • b24026857/tp-1-fl
  • a24025370/M1-INFO-FSI-TP-template
6 results
Select Git revision
  • main
1 result
Show changes

Commits on Source 25

Showing
with 458 additions and 27 deletions
File moved
# M1 INFO FSI TP Template
Dépôt à forker pour les TP de fiabilité logicielle en M1 informatique parcours FSI.
\ No newline at end of file
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
.gradle/
.idea/
build/**/
*.iml
*.ipr
*.iws
### IntelliJ IDEA ###
.idea
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store
\ No newline at end of file
# TP 1 : tests boîte noire
# TP 2 : tests unitaires et couverture de test
Les exécutables à tester sont dans le répertoire `executables`.
Les fichiers images correspondant au cas de test sont à mettre dans le répertoire `ìmages`.
Les commandes gradle les plus utiles :
- `gradle test` pour lancer les tests (rapports dans `build/reports/tests/test`),
- `gradle jacocoTestReport` pour lancer la couverture de code via l'outil [Jacoco](https://www.eclemma.org/jacoco/) (rapport accessible en html à `build/reports/jacoco/test/html/index.html`).
Pour lancer les tests, il suffit d'utiliser la commande :
Le fichier `build.gradle` contient la configuration du projet avec notamment la définition de la classe contenant la méthode `main` à exécuter pour l'application.
```bash
gradle run
```
## Membre(s) du projet
- NOM, prénom du premier membre du projet
- NOM, prénom du deuxième membre du projet (optionnel)
plugins {
id("java")
id("jacoco")
}
group = "fr.univ_amu.m1info"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter-api:5.11.4")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.11.4")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testImplementation("org.assertj:assertj-core:3.27.0")
}
tasks.test {
useJUnitPlatform()
}
tasks.test {
finalizedBy(tasks.jacocoTestReport) // report is always generated after tests run
}
tasks.jacocoTestReport {
dependsOn(tasks.test) // tests are required to run before generating the report
}
org.gradle.warning.mode=all
\ No newline at end of file
No preview for this file type
#Tue Dec 05 18:16:17 CET 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
......@@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
......@@ -80,13 +80,13 @@ do
esac
done
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
DEFAULT_JVM_OPTS='-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
......@@ -143,12 +143,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
......@@ -205,6 +209,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
......
rootProject.name = 'blackbox'
rootProject.name = 'tp_1_unit_test_and_coverage'
package complex;
public class Complex {
float realPart = 0;
float imaginaryPart = 0;
private static final float EPSILON = 0.000001F;
public Complex() {
}
public Complex(float a, float b) {
this.realPart = a;
this.imaginaryPart = b;
}
public boolean isZero() {
return ((Math.abs(this.realPart) <= EPSILON) && (Math.abs(this.imaginaryPart) <= EPSILON));
}
public float getRealPart() {
return this.realPart;
}
public float getImaginaryPart() {
return this.imaginaryPart;
}
public void setRealPart(float a) {
this.realPart = a;
}
public void setImaginaryPart(float b) {
this.imaginaryPart = b;
}
public Complex sum(Complex c) {
return new Complex(this.realPart + c.getRealPart(), this.imaginaryPart + c.getImaginaryPart());
}
public Complex product(Complex c) {
// TODO: change code
return new Complex();
}
public Complex inverse() throws IllegalArgumentException {
if (isZero()) throw new IllegalArgumentException();
float square_norm = (this.realPart * this.realPart + this.imaginaryPart * this.imaginaryPart);
return new Complex(this.realPart / square_norm, -this.imaginaryPart / square_norm);
}
@Override
public String toString() {
return realPart + "+i" + imaginaryPart;
}
public static void infinite()
{
// TODO: add code
}
}
package deque;
import java.util.NoSuchElementException;
/**
* A linear collection that supports element insertion and removal at
* both ends. This interface defines methods to access the elements at both
* ends of the deque (short for double ended queue). Methods are provided
* to insert, remove, and examine the element. the methods throw an exception
* if the operation fails.
*
* @author Doug Lea
* @author Josh Bloch
* @param <E> the type of elements held in this double ended queue
*/
public interface DoubleEndedQueue<E> {
/**
* Inserts the specified element at the front of this deque if it is
* possible to do so immediately without violating capacity restrictions,
* throwing an {@code IllegalStateException} if no space is currently
* available.
*
* @param e the element to add
* @throws IllegalStateException if the element cannot be added at this
* time due to capacity restrictions
*/
void addFirst(E e);
/**
* Inserts the specified element at the end of this deque if it is
* possible to do so immediately without violating capacity restrictions,
* throwing an {@code IllegalStateException} if no space is currently
* available.
*
* @param e the element to add
* @throws IllegalStateException if the element cannot be added at this
* time due to capacity restrictions
*/
void addLast(E e);
/**
* Retrieves and removes the first element of this deque. This method
* throws an exception if this deque is empty.
*
* @return the head of this deque
* @throws NoSuchElementException if this deque is empty
*/
E removeFirst();
/**
* Retrieves and removes the last element of this deque. This method
* throws an exception if this deque is empty.
*
* @return the tail of this deque
* @throws NoSuchElementException if this deque is empty
*/
E removeLast();
/**
* Retrieves, but does not remove, the first element of this deque.
* This method throws an exception if this deque is empty.
*
* @return the head of this deque
* @throws NoSuchElementException if this deque is empty
*/
E getFirst();
/**
* Retrieves, but does not remove, the last element of this deque.
* This method throws an exception if this deque is empty.
*
* @return the tail of this deque
* @throws NoSuchElementException if this deque is empty
*/
E getLast();
/**
* Returns the number of elements in this deque.
*
* @return the number of elements in this deque
*/
int size();
/**
* Returns {@code true} if this deque contains the specified element.
* More formally, returns {@code true} if and only if this deque contains
* at least one element {@code e} such that {@code Objects.equals(o, e)}.
*
* @param o element whose presence in this deque is to be tested
* @return {@code true} if this deque contains the specified element
* @throws NullPointerException if the specified element is null
*/
boolean contains(Object o);
}
package palindrome;
public class Palindrome {
static boolean isPalindrome(String s){
if (s.length() == 0)
return true;
if (s.length() == 1)
return true;
if (s.charAt(0) != s.charAt(s.length()-1))
return false;
return Palindrome.isPalindrome(s.substring(1,s.length()-1));
}
}
package partial_coverage;
public class PartialCoverage {
public int returnZeroOrOne(int x, int y) {
int res = 0;
int z = 2;
x = z * z - z - 1;
/* on va voir si intellij s'en sort!*/
y = x > 0 ? -1 : 0;
for (int i = x; i < y; i++) {
res = x == 0 ? 1 : 0;
}
return res;
}
}
package complex;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.within;
import static org.junit.jupiter.api.Assertions.fail;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
* Test class for the complex class.
*/
class ComplexTest {
private static final float EPSILON = 0.000001F;
@BeforeAll
static void setUpBeforeClass() throws Exception {
// TODO: add message
}
@AfterAll
static void tearDownAfterClass() throws Exception {
// TODO: add message
}
@BeforeEach
void setUp() throws Exception {
// TODO: add message
}
@AfterEach
void tearDown() throws Exception {
// TODO: add message
}
@Test
void testGetterImaginary() {
float expected = 2.0F;
Complex z = new Complex(1.0F, 2.0f);
assertThat(z.getImaginaryPart()).as("problem on getter imaginary")
.isCloseTo(expected, within(EPSILON));
}
@Test
void testGetterReal() {
float expected = 1.0F;
Complex z = new Complex(1.0F, 2.0f);
assertThat(z.getRealPart()).as("problem on getter real")
.isCloseTo(expected, within(EPSILON));
}
@Test
void testSetterImaginary() {
float expected = 3.0F;
Complex z = new Complex();
z.setImaginaryPart(expected);
assertThat(z.getImaginaryPart()).as("problem on setter imaginary")
.isCloseTo(expected, within(EPSILON));
}
@Test
void testSetterReal() {
float expected = 3.0F;
Complex z = new Complex();
z.setRealPart(expected);
assertThat(z.getRealPart()).as("problem on setter real")
.isCloseTo(expected, within(EPSILON));
}
@Test
void testZeroTrue() {
Complex z = new Complex(0.0F, 0.0F);
assertThat(z.isZero()).as("problem with isZero on Zero Complex number")
.isTrue();
}
@Test
void testZeroFalse() {
Complex z = new Complex(1.0F, 1.0F);
assertThat(z.isZero()).as("problem with isZero on non Zero Complex number")
.isFalse();
}
@Test
void testSumReal() {
Complex z1 = new Complex(1.0F, 2.0F);
Complex z2 = new Complex(3.0F, 4.0F);
float expected = 1.0F + 3.0F;
Complex z = z1.sum(z2);
assertThat(z.getRealPart()).as("problem with real part of Sum")
.isCloseTo(expected, within(EPSILON));
}
@Test
void testSumImaginary() {
Complex z1 = new Complex(1.0F, 2.0F);
Complex z2 = new Complex(3.0F, 4.0F);
float expected = 2.0F + 4.0F;
Complex z = z1.sum(z2);
assertThat(z.getImaginaryPart()).as("problem with imaginary part of Sum")
.isCloseTo(expected, within(EPSILON));
}
@Test
void testProductReal() {
Complex z1 = new Complex(1.0F, 2.0F);
Complex z2 = new Complex(3.0F, 4.0F);
float expected = 1.0F * 3.0F - 2.0F * 4.0F;
Complex z = z1.product(z2);
assertThat(z.getRealPart()).as("problem with real part of Product")
.isCloseTo(expected, within(EPSILON));
}
@Test
void testProductImaginary() {
Complex z1 = new Complex(1.0F, 2.0F);
Complex z2 = new Complex(3.0F, 4.0F);
float expected = 1.0F * 4.0F + 2.0F * 3.0F;
Complex z = z1.product(z2);
assertThat(z.getImaginaryPart()).as("problem with imaginary part of Product")
.isCloseTo(expected, within(EPSILON));
}
@Test
final void testTimeoutInfinite() {
Complex.infinite();
fail("NYI");
}
}
package palindrome;
import org.junit.jupiter.api.*;
import static org.assertj.core.api.Assertions.assertThat;
public class PalindromeTest {
@Test
void testEmptyString() {
assertThat(Palindrome.isPalindrome("")).isTrue();
}
@Test
void testEvenLengthFalse() {
assertThat(Palindrome.isPalindrome("abcd")).isFalse();
}
@Test
void testEvenLengthTrue() {
assertThat(Palindrome.isPalindrome("abba")).isTrue();
}
@Test
void testOddLengthTrue() {
assertThat(Palindrome.isPalindrome("aba")).isTrue();
}
}
.gradle/
.idea/
build/**/
*.iml
*.ipr
*.iws