diff tests/test-jams-writer/test-jams-writer.sh @ 204:1f8fef5c6ea2

Add digits option to JAMS output, for number of sig figs
author Chris Cannam
date Tue, 03 Nov 2015 11:36:24 +0000
parents f35bbb3e4d41
children c17b184c16db
line wrap: on
line diff
--- a/tests/test-jams-writer/test-jams-writer.sh	Tue Nov 03 11:36:00 2015 +0000
+++ b/tests/test-jams-writer/test-jams-writer.sh	Tue Nov 03 11:36:24 2015 +0000
@@ -5,6 +5,7 @@
 tmpjson=$mypath/tmp_1_$$.json
 
 silentfile=$audiopath/20sec-silence.wav
+infile=$audiopath/3clicks8.wav
 
 trap "rm -f $tmpjson" 0
 
@@ -12,7 +13,7 @@
 
 mandatory="-w jams"
 
-# This does not yet test for correct values, only for parseable json
+# First check that the JSON is valid for all outputs
 
 for output in instants curve-oss curve-fsr curve-fsr-timed curve-vsr grid-oss grid-fsr notes-regions; do
 
@@ -20,5 +21,32 @@
 	fail "Failed to run for plugin $testplug with output $output"
 
     check_json "$tmpjson" "test plugin output $output"
+
 done
 
+# Now check for valid results, for a subset
+
+for output in instants curve-fsr grid-oss notes-regions; do
+
+    $r -d "$testplug:$output" $mandatory --jams-one-file "$tmpjson" --jams-force "$silentfile" 2>/dev/null || \
+	fail "Failed to run for plugin $testplug with output $output"
+
+    expected="$mypath/expected/$output.json"
+    jsoncompare "$tmpjson" "$expected" || \
+	faildiff "Output differs from expected for $output" "$tmpjson" "$expected"
+
+done
+
+# Test digits option, with an output that has lots of digits to round
+
+for digits in 0 6 2; do
+
+    $r -t "$transformdir/af.n3" $mandatory --jams-digits "$digits" --jams-one-file "$tmpjson" --jams-force "$infile" 2>/dev/null || \
+	fail "Failed to run for af with digits = $digits"
+
+    expected="$mypath/expected/af-$digits.json"
+    jsoncompare "$tmpjson" "$expected" || \
+	faildiff "Output differs from expected for af with digits = $digits" "$tmpjson" "$expected"
+
+done
+