sox_ng/test/bit-depth/run
Martin Guy 079165645a test/bit-depth: Ensure helper program "samples" has been built
To avoid phantom failures when running check.sh in test/
instead of "make check"
2026-05-27 13:44:52 +02:00

78 lines
1.3 KiB
Bash

#! /bin/sh
# https://sourceforge.net/p/sox/bugs/267
# https://sourceforge.net/p/sox/code/merge-requests/1
status=0
# Ensure the helper program has been built
test -x ../samples || (
cd ..
make samples
)
# Test routine takes two parameters:
# - the expected result if it is considered as a mono 16-bit signal
# - a list of 16-bit samples in decimal
testCase() {
expected="$1"; shift
got="`../samples "$@" | \
${sox:-sox} -t raw -e signed -b 16 -L -r 48000 - -n stats 2>&1 | \
grep Bit-depth | awk '{print $2}'`"
if [ "$got" != "$expected" ]
then
echo "Expected $expected, got $got for $@"
status=2
fi
}
testCase 0/0 0
testCase 2/16 1
testCase 1/16 -1
testCase 2/15 2
testCase 1/15 -2
testCase 16/16 32767
testCase 16/16 -32767
testCase 16/16 32767 -32767
testCase 13/16 2765
testCase 9/16 129
testCase 13/16 -2765
testCase 9/16 -129
testCase 13/16 2765 -2765
testCase 9/16 129 -129
testCase 4/15 2 4 6 8
testCase 3/15 2 -4 6 -8
testCase 4/15 -2 4 -6 8
testCase 2/2 16384
testCase 2/3 8192
testCase 2/15 2
testCase 2/16 1
testCase 1/2 -16384
testCase 1/3 -8192
testCase 1/15 -2
testCase 1/16 -1
testCase 2/15 2 -2
testCase 7/15 -2 100
testCase 7/15 2 100
testCase 2/16 -2 1
testCase 1/1 -32768
testCase 1/1 -32768 0
testCase 16/16 -32768 1
testCase 15/15 -32768 2
testCase 14/14 -32768 12
exit $status