box-o-sand/lcthw-remnants/test_ex17.sh

56 lines
1.2 KiB
Bash
Raw Normal View History

#!/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