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

version 2023

parent 95a9c24d
No related branches found
No related tags found
No related merge requests found
.gradle/
.idea/
idea/
build/
*.iml
*.ipr
*.iws
gradle/wrapper/gradle-wrapper.jar
out/
image: openjdk:17-alpine
variables:
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
cache:
paths:
- .gradle/wrapper
- .gradle/caches
stages:
- test
java:
stage: test
script: ./gradlew test
artifacts:
when: always
reports:
junit: build/test-results/test/**/TEST-*.xml
cache:
key: "$CI_COMMIT_REF_NAME"
policy: pull
paths:
- build
- .gradle
\ No newline at end of file
<!DOCTYPE html> # Vecteur d'entiers
<html xmlns="http://www.w3.org/1999/xhtml" lang="fr" xml:lang="fr">
<h2>Version courte <h2>
<p> Pour chacune des classes vue en TD vous devez écrire des tests pour chacune des méthodes et ensuite vous implémenterez ces méthodes. Vous avez un exemple de squelette pour la classe <code>Vector</code>.</p> ## Version courte
<h2>Objectif</h2> Pour chacune des classes vue en TD vous devez écrire des tests pour chacune des méthodes et ensuite vous implémenterez
ces méthodes. Vous avez un exemple de squelette pour la classe `Vector`.
<p>L'objectif de ce TP est de mettre en place des pratiques de programmation permettant ## Objectif
L'objectif de ce TP est de mettre en place des pratiques de programmation permettant
de produire un code correct et lisible. Ce premier TP est assez long à réaliser. Il est impératif de vous concentrer de produire un code correct et lisible. Ce premier TP est assez long à réaliser. Il est impératif de vous concentrer
sur votre TP et de travailler entre les TP pour le terminer.</p> sur votre TP et de travailler entre les TP pour le terminer.
<p>La démarche que vous allez suivre pour implémenter les exercices du TD est la suivante. Vous allez faire dans l'ordre La démarche que vous allez suivre pour implémenter les exercices du TD est la suivante. Vous allez faire dans l'ordre
les trois points suivants : les trois points suivants :
<ul>
<li>Écriture de commentaires pour spécifier <b>précisément</b> le comportement des classes et méthodes.</li>
<li>Écriture de tests permettant de vérifier la <b>totalité</b> de la spécification.</li>
<li>Écriture du code des méthodes de façon <b>la plus lisible possible</b>.</li>
</ul>
</p>
<h2>Vecteur d'entiers</h2> - Écriture de commentaires pour spécifier **précisément** le comportement des classes et méthodes
- Écriture de tests permettant de vérifier la **totalité** de la spécification.
- Écriture du code des méthodes de façon **la plus lisible possible**.
<h3>Écriture des tests</h3> ## Écriture des tests
<p>Les tests permettent de vérifier à chaque étape du développement que le code écrit est correct, c'est-à-dire, Les tests permettent de vérifier à chaque étape du développement que le code écrit est correct, c'est-à-dire,
qu'il vérifie les spécifications. Les tests vont être écrits sous la forme de petites méthodes qui vérifient qu'il vérifie les spécifications. Les tests vont être écrits sous la forme de petites méthodes qui vérifient
un des comportements attendus. </p> un des comportements attendus.
<p>Faites un clic droit sur la classe <code>Vector</code> et créez un nouveau <code>JUnit Test Case</code>. Placez vous sur la classe `VectorTest` et exécutez son contenu à l'aide du double triangle
Sélectionnez <code>New JUnit 4 test</code>, le répertoire <code>src/test/java</code> et nommez vert à coté de la classe sous *InteliJ IDEA*. Normalement, vous devriez voir apparaître le
la classe <code>VectorTest</code>. Normalement, la nouvelle classe contient un code qui ressemble à celui-ci : <p> résultat de l'exécution des test de la classe.
En effet, chaque méthode de ses méthodes est annotée par `@Test` et donc exécuté
<code> comme un test par `JUnit`. Pour le moment, tous les test sauf un sont désactivés car ils
public class VectorTest { sont précédés de l'annotation
@Test `@Disabled`.
public void test() {
fail("Not yet implemented"); Vous allez devoir copmpléter le code des méthodes dans la classe `Vector` afin que les tests
} déjà écrits complétement (ceux sans commentaire `// TODO`) passent. Ensuite, vous devez
} compléter les tests incomplets dans `VectorTest` et éventuellement corriger des problèmes dans
</code> `Vector` afin que ces tests passent. Finalement, vous devez ajouter vos propres tests afin de
garantir le respect des spécifications par la classe `Vector`.
<p>Placez vous sur la classe et <code>VectorTest</code> et exécutez son contenu à l'aide de la flèche
verte d'<code>Eclipse</code>. Normalement, vous devriez voir apparaître le résultat de l'exécution
avec un échec rencontré sur la méthode <code>void test()</code>. En effet, la méthode
<code>test()</code> est annotée par <code>@Test</code>. Par conséquent, elle est exécutée comme
un test par <code>JUnit</code>. La ligne <code>fail("Not yet implemented");</code> génère l'échec
obtenu par l'exécution des tests.</p>
<p>Vous allez écrire des méthodes dans la classe <code>VectorTest</code> afin de tester les différentes
fonctionnalités de la classe <code>Vector</code>. Pour cela, vous allez la compléter en vous inspirant des tests déjà écrits.
<h3>Implémentation de la classe Vector</h3>
<p>Vous pouvez maintenant implémenter la classe <code>Vector</code> en vérifiant
à chaque étape de son implémentation que de nouveaux tests passent au vert.
N'hésitez pas à utiliser le débogueur d'Eclipse si vous avez des problèmes
pour trouver vos erreurs. Évidemment, les erreurs peuvent se trouver dans
les tests ou dans le code de la classe Vector. Dans tous les cas, vous ne
devez modifier les tests uniquement s'ils sont en désaccords avec les
spécifications de la classe.</p>
<h2>Pile d'entiers</h2>
<p>Effectuez les mêmes étapes que pour l'exercice précédent afin d'ajouter
à votre projet la nouvelle classe <code>Stack</code> qui utilise
la classe <code>Vector</code> afin d'implémenter une pile. Vous devez
donc écrire les spécifications de la classe, écrire une classe
de tests, puis implémenter la classe <code>Stack</code>. Cette classe
peut être placée dans un package <code>fr.licinfo.structure</code>. </p>
<h2>Filtres de chaînes de caractères</h2>
<p>Nous allons programmer les classes de l'exercice 3 du TD en utilisant la même démarche de "qualité".
Créez un nouveau projet Maven de nom <code>stringfilter</code>, configurez-le afin de pouvoir utiliser
<code>JUnit 4</code> et <code>Hamcrest</code>.</p>
<p>Définissez ensuite l'interface <code>StringFilter</code> et commentez-là. Créez ensuite les différentes classes
qui implémentent l'interface <code>StringFilter</code>. Écrivez les commentaires précisant leurs spécifications
<b>sans les implémenter</b>.</p>
<p>Ajoutez une classe de tests <code>StringFilterTest</code>. Dans cette classe, ajoutez une méthode testant
chacune des implémentations de <code>StringFilter</code>. Par exemple, vous pouvez ajouter la méthode suivante
pour tester la classe <code>UpperCaseStringFilter</code> : </p>
<code>
@Test
public void upperCaseStringFilter() {
String input = "toto";
StringFilter filter = new UpperCaseStringFilter();
String output = filter.filter(input);
assertThat(output, equalTo("TOTO"));
}
</code>
<p>Implémentez ensuite les différents filtres en vérifiant que votre code est correct à l'aide des tests.</p>
</div>
<ul id="slide-out" class="right side-nav"></ul>
</div>
<footer class="page-footer teal lighten-2">
<div class="footer-copyright">
<div class="center-align">
&copy; 2018 Bertrand Estellon
</div>
</div>
</footer>
</body>
</html>
plugins { plugins {
id 'java' id "java"
} }
group 'L3_INFO'
version '1.0-SNAPSHOT' version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories { repositories {
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12' testImplementation('org.junit.jupiter:junit-jupiter-api:5.10.0',
testCompile 'org.hamcrest:hamcrest-library:1.3' 'org.assertj:assertj-core:3.24.2')
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.0'
}
test {
useJUnitPlatform()
} }
#Wed Sep 18 23:20:29 CEST 2019
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-all.zip
#!/usr/bin/env sh #!/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 UN*X # 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/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/.
#
############################################################################## ##############################################################################
# Attempt to set APP_HOME # Attempt to set APP_HOME
# Resolve links: $0 may be a link # Resolve links: $0 may be a link
PRG="$0" app_path=$0
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do # Need this for daisy-chained symlinks.
ls=`ls -ld "$PRG"` while
link=`expr "$ls" : '.*-> \(.*\)$'` APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
if expr "$link" : '/.*' > /dev/null; then [ -h "$app_path" ]
PRG="$link" do
else ls=$( ls -ld "$app_path" )
PRG=`dirname "$PRG"`"/$link" link=${ls#*' -> '}
fi case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle" # This is normally unused
APP_BASE_NAME=`basename "$0"` # 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. # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS="" 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
warn () { warn () {
echo "$*" echo "$*"
} } >&2
die () { die () {
echo echo
echo "$*" echo "$*"
echo echo
exit 1 exit 1
} } >&2
# OS specific support (must be 'true' or 'false'). # OS specific support (must be 'true' or 'false').
cygwin=false cygwin=false
msys=false msys=false
darwin=false darwin=false
nonstop=false nonstop=false
case "`uname`" in case "$( uname )" in #(
CYGWIN* ) CYGWIN* ) cygwin=true ;; #(
cygwin=true Darwin* ) darwin=true ;; #(
;; MSYS* | MINGW* ) msys=true ;; #(
Darwin* ) NONSTOP* ) nonstop=true ;;
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM. # Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables # IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java" JAVACMD=$JAVA_HOME/jre/sh/java
else else
JAVACMD="$JAVA_HOME/bin/java" JAVACMD=$JAVA_HOME/bin/java
fi fi
if [ ! -x "$JAVACMD" ] ; then if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
...@@ -81,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the ...@@ -81,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation." location of your Java installation."
fi fi
else else
JAVACMD="java" 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. 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 Please set the JAVA_HOME variable in your environment to match the
...@@ -89,84 +140,105 @@ location of your Java installation." ...@@ -89,84 +140,105 @@ location of your Java installation."
fi fi
# Increase the maximum file descriptors if we can. # Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
MAX_FD_LIMIT=`ulimit -H -n` case $MAX_FD in #(
if [ $? -eq 0 ] ; then max*)
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
MAX_FD="$MAX_FD_LIMIT" # shellcheck disable=SC3045
fi MAX_FD=$( ulimit -H -n ) ||
ulimit -n $MAX_FD warn "Could not query maximum file descriptor limit"
if [ $? -ne 0 ] ; then esac
warn "Could not set maximum file descriptor limit: $MAX_FD" case $MAX_FD in #(
fi '' | soft) :;; #(
else *)
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
fi # shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi fi
# For Darwin, add options to specify how the application appears in the dock # Collect all arguments for the java command, stacking in reverse order:
if $darwin; then # * args from the command line
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" # * the main class name
fi # * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin, switch paths to Windows format before running java # For Cygwin or MSYS, switch paths to Windows format before running java
if $cygwin ; then if "$cygwin" || "$msys" ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"` APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition JAVACMD=$( cygpath --unix "$JAVACMD" )
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else # Now convert the arguments - kludge to limit ourselves to /bin/sh
eval `echo args$i`="\"$arg\"" 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 fi
i=$((i+1)) # 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 done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi fi
# Escape application args # Collect all arguments for the java command;
save () { # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done # shell script including quotes and variable substitutions, so put them in
echo " " # double quotes to make sure that they get re-expanded; and
} # * put everything else in single quotes, so that it's not re-expanded.
APP_ARGS=$(save "$@")
set -- \
# Collect all arguments for the java command, following the shell quoting and substitution rules "-Dorg.gradle.appname=$APP_BASE_NAME" \
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong "$@"
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")" # Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi fi
# 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" "$@" exec "$JAVACMD" "$@"
@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 @if "%DEBUG%" == "" @echo off
@rem ########################################################################## @rem ##########################################################################
@rem @rem
...@@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=. ...@@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0 set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% 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. @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= set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe @rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init if "%ERRORLEVEL%" == "0" goto execute
echo. echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
...@@ -35,7 +54,7 @@ goto fail ...@@ -35,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=% set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init if exist "%JAVA_EXE%" goto execute
echo. echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
...@@ -45,28 +64,14 @@ echo location of your Java installation. ...@@ -45,28 +64,14 @@ echo location of your Java installation.
goto fail goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute :execute
@rem Setup the command line @rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle @rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end :end
@rem End local scope for the variables with windows NT shell @rem End local scope for the variables with windows NT shell
......
import java.util.Arrays; import java.util.Arrays;
/** * La classe Vector implémente un tableau d'entiers * de taille dynamique. Les éléments du vecteur sont stockés dans un tableau. * La taille de ce tableau est au minimum doublée à chaque fois qu'il est * nécessaire de le faire grossir. */ /**
* La classe Vector implémente un tableau d'entiers * de taille dynamique. Les éléments du
* vecteur sont stockés dans un tableau. * La taille de ce tableau est au minimum doublée
* à chaque fois qu'il est * nécessaire de le faire grossir.
*/
public class Vector { public class Vector {
/** /**
......
import static junit.framework.TestCase.fail; import org.junit.jupiter.api.Disabled;
import static org.hamcrest.MatcherAssert.assertThat; import org.junit.jupiter.api.Test;
import static org.hamcrest.Matchers.*;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
public class VectorTest { public class VectorTest {
@Test @Test
public void testVectorInt() { @Disabled
void testConstruction_WithAnArgument() {
Vector vector = new Vector(123); Vector vector = new Vector(123);
assertThat(vector.capacity(), equalTo(123)); assertThat(vector.capacity()).isEqualTo(123);
assertThat(vector.size(), equalTo(0)); assertThat(vector.size()).isEqualTo(0);
} }
@Test @Test
public void testVector() { @Disabled
void testConstruction_WithoutAnArgument() {
Vector vector = new Vector(); Vector vector = new Vector();
assertThat(vector.capacity(), equalTo(10)); assertThat(vector.capacity()).isEqualTo(10);
assertThat(vector.size(), equalTo(0)); assertThat(vector.size()).isEqualTo(0);
} }
@Test @Test
@Disabled
public void testEnsureCapacity_CapacityDoubled() { public void testEnsureCapacity_CapacityDoubled() {
Vector vector = new Vector(23); Vector vector = new Vector(23);
vector.ensureCapacity(24); vector.ensureCapacity(24);
assertThat(vector.capacity(), greaterThanOrEqualTo(23*2)); assertThat(vector.capacity()).isGreaterThanOrEqualTo(23 * 2);
} }
@Test @Test
public void testEnsureCapacity_CapacitySatified() { @Disabled
void testEnsureCapacity_CapacitySatisfied() {
Vector vector = new Vector(23); Vector vector = new Vector(23);
vector.ensureCapacity(120); vector.ensureCapacity(120);
/* TODO */ // TODO : add code
fail("not yet implemented"); fail("not yet implemented");
} }
@Test @Test
public void testEnsureCapacity_CapacityAlwaysIncreased() { void testEnsureCapacity_CapacityAlwaysIncreased() {
Vector vector = new Vector(120); Vector vector = new Vector(120);
vector.ensureCapacity(10); vector.ensureCapacity(10);
assertThat(vector.capacity(), equalTo(120)); assertThat(vector.capacity()).isEqualTo(120);
} }
@Test @Test
public void testResize() { @Disabled
void testResize() {
Vector vector = new Vector(); Vector vector = new Vector();
vector.resize(120); vector.resize(120);
/* TODO */ // TODO : add code
fail("not yet implemented"); fail("not yet implemented");
} }
@Test @Test
public void testResize_Zeros() { @Disabled
void testResize_Nulls() {
Vector vector = new Vector(1); Vector vector = new Vector(1);
vector.add(2); vector.add(2);
vector.resize(0); vector.resize(0);
vector.resize(1); vector.resize(1);
assertThat(vector.get(0), equalTo(0)); assertThat(vector.get(0)).isNull();
} }
@Test @Test
public void testResize_CapacityIncreased() { @Disabled
void testResize_CapacityIncreased() {
/* TODO */ /* TODO */
fail("not yet implemented"); fail("not yet implemented");
} }
@Test @Test
public void testResize_CapacityAlwaysIncreased() { @Disabled
/* TODO */ void testResize_CapacityAlwaysIncreased() {
// TODO : add code
fail("not yet implemented"); fail("not yet implemented");
} }
@Test @Test
public void testIsEmpty() { @Disabled
void testIsEmpty() {
Vector vector = new Vector(); Vector vector = new Vector();
assertThat(vector.isEmpty(), equalTo(true)); assertThat(vector.isEmpty()).isTrue();
vector.resize(12); vector.resize(12);
/* TODO */ // TODO : add code
fail("not yet implemented"); fail("not yet implemented");
} }
@Test @Test
public void testAdd() { @Disabled
void testAdd() {
Vector vector = new Vector(); Vector vector = new Vector();
vector.add(12); vector.add(12);
vector.add(13); vector.add(13);
vector.add(10); vector.add(10);
assertThat(vector.size(), equalTo(3)); assertThat(vector.size()).isEqualTo(3);
assertThat(vector.get(0), equalTo(12)); assertThat(vector.get(0)).isEqualTo(12);
assertThat(vector.get(1), equalTo(13)); assertThat(vector.get(1)).isEqualTo(13);
assertThat(vector.get(2), equalTo(10)); assertThat(vector.get(2)).isEqualTo(10);
vector.resize(1); vector.resize(1);
vector.add(2); vector.add(2);
/* TODO */ // TODO : add code
fail("not yet implemented"); fail("not yet implemented");
} }
@Test @Test
public void testSet() { @Disabled
void testSet() {
Vector vector = new Vector(); Vector vector = new Vector();
vector.add(12); vector.add(12);
vector.add(13); vector.add(13);
...@@ -105,17 +117,27 @@ public class VectorTest { ...@@ -105,17 +117,27 @@ public class VectorTest {
vector.set(0, 2); vector.set(0, 2);
vector.set(2, 4); vector.set(2, 4);
vector.set(3, 123); vector.set(3, 123);
/* TODO */ // TODO : add code
fail("not yet implemented"); fail("not yet implemented");
} }
@Test @Test
public void testGet() { @Disabled
void testGet_WhenInRange() {
Vector vector = new Vector(); Vector vector = new Vector();
vector.add(12); vector.add(12);
vector.add(13); vector.add(13);
/* TODO : tester également le fait d'être en dehors des bornes. */ // TODO : add test
fail("not yet implemented"); fail("not yet implemented");
} }
@Test
@Disabled
void testGet_WhenOutsideRange() {
Vector vector = new Vector();
vector.add(12);
vector.add(13);
// TODO : add test for indices outside of the size of the vector
fail("not yet implemented");
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment