2007-01-28 03:37:54 +05:30
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# unit test for sum.
|
2008-09-25 17:43:34 +05:30
|
|
|
# Copyright 2007 by Bernhard Reutner-Fischer
|
2010-08-16 23:44:46 +05:30
|
|
|
# Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
2007-01-28 03:37:54 +05:30
|
|
|
|
|
|
|
# AUDIT: Unit tests for sum
|
|
|
|
|
2009-11-05 05:11:22 +05:30
|
|
|
. ./testing.sh
|
2007-01-28 03:37:54 +05:30
|
|
|
|
|
|
|
# testing "test name" "options" "expected result" "file input" "stdin"
|
|
|
|
# file input will be file called "input"
|
|
|
|
# test can create a file "actual" instead of writing to stdout
|
|
|
|
|
|
|
|
testing "sum -r file doesn't print file's name" \
|
2018-02-09 15:22:52 +05:30
|
|
|
"sum -r '$0' | grep -c '$0' && echo wrongly_printed_filename || echo yes" \
|
2007-01-28 03:37:54 +05:30
|
|
|
"0\nyes\n" "" ""
|
|
|
|
testing "sum -r file file does print both names" \
|
2018-02-09 15:22:52 +05:30
|
|
|
"sum -r '$0' '$0' | grep -c '$0' && echo yes || echo wrongly_omitted_filename" \
|
2007-01-28 03:37:54 +05:30
|
|
|
"2\nyes\n" "" ""
|
|
|
|
testing "sum -s file does print file's name" \
|
2018-02-09 15:22:52 +05:30
|
|
|
"sum -s '$0' | grep -c '$0' && echo yes || echo wrongly_omitted_filename" \
|
2007-01-28 03:37:54 +05:30
|
|
|
"1\nyes\n" "" ""
|
|
|
|
exit $FAILCOUNT
|