Skip to content

Commit

Permalink
wip,test: add rounding test case
Browse files Browse the repository at this point in the history
Added two test cases from the discussion gunnarmorling#5 (comment)

Neither all implementations match baseline nor they match precise value of `33.6+31.7+21.9+14.6=25.5`:
```
$ ./test_all.sh src/test/resources/samples/measurements-rounding-baseline.txt 2>/dev/null | tee /tmp/rounding-baseline.log
FAIL armandino
FAIL artsiomkorzun
PASS baseline
PASS bjhara
PASS criccomini
FAIL ddimtirov
FAIL ebarlas
FAIL filiphr
FAIL itaske
PASS jgrateron
FAIL khmarbaise
FAIL kuduwa-keshavram
PASS lawrey
PASS moysesb
FAIL nstng
PASS padreati
FAIL palmr
PASS richardstartin
FAIL royvanrijn
PASS seijikun
PASS spullara
PASS truelive

$ ./test_all.sh src/test/resources/samples/measurements-rounding-precise.txt 2>/dev/null | tee /tm
p/rounding-precise.log
PASS armandino
PASS artsiomkorzun
FAIL baseline
FAIL bjhara
FAIL criccomini
FAIL ddimtirov
PASS ebarlas
PASS filiphr
FAIL itaske
FAIL jgrateron
PASS khmarbaise
FAIL kuduwa-keshavram
FAIL lawrey
FAIL moysesb
PASS nstng
FAIL padreati
PASS palmr
FAIL richardstartin
PASS royvanrijn
FAIL seijikun
FAIL spullara
FAIL truelive

$ git --no-pager diff --word-diff /tmp/rounding-baseline.log /tmp/rounding-precise.log
diff --git a/tmp/rounding-baseline.log b/tmp/rounding-precise.log
index 76d5b4e..495fb00 100644
--- a/tmp/rounding-baseline.log
+++ b/tmp/rounding-precise.log
@@ -1,22 +1,22 @@
[-FAIL-]{+PASS+} armandino[-FAIL artsiomkorzun-]
PASS {+artsiomkorzun+}
{+FAIL+} baseline
[-PASS-]{+FAIL+} bjhara
[-PASS-]{+FAIL+} criccomini
FAIL ddimtirov
[-FAIL-]{+PASS+} ebarlas
[-FAIL-]{+PASS+} filiphr
FAIL itaske
[-PASS jgrateron-]FAIL {+jgrateron+}
{+PASS+} khmarbaise
FAIL kuduwa-keshavram
[-PASS-]{+FAIL+} lawrey[-PASS moysesb-]
FAIL [-nstng-]{+moysesb+}
PASS [-padreati-]{+nstng+}
FAIL [-palmr-]{+padreati+}
PASS [-richardstartin-]{+palmr+}
FAIL [-royvanrijn-]{+richardstartin+}
PASS {+royvanrijn+}
{+FAIL+} seijikun
[-PASS-]{+FAIL+} spullara
[-PASS-]{+FAIL+} truelive
```

For gunnarmorling#49
  • Loading branch information
AlexanderYastrebov committed Jan 4, 2024
1 parent 951c06e commit 107ca23
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{Rounding=14.6/25.4/33.6}
4 changes: 4 additions & 0 deletions src/test/resources/samples/measurements-rounding-baseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Rounding;33.6
Rounding;31.7
Rounding;21.9
Rounding;14.6
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{Rounding=14.6/25.5/33.6}
4 changes: 4 additions & 0 deletions src/test/resources/samples/measurements-rounding-precise.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Rounding;33.6
Rounding;31.7
Rounding;21.9
Rounding;14.6
2 changes: 1 addition & 1 deletion test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if [ -z "$1" ]; then
exit 1
fi

for sample in $(ls src/test/resources/samples/*.txt); do
for sample in $(ls "$2"); do
echo "Validating calculate_average_$1.sh -- $sample"

rm -f measurements.txt
Expand Down
2 changes: 1 addition & 1 deletion test_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ for impl in $(ls calculate_average_*.sh | sort); do
noext="${impl%%.sh}"
name=${noext##calculate_average_}

if output=$(./test.sh "$name" 2>&1); then
if output=$(./test.sh "$name" "$1" 2>&1); then
echo "PASS $name"
else
echo "FAIL $name"
Expand Down

0 comments on commit 107ca23

Please sign in to comment.