box-o-sand/lcthw-remnants/test_ex17.sh
Dan Buch f2380eef05 Add 'lcthw-remnants/' from commit 'e172f73c8297b22a579c94558f0c171ca74a0e5c'
git-subtree-dir: lcthw-remnants
git-subtree-mainline: 4107485591
git-subtree-split: e172f73c82
2013-01-09 23:42:19 -05:00

56 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
source './test.sh'
prog=${1-'./ex17'}
test_db=db.$$.$RANDOM.dat
# ----------------------------------------------------------------------------
$prog 2>&1 >/dev/null
assert_equal $? 1
$prog $test_db c 2>&1 >/dev/null
assert_equal $? 0
$prog $test_db s 2>&1 >/dev/null
assert_equal $? 1
$prog $test_db s 1 ham ham@foo.bar
assert_equal $? 0
$prog $test_db s 2 derp derp@foo.bar
assert_equal $? 0
$prog $test_db s 3 herp herp@foo.bar
assert_equal $? 0
$prog $test_db s 4 zap zap@foo.bar
assert_equal $? 0
$prog $test_db l > $$.out
grep '1 ham ham@foo.bar' $$.out >/dev/null
assert_equal $? 0
$prog $test_db l > $$.out
grep '2 derp derp@foo.bar' $$.out >/dev/null
assert_equal $? 0
$prog $test_db l > $$.out
grep '3 herp herp@foo.bar' $$.out >/dev/null
assert_equal $? 0
$prog $test_db l > $$.out
grep '4 zap zap@foo.bar' $$.out >/dev/null
assert_equal $? 0
$prog $test_db g 1 > $$.out
grep '1 ham ham@foo.bar' $$.out >/dev/null
assert_equal $? 0
$prog $test_db d 1
$prog $test_db l > $$.out
grep 'ham@foo.bar' $$.out >/dev/null
assert_not_equal $? 0
# ----------------------------------------------------------------------------
rm -f $$.out
rm -f $test_db
test_finish