65 lines
1.6 KiB
Plaintext
65 lines
1.6 KiB
Plaintext
|
#!/bin/bash
|
||
|
#xcrypted
|
||
|
# Auteur: Pascal Anelli
|
||
|
# adaptation session 2 : Denis Payet
|
||
|
# modification session 3: pascal ANELLI
|
||
|
# version 23 mars 2020
|
||
|
|
||
|
source ${LIBSH}/libeval.sh
|
||
|
|
||
|
#-----------------------------------------
|
||
|
rep=~/Sequence4/A41
|
||
|
challenge=C41Q2
|
||
|
scriptname=delta.sh
|
||
|
exo=$rep/$scriptname
|
||
|
#---------------------------------
|
||
|
|
||
|
# Debut
|
||
|
firstcheck
|
||
|
|
||
|
err="$(mktemp)"
|
||
|
|
||
|
# 1 working
|
||
|
$exo 8 22 12 2>$err 1>/dev/null
|
||
|
[ $? -eq 0 -a ! -s "$err" ]
|
||
|
step $(vraifaux $?) "Le script fonctionne sans erreur " true
|
||
|
|
||
|
# 2 display
|
||
|
number=$($exo 8 22 12 2>/dev/null)
|
||
|
[ -n "$number" ]
|
||
|
step $(vraifaux $?) "Le resultat est affiche " true
|
||
|
|
||
|
# 3 is integer
|
||
|
isinteger "$number"
|
||
|
step $(vraifaux $?) "Le resultat est un entier " true
|
||
|
|
||
|
# 4 accuracy
|
||
|
typeset -i dis="$number"
|
||
|
[ "$dis" -eq 100 ]
|
||
|
step $(vraifaux $?) "Le calcul est correct "
|
||
|
|
||
|
# 5 arguments missing : error code
|
||
|
$exo &>/dev/null
|
||
|
[ $? -eq 1 ]
|
||
|
step $(vraifaux $?) "Code erreur genere en cas d'absence des arguments "
|
||
|
|
||
|
# 6-8 arguments missing: error message
|
||
|
$exo 2>&1 | grep -q -i "Erreur" >/dev/null
|
||
|
step $(vraifaux $?) "Affichage 'Erreur' en cas d'absence de l'argument A"
|
||
|
|
||
|
$exo 8 2>&1 | grep -q -i "Erreur" >/dev/null
|
||
|
step $(vraifaux $?) "Affichage 'Erreur' en cas d'absence de l'argument B"
|
||
|
|
||
|
$exo 8 22 2>&1 | grep -q -i "Erreur" >/dev/null
|
||
|
step $(vraifaux $?) "Affichage 'Erreur' en cas d'absence de l'argument C"
|
||
|
|
||
|
|
||
|
#--------------------------------
|
||
|
# Fin
|
||
|
status "${challenge}_$res"
|
||
|
exit 0
|
||
|
|
||
|
|
||
|
# listcode = [ '000', 'ec4', 'c37', 'a71', '7c6', '919', '253', 'b16', '39a' ]
|
||
|
|