Des scripts pour imprimer les données dans TSV sous la forme d'un layout prédéfini - retour accueil
git clone git://bebou.netlib.re/tsv2layout
Log | Files | Refs | README |
commit c7f0e8c8ff89d5a6f39fb25b53672dc94db2dc09 parent ebb3d50f9efe33b761f572f5ddaa34e19ae74da3 Auterice: Arthur Pons <arthur.pons@unistra.fr> Date: Thu, 19 Sep 2024 16:42:24 +0200 Ajout des tests pour la version heredoc faire tests/test.sh pour les lancer Diffstat:
A | tests/data | | | 11 | +++++++++++ |
A | tests/layout.heredoc | | | 8 | ++++++++ |
A | tests/reference.heredoc | | | 40 | ++++++++++++++++++++++++++++++++++++++++ |
A | tests/test.sh | | | 24 | ++++++++++++++++++++++++ |
4 files changed, 83 insertions(+), 0 deletions(-)
diff --git a/tests/data b/tests/data @@ -0,0 +1,11 @@ +index firstname lastname email dateofbirth jobtitle +1 Shelby Terrell elijah57@example.net 1945-10-26 Games developer +2 a Summers bethany14@example.com 1910-03-24 a +3 Kristine Travis bthompson@example.com 1992-07-02 Homeopath +4 Yesenia s kaitlinkaiser@example.com 2017-08-03 Market researcher +5 Lori Todd buchananmanuel@example.net a Veterinary surgeon +6 Erin Day tconner@example.org 2015-10-28 Waste management officer +7 Katherine Buck conniecowan@example.com 1989-01-22 Intelligence analyst +8 Ricardo Hinton wyattbishop@example.com 1924-03-26 Hydrogeologist +9 Dave Farrell s 2018-10-06 Lawyer +10 Isaiah Downs virginiaterrell@example.org 1964-09-20 Engineer, site diff --git a/tests/layout.heredoc b/tests/layout.heredoc @@ -0,0 +1,8 @@ +<<@ cat +[${index:-?}] +$firstname $lastname +mailto:$email +$( [ -n "$jobtitle" ] \ +&& echo "Born on $dateofbirth, is a $jobtitle" \ +|| echo "Born on $dateofbirth, job unknown") +@ diff --git a/tests/reference.heredoc b/tests/reference.heredoc @@ -0,0 +1,40 @@ +[1] +Shelby Terrell +mailto:elijah57@example.net +Born on 1945-10-26, is a Games developer +[?] + Summers +mailto:bethany14@example.com +Born on 1910-03-24, job unknown +[3] +Kristine Travis +mailto:bthompson@example.com +Born on 1992-07-02, is a Homeopath +[4] +Yesenia +mailto:kaitlinkaiser@example.com +Born on 2017-08-03, is a Market researcher +[5] +Lori Todd +mailto:buchananmanuel@example.net +Born on , is a Veterinary surgeon +[6] +Erin Day +mailto:tconner@example.org +Born on 2015-10-28, is a Waste management officer +[7] +Katherine Buck +mailto:conniecowan@example.com +Born on 1989-01-22, is a Intelligence analyst +[8] +Ricardo Hinton +mailto:wyattbishop@example.com +Born on 1924-03-26, is a Hydrogeologist +[9] +Dave Farrell +mailto: +Born on 2018-10-06, is a Lawyer +[10] +Isaiah Downs +mailto:virginiaterrell@example.org +Born on 1964-09-20, is a Engineer, site diff --git a/tests/test.sh b/tests/test.sh @@ -0,0 +1,24 @@ +#! /bin/sh + +red="\033[91m" +green="\033[92m" +norm="\033[0m" + +_die() { echo "$red$@$norm" >&2 ;return 1; } + +_success() echo "$green$@$norm" >&2 + +issame() { + diff -q "$1" "$2" +} + +tmpd=$(mktemp -d) +trap "rm -rf $tmpd" EXIT + +< tests/data ./tsv2layout tests/layout.heredoc > $tmpd/1 +#< tests/data ./tsv2layout.printf2 tests/layout.printf > $tmpd/2 + +issame tests/reference.heredoc $tmpd/1 \ + && _success "printlayout test passed" \ + || _die "printlayout test failed" +