forked from koraa/huniq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
33 lines (25 loc) · 583 Bytes
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#! /bin/bash
cd "$(dirname "$0")"
bin="./target/debug/huniq"
failures=0
count=0
assert() {
local desc="$1"; shift
local ref="$1"; shift
(( count++ ))
diff <(eval "$@") "$ref" >/dev/null || {
echo >&2 "Assertion failed \"$desc\": \`$@\`"
diff <(eval "$@") "$ref" >&2
(( failures++ ))
}
}
main() {
test -e "$huniq2bin" || {
cargo build
}
assert uniq test/expect_uniq.txt "$bin <test/input.txt"
assert count test/expect_count.txt "$bin -c <test/input.txt | sort -nr"
echo >&2 "$count tests $failures failures"
test "$failures" -eq 0
}
main