Added tests for input/output and radix commands(i/I,o/O,k/K)
All checks were successful
dc / build (push) Successful in 35s
All checks were successful
dc / build (push) Successful in 35s
This commit is contained in:
parent
e61a7debfa
commit
5d65d4f3b1
19
tests/test_fix
Normal file
19
tests/test_fix
Normal file
@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
utest() {
|
||||
PROGRAM="$PWD/build/dc"
|
||||
EXPECTED="3.14159"
|
||||
ACTUAL=$("$PROGRAM" -e '5 k pi p')
|
||||
assert_eq "$EXPECTED" "$ACTUAL"
|
||||
|
||||
# Test default precision
|
||||
EXPECTED="0"
|
||||
ACTUAL=$("$PROGRAM" -e 'K p')
|
||||
assert_eq "$EXPECTED" "$ACTUAL"
|
||||
|
||||
# Test invalid precision
|
||||
EXPECTED="Precision must be a non-negative number"
|
||||
ACTUAL=$("$PROGRAM" -e '-1 k' 2>&1) || true
|
||||
assert_eq "$EXPECTED" "$ACTUAL"
|
||||
}
|
||||
# vim: ts=4 sw=4 softtabstop=4 expandtab:
|
21
tests/test_irdx
Normal file
21
tests/test_irdx
Normal file
@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
|
||||
utest() {
|
||||
PROGRAM="$PWD/build/dc"
|
||||
|
||||
# Test default input base
|
||||
EXPECTED="10"
|
||||
ACTUAL=$("$PROGRAM" -e 'I p')
|
||||
assert_eq "$EXPECTED" "$ACTUAL"
|
||||
|
||||
# Test new, valid input base
|
||||
EXPECTED="10"
|
||||
ACTUAL=$("$PROGRAM" -e '2 i 1010 p')
|
||||
assert_eq "$EXPECTED" "$ACTUAL"
|
||||
|
||||
# Test new, invalid input base
|
||||
EXPECTED="Input base must be a number within the range 2-16(inclusive)"
|
||||
ACTUAL=$("$PROGRAM" -e '1 i' 2>&1) || true
|
||||
assert_eq "$EXPECTED" "$ACTUAL"
|
||||
}
|
||||
# vim: ts=4 sw=4 softtabstop=4 expandtab:
|
21
tests/test_ordx
Normal file
21
tests/test_ordx
Normal file
@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
|
||||
utest() {
|
||||
PROGRAM="$PWD/build/dc"
|
||||
|
||||
# Test default output base
|
||||
EXPECTED="10"
|
||||
ACTUAL=$("$PROGRAM" -e 'O p')
|
||||
assert_eq "$EXPECTED" "$ACTUAL"
|
||||
|
||||
# Test new, valid output base
|
||||
EXPECTED="Fh"
|
||||
ACTUAL=$("$PROGRAM" -e '16 o 15 p')
|
||||
assert_eq "$EXPECTED" "$ACTUAL"
|
||||
|
||||
# Test new, invalid output base
|
||||
EXPECTED="'o' accepts either BIN, OCT, DEC or HEX bases"
|
||||
ACTUAL=$("$PROGRAM" -e '9 o' 2>&1) || true
|
||||
assert_eq "$EXPECTED" "$ACTUAL"
|
||||
}
|
||||
# vim: ts=4 sw=4 softtabstop=4 expandtab:
|
Loading…
Reference in New Issue
Block a user