blob: e6379349f20581612ce1038a977d68f76f75ef94 [file] [log] [blame]
Bernhard Reutner-Fischer14813c52007-01-27 22:07:54 +00001#!/bin/sh
2
3# unit test for sum.
Bernhard Reutner-Fischer6c4dade2008-09-25 12:13:34 +00004# Copyright 2007 by Bernhard Reutner-Fischer
Denys Vlasenko0ef64bd2010-08-16 20:14:46 +02005# Licensed under GPLv2 or later, see file LICENSE in this source tree.
Bernhard Reutner-Fischer14813c52007-01-27 22:07:54 +00006
7# AUDIT: Unit tests for sum
8
Mike Frysingercaa79402009-11-04 18:41:22 -05009. ./testing.sh
Bernhard Reutner-Fischer14813c52007-01-27 22:07:54 +000010
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
15testing "sum -r file doesn't print file's name" \
Ron Yorston1f27fa92018-02-09 09:52:52 +000016 "sum -r '$0' | grep -c '$0' && echo wrongly_printed_filename || echo yes" \
Bernhard Reutner-Fischer14813c52007-01-27 22:07:54 +000017 "0\nyes\n" "" ""
18testing "sum -r file file does print both names" \
Ron Yorston1f27fa92018-02-09 09:52:52 +000019 "sum -r '$0' '$0' | grep -c '$0' && echo yes || echo wrongly_omitted_filename" \
Bernhard Reutner-Fischer14813c52007-01-27 22:07:54 +000020 "2\nyes\n" "" ""
21testing "sum -s file does print file's name" \
Ron Yorston1f27fa92018-02-09 09:52:52 +000022 "sum -s '$0' | grep -c '$0' && echo yes || echo wrongly_omitted_filename" \
Bernhard Reutner-Fischer14813c52007-01-27 22:07:54 +000023 "1\nyes\n" "" ""
24exit $FAILCOUNT