dc/tests/test_sqrt
Marco Cetica 9d5aeebef3
All checks were successful
dc / build (push) Successful in 18s
Added support for complex numbers and added logarithm function
2024-04-19 16:14:47 +02:00

25 lines
614 B
Bash

#!/bin/sh
utest() {
PROGRAM="$PWD/build/dc"
EXPECTED="5"
ACTUAL=$("$PROGRAM" -e '25 v p')
assert_eq "$EXPECTED" "$ACTUAL"
# Test empty stack
EXPECTED="'v' requires one operand"
ACTUAL=$("$PROGRAM" -e 'v' 2>&1) || true
assert_eq "$EXPECTED" "$ACTUAL"
# Test non numerical values
EXPECTED="'v' requires numeric values"
ACTUAL=$("$PROGRAM" -e '[ foo ] v' 2>&1) || true
assert_eq "$EXPECTED" "$ACTUAL"
# Test complex number
EXPECTED="(0,1)"
ACTUAL=$("$PROGRAM" -e '-1 v p')
assert_eq "$EXPECTED" "$ACTUAL"
}
# vim: ts=4 sw=4 softtabstop=4 expandtab: