3
0

sum.tests 818 B

123456789101112131415161718192021222324
  1. #!/bin/sh
  2. # unit test for sum.
  3. # Copyright 2007 by Bernhard Fischer
  4. # Licensed under GPL v2 or later, see file LICENSE for details.
  5. # AUDIT: Unit tests for sum
  6. . testing.sh
  7. # testing "test name" "options" "expected result" "file input" "stdin"
  8. # file input will be file called "input"
  9. # test can create a file "actual" instead of writing to stdout
  10. testing "sum -r file doesn't print file's name" \
  11. "sum -r $0 | grep -c $0 && echo wrongly_printed_filename || echo yes" \
  12. "0\nyes\n" "" ""
  13. testing "sum -r file file does print both names" \
  14. "sum -r $0 $0 | grep -c $0 && echo yes || echo wrongly_omitted_filename" \
  15. "2\nyes\n" "" ""
  16. testing "sum -s file does print file's name" \
  17. "sum -s $0 | grep -c $0 && echo yes || echo wrongly_omitted_filename" \
  18. "1\nyes\n" "" ""
  19. exit $FAILCOUNT