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
No results found
Select Git revision
  • main
1 result
Show changes

Commits on Source 19

81 files
+ 1368
192
Compare changes
  • Side-by-side
  • Inline

Files

.gitlab-ci.yml

deleted100644 → 0
+0 −44
Original line number Original line Diff line number Diff line
include:
  - local: 'TP2/.gitlab-ci.yml'

## my_folder/build.yml
# the `.` (dot) before build means that we don't want it run alone, we must
# extends to run this part
.build:
  variables:
    SOFTWARE_ROOT: ""
  script:
    - echo ${SOFTWARE_ROOT}
    - cd ${SOFTWARE_ROOT}
    - build ${SOFTWARE_ROOT}

build_tp_2:
  extends: .build
  variables:
    SOFTWARE_ROOT: "TP2/"


.test:
  variables:
    SOFTWARE_ROOT: ""
  script:
    - cd ${SOFTWARE_ROOT}
    - test ${SOFTWARE_ROOT}

test_tp_2:
  extends: .test
  variables:
    SOFTWARE_ROOT: "TP2/"


.coverage:
  variables:
    SOFTWARE_ROOT: ""
  script:
    - cd ${SOFTWARE_ROOT}
    - coverage ${SOFTWARE_ROOT}

coverage_tp_2:
  extends: .coverage
  variables:
    SOFTWARE_ROOT: "TP2/"
 No newline at end of file

.idea/.gitignore

deleted100644 → 0
+0 −8
Original line number Original line Diff line number Diff line
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

CR-TP4/.gitkeep

0 → 100644
+0 −0
Original line number Original line Diff line number Diff line

CR-TP5/.gitkeep

0 → 100644
+0 −0
Original line number Original line Diff line number Diff line
+0 −1
Original line number Original line Diff line number Diff line
# M1 INFO FSI TP Template
# 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
+7 −11
Original line number Original line Diff line number Diff line
.gradle
.gradle/
build/
.idea/
!gradle/wrapper/gradle-wrapper.jar
build/**/
!**/src/main/**/build/
*.iml
!**/src/test/**/build/
*.ipr
*.iws



### IntelliJ IDEA ###
.idea


### VS Code ###
.vscode/
### Mac OS ###
.DS_Store
 No newline at end of file
+10 −7
Original line number Original line Diff line number Diff line
# 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 commandes gradle les plus utiles :
Les fichiers images correspondant au cas de test sont à mettre dans le répertoire `ìmages`.


- `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)

TP1/build.gradle.kts

0 → 100644
+42 −0
Original line number Original line Diff line number Diff line
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
}









TP1/gradle.properties

0 → 100644
+1 −0
Original line number Original line Diff line number Diff line
org.gradle.warning.mode=all
 No newline at end of file
Original line number Original line Diff line number Diff line
#Tue Dec 05 18:16:17 CET 2023
distributionBase=GRADLE_USER_HOME
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
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
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStorePath=wrapper/dists
+15 −5
Original line number Original line Diff line number Diff line
@@ -55,7 +55,7 @@
#       Darwin, MinGW, and NonStop.
#       Darwin, MinGW, and NonStop.
#
#
#   (3) This script is generated from the Groovy template
#   (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.
#       within the Gradle project.
#
#
#       You can find Gradle at https://github.com/gradle/gradle/.
#       You can find Gradle at https://github.com/gradle/gradle/.
@@ -80,13 +80,13 @@ do
    esac
    esac
done
done


APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# This is normally unused

# shellcheck disable=SC2034
APP_NAME="Gradle"
APP_BASE_NAME=${0##*/}
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.
# 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.
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
MAX_FD=maximum
@@ -143,12 +143,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
    case $MAX_FD in #(
    case $MAX_FD in #(
      max*)
      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 ) ||
        MAX_FD=$( ulimit -H -n ) ||
            warn "Could not query maximum file descriptor limit"
            warn "Could not query maximum file descriptor limit"
    esac
    esac
    case $MAX_FD in  #(
    case $MAX_FD in  #(
      '' | soft) :;; #(
      '' | 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" ||
        ulimit -n "$MAX_FD" ||
            warn "Could not set maximum file descriptor limit to $MAX_FD"
            warn "Could not set maximum file descriptor limit to $MAX_FD"
    esac
    esac
@@ -205,6 +209,12 @@ set -- \
        org.gradle.wrapper.GradleWrapperMain \
        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.
# Use "xargs" to parse quoted args.
#
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Original line number Original line Diff line number Diff line
rootProject.name = 'blackbox'
rootProject.name = 'tp_1_unit_test_and_coverage'
Original line number Original line Diff line number Diff line
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;
  }

}
Original line number Original line Diff line number Diff line
@@ -120,8 +120,6 @@ class ComplexTest {
  }
  }




  // TODO : correct the code and enable the test
  @Disabled
  @Test
  @Test
  void testProductReal() {
  void testProductReal() {
    Complex z1 = new Complex(1.0F, 2.0F);
    Complex z1 = new Complex(1.0F, 2.0F);
@@ -134,9 +132,7 @@ class ComplexTest {
            .isCloseTo(expected, within(EPSILON));
            .isCloseTo(expected, within(EPSILON));


  }
  }
  // TODO : correct the code and enable the test


  @Disabled
  @Test
  @Test
  void testProductImaginary() {
  void testProductImaginary() {
    Complex z1 = new Complex(1.0F, 2.0F);
    Complex z1 = new Complex(1.0F, 2.0F);
@@ -151,9 +147,6 @@ class ComplexTest {


  }
  }


  // TODO: Write a test that fails if computation with infinite takes too long

  @Disabled
  @Test
  @Test
  final void testTimeoutInfinite() {
  final void testTimeoutInfinite() {
    Complex.infinite();
    Complex.infinite();
Original line number Original line Diff line number Diff line
@@ -20,8 +20,7 @@ public class PalindromeTest {
  void testEvenLengthTrue() {
  void testEvenLengthTrue() {
    assertThat(Palindrome.isPalindrome("abba")).isTrue();
    assertThat(Palindrome.isPalindrome("abba")).isTrue();
  }
  }

  @Test
  @Disabled
  void testOddLengthTrue() {
  void testOddLengthTrue() {
    assertThat(Palindrome.isPalindrome("aba")).isTrue();
    assertThat(Palindrome.isPalindrome("aba")).isTrue();
  }
  }

TP2/.gitlab-ci.yml

deleted100644 → 0
+0 −58
Original line number Original line Diff line number Diff line
variables:
  GRADLE_OPTS: "-Dorg.gradle.daemon=false"

before_script:
  - export GRADLE_USER_HOME=`pwd`/.gradle

cache:
  paths:
    - .gradle/wrapper
    - .gradle/caches

stages:
  - build
  - test
  - coverage

build:
  stage: build
  image: openjdk:17-alpine
  script: ./gradlew --build-cache assemble
  cache:
    key: "$CI_COMMIT_REF_NAME"
    policy: push
    paths:
      - build
      - .gradle

test-junit:
  stage: test
  image: openjdk:17-alpine
  script:
    - ./gradlew test
  artifacts:
    when: always
    reports:
      junit: build/test-results/test/**/TEST-*.xml

test-jacoco:
  stage: test
  image: openjdk:17-alpine
  script:
    - ./gradlew jacocoTestReport # jacoco must be configured to create an xml report
  artifacts:
    paths:
      - build/reports/jacoco/test/jacocoTestReport.xml

coverage:
  stage: coverage
  image: registry.gitlab.com/haynes/jacoco2cobertura:1.0.7
  script:
    # convert report from jacoco to cobertura, using relative project path
    - python /opt/cover2cover.py build/reports/jacoco/test/jacocoTestReport.xml $CI_PROJECT_DIR/src/main/java/ > build/cobertura.xml
  needs: ["test-jacoco"]
  artifacts:
    reports:
      coverage_report:
        coverage_format: cobertura
        path: build/cobertura.xml
 No newline at end of file
+6 −2
Original line number Original line Diff line number Diff line
# TP 2 : tests unitaires et couverture de test
# Projet

Modèle de projet gradle pour les tests unitaires avec mock grace à [Mockito](https://site.mockito.org/).


Les commandes gradle les plus utiles :
Les commandes gradle les plus utiles :


- `gradle test` pour lancer les tests (rapports dans `build/reports/tests/test`),
- `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`). 
- `gradle run` pour lancer le programme,
- `gradle jacocoTestReport` pour lancer la couverture de code via l'outil [Jacoco](https://www.eclemma.org/jacoco/) (rapports dans `build/reports/jacoco/test`).


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.
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.


@@ -14,3 +17,4 @@ Le projet est configuré (via le fichier `.gitlab-ci.yml`) pour produire un jar


- NOM, prénom du premier membre du projet
- NOM, prénom du premier membre du projet
- NOM, prénom du deuxième membre du projet (optionnel)
- NOM, prénom du deuxième membre du projet (optionnel)

TP2/build.gradle

deleted100644 → 0
+0 −42
Original line number Original line Diff line number Diff line
plugins {
    id 'java'
    id 'application'
    id 'jacoco'
}

group 'fr.univ_amu'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
}

dependencies {
    testImplementation 'org.junit.jupiter:junit-jupiter:5.9.2'
    testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
    testImplementation("org.assertj:assertj-core:3.24.2")
}

test {
    finalizedBy jacocoTestReport
}

jacocoTestReport {
    dependsOn test // tests are required to run before generating the report
    reports {
        xml.required = true
    }
}

test {
    useJUnitPlatform()
}








TP2/build.gradle.kts

0 → 100644
+43 −0
Original line number Original line Diff line number Diff line
plugins {
    id("java")
    id("jacoco")
}

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")
    testImplementation("org.mockito:mockito-core:5.15.2")
}

tasks.test {
    finalizedBy("jacocoTestReport")
}

tasks.jacocoTestReport {
    dependsOn("test")
    reports {
        xml.required = true
        html.outputLocation = layout.buildDirectory.dir("jacocoHtml")
    }
}

tasks.test {
    useJUnitPlatform()
}










Original line number Original line Diff line number Diff line
distributionBase=GRADLE_USER_HOME
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
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
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStorePath=wrapper/dists
Original line number Original line Diff line number Diff line
rootProject.name = 'tp_fiabilite'
rootProject.name = 'tp_2_mocking'

TP3/.gitignore

0 → 100644
+14 −0
Original line number Original line Diff line number Diff line
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### IntelliJ IDEA ###
.idea

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
 No newline at end of file

TP3/README.md

0 → 100644
+11 −0
Original line number Original line Diff line number Diff line
# TP 1 : tests boîte noire

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`.


Pour lancer les tests, il suffit d'utiliser la commande :

```bash
gradle run
```
Original line number Original line Diff line number Diff line
plugins {
plugins {
    id 'java'
    id("java")
    id 'application'
    id("application")
}
}


group = 'org.example'
version = '1.0-SNAPSHOT'

repositories {
repositories {
    mavenCentral()
    mavenCentral()
}
}


dependencies {
dependencies {
    testImplementation platform('org.junit:junit-bom:5.9.1')
    testImplementation("org.junit.jupiter:junit-jupiter-api:5.11.4")
    testImplementation 'org.junit.jupiter:junit-jupiter'
    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")
}
}


test {
tasks.test {
    useJUnitPlatform()
    useJUnitPlatform()
}
}


Original line number Original line Diff line number Diff line
#Tue Dec 05 18:16:17 CET 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

TP3/gradlew

0 → 100755
+234 −0
Original line number Original line Diff line number Diff line
#!/bin/sh

#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

##############################################################################
#
#   Gradle start up script for POSIX generated by Gradle.
#
#   Important for running:
#
#   (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
#       noncompliant, but you have some other compliant shell such as ksh or
#       bash, then to run this script, type that shell name before the whole
#       command line, like:
#
#           ksh Gradle
#
#       Busybox and similar reduced shells will NOT work, because this script
#       requires all of these POSIX shell features:
#         * functions;
#         * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
#           «${var#prefix}», «${var%suffix}», and «$( cmd )»;
#         * compound commands having a testable exit status, especially «case»;
#         * various built-in commands including «command», «set», and «ulimit».
#
#   Important for patching:
#
#   (2) This script targets any POSIX shell, so it avoids extensions provided
#       by Bash, Ksh, etc; in particular arrays are avoided.
#
#       The "traditional" practice of packing multiple parameters into a
#       space-separated string is a well documented source of bugs and security
#       problems, so this is (mostly) avoided, by progressively accumulating
#       options in "$@", and eventually passing that to Java.
#
#       Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
#       and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
#       see the in-line comments for details.
#
#       There are tweaks for specific operating systems such as AIX, CygWin,
#       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
#       within the Gradle project.
#
#       You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################

# Attempt to set APP_HOME

# Resolve links: $0 may be a link
app_path=$0

# Need this for daisy-chained symlinks.
while
    APP_HOME=${app_path%"${app_path##*/}"}  # leaves a trailing /; empty if no leading path
    [ -h "$app_path" ]
do
    ls=$( ls -ld "$app_path" )
    link=${ls#*' -> '}
    case $link in             #(
      /*)   app_path=$link ;; #(
      *)    app_path=$APP_HOME$link ;;
    esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
APP_BASE_NAME=${0##*/}

# 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"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum

warn () {
    echo "$*"
} >&2

die () {
    echo
    echo "$*"
    echo
    exit 1
} >&2

# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in                #(
  CYGWIN* )         cygwin=true  ;; #(
  Darwin* )         darwin=true  ;; #(
  MSYS* | MINGW* )  msys=true    ;; #(
  NONSTOP* )        nonstop=true ;;
esac

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar


# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
        # IBM's JDK on AIX uses strange locations for the executables
        JAVACMD=$JAVA_HOME/jre/sh/java
    else
        JAVACMD=$JAVA_HOME/bin/java
    fi
    if [ ! -x "$JAVACMD" ] ; then
        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
    fi
else
    JAVACMD=java
    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
    case $MAX_FD in #(
      max*)
        MAX_FD=$( ulimit -H -n ) ||
            warn "Could not query maximum file descriptor limit"
    esac
    case $MAX_FD in  #(
      '' | soft) :;; #(
      *)
        ulimit -n "$MAX_FD" ||
            warn "Could not set maximum file descriptor limit to $MAX_FD"
    esac
fi

# Collect all arguments for the java command, stacking in reverse order:
#   * args from the command line
#   * the main class name
#   * -classpath
#   * -D...appname settings
#   * --module-path (only if needed)
#   * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.

# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
    APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
    CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )

    JAVACMD=$( cygpath --unix "$JAVACMD" )

    # Now convert the arguments - kludge to limit ourselves to /bin/sh
    for arg do
        if
            case $arg in                                #(
              -*)   false ;;                            # don't mess with options #(
              /?*)  t=${arg#/} t=/${t%%/*}              # looks like a POSIX filepath
                    [ -e "$t" ] ;;                      #(
              *)    false ;;
            esac
        then
            arg=$( cygpath --path --ignore --mixed "$arg" )
        fi
        # Roll the args list around exactly as many times as the number of
        # args, so each arg winds up back in the position where it started, but
        # possibly modified.
        #
        # NB: a `for` loop captures its iteration list before it begins, so
        # changing the positional parameters here affects neither the number of
        # iterations, nor the values presented in `arg`.
        shift                   # remove old arg
        set -- "$@" "$arg"      # push replacement arg
    done
fi

# Collect all arguments for the java command;
#   * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
#     shell script including quotes and variable substitutions, so put them in
#     double quotes to make sure that they get re-expanded; and
#   * put everything else in single quotes, so that it's not re-expanded.

set -- \
        "-Dorg.gradle.appname=$APP_BASE_NAME" \
        -classpath "$CLASSPATH" \
        org.gradle.wrapper.GradleWrapperMain \
        "$@"

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
#   readarray ARGS < <( xargs -n1 <<<"$var" ) &&
#   set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#

eval "set -- $(
        printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
        xargs -n1 |
        sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
        tr '\n' ' '
    )" '"$@"'

exec "$JAVACMD" "$@"

TP3/gradlew.bat

0 → 100644
+89 −0
Original line number Original line Diff line number Diff line
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem      https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem  Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega

TP3/images/.gitkeep

0 → 100644
+0 −0
Original line number Original line Diff line number Diff line

TP3/settings.gradle

0 → 100644
+2 −0
Original line number Original line Diff line number Diff line
rootProject.name = 'tp_3_test_blackbox'

TP4/.gitignore

0 → 100644
+14 −0
Original line number Original line Diff line number Diff line
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### IntelliJ IDEA ###
.idea/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
 No newline at end of file

TP4/README.md

0 → 100644
+37 −0
Original line number Original line Diff line number Diff line
# M1 INFO FSI TP 4

- Lancer PMD sur le code `main` avec la commande suivante :

    ```
    ./gradlew pmdMain
    ```
  
- Lancer PMD sur le code `test` avec la commande suivante :

    ```
    ./gradlew pmdTest
    ```

- Lancer SpotBugs sur le code `main` avec la commande suivante :

    ```
    ./gradlew spotbugsMain
    ```

- Lancer SpotBugs sur le code `test` avec la commande suivante :

    ```
    ./gradlew spotbugsTest
    ```

- Lancer sonarlint sur le code `main` avec la commande suivante :

    ```
    ./gradlew sonarlintMain
    ```

- Lancer sonarlint sur le code `test` avec la commande suivante :

    ```
    ./gradlew sonarlintTest
    ```
 No newline at end of file

TP4/build.gradle.kts

0 → 100644
+37 −0
Original line number Original line Diff line number Diff line
plugins {
    id("java")
    id("application")
    id("pmd")
    id("com.github.spotbugs") version "6.1.3"
    id ("name.remal.sonarlint") version "5.1.1"
}

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()
}

pmd {
    isConsoleOutput = true
    toolVersion = "7.0.0-rc1"
    rulesMinimumPriority = 5
    ruleSets = listOf("rulesets/java/quickstart.xml", "category/java/errorprone.xml", "category/java/bestpractices.xml")
}

spotbugs {
    toolVersion = "4.9.0"
}

application {
    mainClass.set("Main")
}
Original line number Original line Diff line number Diff line
#Tue Dec 05 18:16:17 CET 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

TP4/gradlew

0 → 100755
+234 −0
Original line number Original line Diff line number Diff line
#!/bin/sh

#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

##############################################################################
#
#   Gradle start up script for POSIX generated by Gradle.
#
#   Important for running:
#
#   (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
#       noncompliant, but you have some other compliant shell such as ksh or
#       bash, then to run this script, type that shell name before the whole
#       command line, like:
#
#           ksh Gradle
#
#       Busybox and similar reduced shells will NOT work, because this script
#       requires all of these POSIX shell features:
#         * functions;
#         * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
#           «${var#prefix}», «${var%suffix}», and «$( cmd )»;
#         * compound commands having a testable exit status, especially «case»;
#         * various built-in commands including «command», «set», and «ulimit».
#
#   Important for patching:
#
#   (2) This script targets any POSIX shell, so it avoids extensions provided
#       by Bash, Ksh, etc; in particular arrays are avoided.
#
#       The "traditional" practice of packing multiple parameters into a
#       space-separated string is a well documented source of bugs and security
#       problems, so this is (mostly) avoided, by progressively accumulating
#       options in "$@", and eventually passing that to Java.
#
#       Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
#       and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
#       see the in-line comments for details.
#
#       There are tweaks for specific operating systems such as AIX, CygWin,
#       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
#       within the Gradle project.
#
#       You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################

# Attempt to set APP_HOME

# Resolve links: $0 may be a link
app_path=$0

# Need this for daisy-chained symlinks.
while
    APP_HOME=${app_path%"${app_path##*/}"}  # leaves a trailing /; empty if no leading path
    [ -h "$app_path" ]
do
    ls=$( ls -ld "$app_path" )
    link=${ls#*' -> '}
    case $link in             #(
      /*)   app_path=$link ;; #(
      *)    app_path=$APP_HOME$link ;;
    esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
APP_BASE_NAME=${0##*/}

# 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"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum

warn () {
    echo "$*"
} >&2

die () {
    echo
    echo "$*"
    echo
    exit 1
} >&2

# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in                #(
  CYGWIN* )         cygwin=true  ;; #(
  Darwin* )         darwin=true  ;; #(
  MSYS* | MINGW* )  msys=true    ;; #(
  NONSTOP* )        nonstop=true ;;
esac

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar


# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
        # IBM's JDK on AIX uses strange locations for the executables
        JAVACMD=$JAVA_HOME/jre/sh/java
    else
        JAVACMD=$JAVA_HOME/bin/java
    fi
    if [ ! -x "$JAVACMD" ] ; then
        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
    fi
else
    JAVACMD=java
    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
    case $MAX_FD in #(
      max*)
        MAX_FD=$( ulimit -H -n ) ||
            warn "Could not query maximum file descriptor limit"
    esac
    case $MAX_FD in  #(
      '' | soft) :;; #(
      *)
        ulimit -n "$MAX_FD" ||
            warn "Could not set maximum file descriptor limit to $MAX_FD"
    esac
fi

# Collect all arguments for the java command, stacking in reverse order:
#   * args from the command line
#   * the main class name
#   * -classpath
#   * -D...appname settings
#   * --module-path (only if needed)
#   * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.

# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
    APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
    CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )

    JAVACMD=$( cygpath --unix "$JAVACMD" )

    # Now convert the arguments - kludge to limit ourselves to /bin/sh
    for arg do
        if
            case $arg in                                #(
              -*)   false ;;                            # don't mess with options #(
              /?*)  t=${arg#/} t=/${t%%/*}              # looks like a POSIX filepath
                    [ -e "$t" ] ;;                      #(
              *)    false ;;
            esac
        then
            arg=$( cygpath --path --ignore --mixed "$arg" )
        fi
        # Roll the args list around exactly as many times as the number of
        # args, so each arg winds up back in the position where it started, but
        # possibly modified.
        #
        # NB: a `for` loop captures its iteration list before it begins, so
        # changing the positional parameters here affects neither the number of
        # iterations, nor the values presented in `arg`.
        shift                   # remove old arg
        set -- "$@" "$arg"      # push replacement arg
    done
fi

# Collect all arguments for the java command;
#   * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
#     shell script including quotes and variable substitutions, so put them in
#     double quotes to make sure that they get re-expanded; and
#   * put everything else in single quotes, so that it's not re-expanded.

set -- \
        "-Dorg.gradle.appname=$APP_BASE_NAME" \
        -classpath "$CLASSPATH" \
        org.gradle.wrapper.GradleWrapperMain \
        "$@"

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
#   readarray ARGS < <( xargs -n1 <<<"$var" ) &&
#   set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#

eval "set -- $(
        printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
        xargs -n1 |
        sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
        tr '\n' ' '
    )" '"$@"'

exec "$JAVACMD" "$@"

TP4/gradlew.bat

0 → 100644
+89 −0
Original line number Original line Diff line number Diff line
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem      https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem  Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega

TP4/settings.gradle

0 → 100644
+4 −0
Original line number Original line Diff line number Diff line


rootProject.name = 'tp_4_static_analysis'
+64 −0
Original line number Original line Diff line number Diff line
public class Complex {
    float realPart = 0;
    float imaginaryPart = 0;

    public Complex() {
        super();
    }

    public Complex(float a, float b) {
        this.realPart = a;
        this.imaginaryPart = b;
    }


    public boolean is_zero() {
        return ((this.realPart == 0) && (this.imaginaryPart == 0));
    }

    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 inverse() throws IllegalArgumentException {

        float square_norm = (this.realPart * this.realPart + this.imaginaryPart * this.imaginaryPart);

        if (is_zero()) throw new IllegalArgumentException();
        else return new Complex(this.realPart / square_norm, -this.imaginaryPart / square_norm);
    }

    public boolean equals(Complex c){
        if ((this == null) || (c == null)) return false;
        return ((this.realPart == c.realPart) && (this.imaginaryPart == c.imaginaryPart));
    }

    @Override
    public String toString() {
        return realPart + "+i" + imaginaryPart;
    }

    public static void infinite()
    {
        infinite();
    }
}

+47 −0
Original line number Original line Diff line number Diff line

public class Main {

    public static class Point{
        float abs = 0.0F;
        float ord = 0.0F;

        public Point(){
            super();
        }

        public Point(float x, float y){
            abs = x;
            ord = y;
        }
    }

    public static class Rectangle{
        Point point1;
        Point point2;

        public Rectangle(Point P1, Point P2){
            point1 = P1;
            point2 = P2;
        }
    }


    public static void main(String[] args) {

    Point P1 = new Point(7,8);
    Rectangle R1 = new Rectangle(P1, new Point());
    Rectangle R2 = R1;
    Rectangle R3 = new Rectangle(P1, new Point());

    if (R1 == R2)  System.out.println("equal_ref");

    if (R1.point1 == R3.point1) System.out.println("equal_point1Field");


    R3.point1.ord = 2;
    R1.point1.ord = R3.point1.ord;
    if (R1.point1.ord == R3.point1.ord) System.out.println("equal_point1Field_ordField");

    }

}
+29 −0
Original line number Original line Diff line number Diff line
import java.io.*;

public class SpotBugsExample {
    private byte[] b;
    private int length;

    SpotBugsExample() {
        length = 40;
        b = new byte[length];
    }


    public void bar() {
        int y;

        try {
            FileInputStream x = new FileInputStream("z");
            x.read(b, 0, length);
            x.close();
        } catch (Exception e) {
            System.out.println("Oopsie");
        }

        for (int i = 1; i <= length; i++) {
            if (Integer.toString(50) == Byte.toString(b[i])) System.out.print(b[i] + " ");
        }

    }
}
+41 −0
Original line number Original line Diff line number Diff line
#include <limits.h>
#include "__fc_builtin.h"

/*@
  ensures \result >= 0;
*/
int abs(int val)
{
	if (val < 0)
		return -val;
	return val;
}

/*@ ensures \result == a + b;
 */
int add(int a, int b)
{
	return a + b;
}

/*@ ensures \result == a/b;
 */
int div(int a, int b)
{
	return a / b;
}

int main(void)
{
	int a = abs(42);
	int b = abs(-42);
	int c = abs(-74);
	int d = add(a, c);
	int e = add(d, d);
	//	b = add(INT_MAX,42);	//cas d’erreur 1
	//	a = abs(INT_MIN);		//cas d’erreur 2
	a = div(4, 8);
	b = div(17, -12);
	//	c = div(15,0);			//cas d’erreur 3
	a = div(-12, 54);
}
 No newline at end of file

TP5/Exo2/max.c

0 → 100644
+9 −0
Original line number Original line Diff line number Diff line
#include "max.h"

int max(int a, int b)
{
	int res = a;
	if (res < b)
		res = b;
	return res;
}
 No newline at end of file

TP5/Exo2/max.h

0 → 100644
+4 −0
Original line number Original line Diff line number Diff line

/*Put your specification here.
*/
int max(int a, int b);
 No newline at end of file

TP5/Exo2/max_5.c

0 → 100644
+15 −0
Original line number Original line Diff line number Diff line
#include "max_5.h"

int max(int a, int b, int c, int d, int e)
{
    int res = a;
    if (res < b)
        res = b;
    if (res < c)
        res = c;
    if (res < d)
        res = d;
    if (res < e)
        res = e;
    return res;
}
 No newline at end of file

TP5/Exo2/max_5.h

0 → 100644
+4 −0
Original line number Original line Diff line number Diff line

/*Put your specification here.
 */
int max(int a, int b, int c, int d, int e);
 No newline at end of file

TP5/Exo2/max_wrong1.c

0 → 100644
+6 −0
Original line number Original line Diff line number Diff line
#include "max.h"

int max(int a, int b)
{
	return a;
}
 No newline at end of file

TP5/Exo2/max_wrong2.c

0 → 100644
+7 −0
Original line number Original line Diff line number Diff line
#include "max.h"
#include "limits.h"

int max(int a, int b)
{
	return INT_MAX;
}
 No newline at end of file

TP5/Exo2/silly-max.c

0 → 100644
+25 −0
Original line number Original line Diff line number Diff line
#include "max.h"

int max(int a, int b)
{
    if (a == 0 && b == 0)
        return 0;
    if (a <= 0 && b >= 0)
        return b;
    if (a > 42 && b <= 25)
        return a;
    if (a >= 0 && b <= 0)
        return a;
    if (a - b > 4)
        return a;
    if (a - b < 1)
        return b;
    if (a == b + 1)
        return a;
    if (a <= b + 4)
        if (a + 1 < b)
            return b;
        else
            return a;
    return 42;
}
 No newline at end of file
+47 −0
Original line number Original line Diff line number Diff line
#include "plus_one.h"
#include "div.h"

int good_call_1(void)
{
    return plus_one(4);
}

int bad_call_1(void)
{
    return plus_one(-345);
}

int bad_call_2(void)
{
    return plus_one(INT_MAX);
}

int good_call_2(void)
{
    return div(45, 73);
}

int good_call_3(void)
{
    return div(0, 74);
}

int bad_call_3(void)
{
    return div(74, 0);
}

int good_call_4(void)
{
    return div(INT_MAX, INT_MIN);
}

int good_call_5(void)
{
    return div(INT_MAX, -1);
}

int bad_call_4(void)
{
    return div(INT_MIN, -1);
}
 No newline at end of file

TP5/Exo3/div.c

0 → 100644
+6 −0
Original line number Original line Diff line number Diff line
#include "div.h"

int div(int a, int b)
{
    return a / b;
}
 No newline at end of file

TP5/Exo3/div.h

0 → 100644
+5 −0
Original line number Original line Diff line number Diff line
#include "limits.h"

/*@ ensures \result == a/b;
*/
int div(int a, int b);
 No newline at end of file

TP5/Exo3/plus_one.c

0 → 100644
+6 −0
Original line number Original line Diff line number Diff line
#include "plus_one.h"

int plus_one(int a)
{
	return a + 1;
}
 No newline at end of file

TP5/Exo3/plus_one.h

0 → 100644
+4 −0
Original line number Original line Diff line number Diff line

/*@ ensures \result >= 0;
*/
int plus_one(int a);
 No newline at end of file

TP5/Exo4/affine.c

0 → 100644
+6 −0
Original line number Original line Diff line number Diff line
#include "affine.h"

int f(int a, int b, int x)
{
  return a * x + b;
}
 No newline at end of file

TP5/Exo4/affine.h

0 → 100644
+4 −0
Original line number Original line Diff line number Diff line
#include "limits.h"

/* Écrivez ici votre spécification. Attention, elle doit permettre de prouver les assertions RTE.*/
int f(int a,int b,int x);
 No newline at end of file
+27 −0
Original line number Original line Diff line number Diff line
#include "limits.h"

/*@ requires a < INT_MAX;
    behavior div:
        assumes a <= 0;
        requires b != 0;
        ensures \result == a/b;

    behavior add:
        assumes a > 0 && b <= 0;
        ensures \result == a+b;

    behavior sub:
        assumes a > 0 && b >= 0;
        ensures \result == a-b;

    complete behaviors;
    disjoint behaviors div,add;
*/
int addOrDiv(int a, int b)
{
    if (a <= 0)
        return a / b;
    if (b <= 0)
        return a + b;
    return a - b;
}
 No newline at end of file
+16 −0
Original line number Original line Diff line number Diff line

/*@ predicate inInterval(integer a, integer b, integer c) = a >= b && a <= c;

    predicate fourInOrder(integer a, integer b, integer c, integer d) = inInterval(b,a,c) && inInterval(c,b,d);

    predicate controlledEquality(integer a, integer b, boolean c) = a == b || c;
*/

/*@ requires inInterval(a,b,c);
    requires inInterval(c,a,d);
    ensures fourInOrder(\result,a,c,d);
*/
int toto(int a, int b, int c, int d)
{
    return b;
}
 No newline at end of file

TP5/Exo5/result-case.c

0 → 100644
+15 −0
Original line number Original line Diff line number Diff line
#include "result-case.h"

int caseResult(int a, int b, int c)
{
    if (a == b || b == c || a == c)
        return 0;
    if (a <= b && a <= c)
        return 1;
    if (b <= a && a <= c)
        return 2;
    if (c <= a && c <= b)
        return 3;
    // Dans quel ordre sont rangés a,b et c ici ?
    return 2;
}
 No newline at end of file

TP5/Exo5/result-case.h

0 → 100644
+6 −0
Original line number Original line Diff line number Diff line

/* Put your specification here.

Attention, la spécification à trouver ici n’est pas une paraphrase du code. Demandez-vous, pour chaque résultat quel est la description la plus courte dans laquelle ce résultat est renvoyé.
*/
int caseResult(int a, int b, int c);
 No newline at end of file

TP5/Exo6/exo6.h

0 → 100644
+30 −0
Original line number Original line Diff line number Diff line
#include "limits.h"

/**
 * @brief Computes the min of these arguments.
 * 
 * @param a an integer
 * @param b an integer
 * @param c an integer
 * @return int The smallest value among a, b and c.
 */
int min(int a, int b, int c);

/**
 * @brief Computes the next step of @p a in the Syracuse sequence, i.e., its quotient by 2 if @p a is even, and 3 * @p a +1 otherwise.
 * 
 * @param a an integer.
 * @return int The next value in the Syracuse sequence.
 */
int syracuseStep(int a);

/**
 * @brief Computes the rounding of the (real) quotient of a by b, i.e. the closest integer to the quotient. We will accept a function that does that only for positive integers (remember the C int division is not the Euclidean division). As a bonus, you might implement a function that works for any pair of integer (such that the quotient is defined of course).
 *
 * @param a the dividend
 * @param b the diviser
 * @return int The rounding of a/.b.
 * @pre a and b are positive (or not, depending of your implementation).
 * @pre b is not 0.
 */
int roundedDiv(int a, int b);
 No newline at end of file