aboutsummaryrefslogtreecommitdiff
path: root/tests/bc.test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/bc.test')
-rw-r--r--tests/bc.test72
1 files changed, 72 insertions, 0 deletions
diff --git a/tests/bc.test b/tests/bc.test
new file mode 100644
index 00000000..213b21ab
--- /dev/null
+++ b/tests/bc.test
@@ -0,0 +1,72 @@
+#!/bin/bash
+
+[ -f testing.sh ] && . testing.sh
+
+#testing "name" "command" "result" "infile" "stdin"
+
+BDIR="$FILES/bc"
+TESTDIR="./"
+
+results=$(cat "$BDIR/decimal_results.txt")
+testcmd "decimal" "-l $BDIR/decimal.txt" "$results\n" "$BDIR/decimal.txt" ""
+
+results=$(cat "$BDIR/add_results.txt")
+testcmd "add" "-l $BDIR/add.txt" "$results\n" "$BDIR/add.txt" ""
+
+results=$(cat "$BDIR/subtract_results.txt")
+testcmd "subtract" "-l $BDIR/subtract.txt" "$results\n" "$BDIR/subtract.txt" ""
+
+results=$(cat "$BDIR/multiply_results.txt")
+testcmd "multiply" "-l $BDIR/multiply.txt" "$results\n" "$BDIR/multiply.txt" ""
+
+results=$(cat "$BDIR/divide_results.txt")
+testcmd "divide" "-l $BDIR/divide.txt" "$results\n" "$BDIR/divide.txt" ""
+
+results=$(cat "$BDIR/modulus_results.txt")
+testcmd "modulus" "-l $BDIR/modulus.txt" "$results\n" "$BDIR/modulus.txt" ""
+
+results=$(cat "$BDIR/power_results.txt")
+testcmd "power" "-l $BDIR/power.txt" "$results\n" "$BDIR/power.txt" ""
+
+results=$(cat "$BDIR/sqrt_results.txt")
+testcmd "sqrt" "-l $BDIR/sqrt.txt" "$results\n" "$BDIR/sqrt.txt" ""
+
+results=$(cat "$BDIR/basic_results.txt")
+testcmd "basic" "-l $BDIR/basic.txt" "$results\n" "$BDIR/basic.txt" ""
+
+if [ ! -f "$TESTDIR/parse.txt" ]; then
+ echo "Generating bc parse..."
+ cat "$BDIR/parse.bc" | bc -l > "$TESTDIR/parse.txt"
+fi
+results=$(cat "$TESTDIR/parse.txt" | bc -l)
+testcmd "parse" "-l $TESTDIR/parse.txt" "$results\n" "$TESTDIR/parse.txt" ""
+
+if [ ! -f "$TESTDIR/print.txt" ]; then
+ echo "Generating bc print..."
+ cat "$BDIR/print.bc" | bc -l > "$TESTDIR/print.txt"
+fi
+results=$(cat "$TESTDIR/print.txt" | bc -l)
+testcmd "print" "-l $TESTDIR/print.txt" "$results\n" "$TESTDIR/print.txt" ""
+
+results=$(cat "$BDIR/pi.txt" | bc -l)
+testcmd "pi" "-l $BDIR/pi.txt" "$results\n" "$BDIR/pi.txt" ""
+
+if [ ! -f "$TESTDIR/arctan.txt" ]; then
+ echo "Generating bc arctan..."
+ cat "$BDIR/arctan.bc" | bc -l > "$TESTDIR/arctan.txt"
+fi
+results=$(cat "$TESTDIR/arctan.txt" | bc -l)
+testcmd "arctan" "-l $TESTDIR/arctan.txt" "$results\n" "$TESTDIR/arctan.txt" ""
+
+results=$(cat "$TESTDIR/arctan.txt")
+testcmd "arctan script" "-l $BDIR/arctan.bc" "$results" "$BDIR/arctan.bc" ""
+
+results=$(cat "$TESTDIR/parse.txt")
+testcmd "parse script" "-l $BDIR/parse.bc" "$results\n" "$BDIR/parse.bc" ""
+
+results=$(cat "$TESTDIR/print.txt")
+testcmd "print script" "-l $BDIR/print.bc" "$results\n" "$BDIR/print.bc" ""
+
+results=$(cat "$BDIR/screen.bc" | bc -l)
+testcmd "screen script" "-l $BDIR/screen.bc" "$results\n" "$BDIR/screen.bc" ""
+