-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhashpipe256-test.sh
executable file
·56 lines (44 loc) · 1.71 KB
/
hashpipe256-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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/sh
# @author Andreas Fischer <[email protected]>
# @copyright 2014 Andreas Fischer
# @license http://www.opensource.org/licenses/mit-license.html MIT License
CURDIR=$(dirname "$0")
TARGET="$CURDIR/hashpipe256.sh"
SCRATCH_DIR="/tmp/hashpipe-tests"
SCRATCH_FILENAME="hashpipe-test-output.test"
SCRATCH_FILENAME_HASH="$SCRATCH_FILENAME.sha256"
oneTimeSetUp() {
mkdir -p "$SCRATCH_DIR"
}
oneTimeTearDown() {
rm -rf "$SCRATCH_DIR"
}
tearDown() {
find "$CURDIR" -type f -name "$SCRATCH_FILENAME*" -delete
find "$SCRATCH_DIR" -type f -name "$SCRATCH_FILENAME*" -delete
}
testRelativeFile() {
EXPECTED_CONTENT="The quick brown fox jumps over the lazy dog"
echo -n "$EXPECTED_CONTENT" | "$TARGET" "$SCRATCH_FILENAME"
assertSame \
"Failed asserting that the output file contains the expected content" \
"$EXPECTED_CONTENT" \
"$(cat "$SCRATCH_FILENAME")"
assertSame \
"Failed asserting that the hash file contains the expected content" \
"d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592 $SCRATCH_FILENAME" \
"$(cat "$SCRATCH_FILENAME_HASH")"
}
testAbsoluteFile() {
EXPECTED_CONTENT="The quick brown fox jumps over the lazy dog."
echo -n "$EXPECTED_CONTENT" | "$TARGET" "$SCRATCH_DIR/$SCRATCH_FILENAME"
assertSame \
"Failed asserting that the output file contains the expected content" \
"$EXPECTED_CONTENT" \
"$(cat "$SCRATCH_DIR/$SCRATCH_FILENAME")"
assertSame \
"Failed asserting that the hash file contains the expected content" \
"ef537f25c895bfa782526529a9b63d97aa631564d5d789c2b765448c8635fb6c $SCRATCH_FILENAME" \
"$(cat "$SCRATCH_DIR/$SCRATCH_FILENAME_HASH")"
}
. "$CURDIR/shunit2-2.1.6/src/shunit2"