Bernhard Reutner-Fischer | 14813c5 | 2007-01-27 22:07:54 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # unit test for sum. |
Bernhard Reutner-Fischer | 6c4dade | 2008-09-25 12:13:34 +0000 | [diff] [blame] | 4 | # Copyright 2007 by Bernhard Reutner-Fischer |
Denys Vlasenko | 0ef64bd | 2010-08-16 20:14:46 +0200 | [diff] [blame] | 5 | # Licensed under GPLv2 or later, see file LICENSE in this source tree. |
Bernhard Reutner-Fischer | 14813c5 | 2007-01-27 22:07:54 +0000 | [diff] [blame] | 6 | |
| 7 | # AUDIT: Unit tests for sum |
| 8 | |
Mike Frysinger | caa7940 | 2009-11-04 18:41:22 -0500 | [diff] [blame] | 9 | . ./testing.sh |
Bernhard Reutner-Fischer | 14813c5 | 2007-01-27 22:07:54 +0000 | [diff] [blame] | 10 | |
| 11 | # testing "test name" "options" "expected result" "file input" "stdin" |
| 12 | # file input will be file called "input" |
| 13 | # test can create a file "actual" instead of writing to stdout |
| 14 | |
| 15 | testing "sum -r file doesn't print file's name" \ |
Ron Yorston | 1f27fa9 | 2018-02-09 09:52:52 +0000 | [diff] [blame] | 16 | "sum -r '$0' | grep -c '$0' && echo wrongly_printed_filename || echo yes" \ |
Bernhard Reutner-Fischer | 14813c5 | 2007-01-27 22:07:54 +0000 | [diff] [blame] | 17 | "0\nyes\n" "" "" |
| 18 | testing "sum -r file file does print both names" \ |
Ron Yorston | 1f27fa9 | 2018-02-09 09:52:52 +0000 | [diff] [blame] | 19 | "sum -r '$0' '$0' | grep -c '$0' && echo yes || echo wrongly_omitted_filename" \ |
Bernhard Reutner-Fischer | 14813c5 | 2007-01-27 22:07:54 +0000 | [diff] [blame] | 20 | "2\nyes\n" "" "" |
| 21 | testing "sum -s file does print file's name" \ |
Ron Yorston | 1f27fa9 | 2018-02-09 09:52:52 +0000 | [diff] [blame] | 22 | "sum -s '$0' | grep -c '$0' && echo yes || echo wrongly_omitted_filename" \ |
Bernhard Reutner-Fischer | 14813c5 | 2007-01-27 22:07:54 +0000 | [diff] [blame] | 23 | "1\nyes\n" "" "" |
| 24 | exit $FAILCOUNT |