|
| 1 | +#!/bin/sh |
| 2 | +# |
| 3 | +# Copyright (c) 2016 Christian Couder |
| 4 | +# MIT Licensed; see the LICENSE file in this repository. |
| 5 | +# |
| 6 | + |
| 7 | +test_description="sha2 tests" |
| 8 | + |
| 9 | +. lib/test-lib.sh |
| 10 | + |
| 11 | +test_expect_success "setup sha2 tests" ' |
| 12 | + echo "Hash me!" >hash_me.txt && |
| 13 | + SHA256=c16bdce7e126ff8e241a9893ccd908c292cd0e54c403145326eb0c567071a613 && |
| 14 | + SHA512=4c4a59a7d958cff035eb7d752b319b90337037e352b89d58aa5be29ef051ea0a565133781aa3279384654274c4786893287ea8037f0a1a15d9b40ea0bc4be73c && |
| 15 | + echo "1220$SHA256" >expected256 && |
| 16 | + echo "1340$SHA512" >expected512 |
| 17 | +' |
| 18 | + |
| 19 | +test_expect_success "'multihash -a=sha2-256 -e=hex' works" ' |
| 20 | + multihash -a=sha2-256 -e=hex hash_me.txt >actual256 |
| 21 | +' |
| 22 | + |
| 23 | +test_expect_success "'multihash -a=sha2-256 -e=hex' output looks good" ' |
| 24 | + test_cmp expected256 actual256 |
| 25 | +' |
| 26 | + |
| 27 | +test_expect_success "'multihash -a=sha2-512 -e=hex' works" ' |
| 28 | + multihash -a=sha2-512 -e=hex hash_me.txt >actual512 |
| 29 | +' |
| 30 | + |
| 31 | +test_expect_success "'multihash -a=sha2-512 -e=hex' output looks good" ' |
| 32 | + test_cmp expected512 actual512 |
| 33 | +' |
| 34 | + |
| 35 | +test_expect_success SHA256SUM "check sha2-256 hash using '$SHA256SUMBIN'" ' |
| 36 | + echo "$SHA256 hash_me.txt" >expected && |
| 37 | + $SHA256SUMBIN hash_me.txt >actual && |
| 38 | + test_cmp expected actual |
| 39 | +' |
| 40 | + |
| 41 | +test_expect_success SHA512SUM "check sha2-512 hash using '$SHA512SUMBIN'" ' |
| 42 | + echo "$SHA512 hash_me.txt" >expected && |
| 43 | + $SHA512SUMBIN hash_me.txt >actual && |
| 44 | + test_cmp expected actual |
| 45 | +' |
| 46 | + |
| 47 | +test_done |
0 commit comments