]> pd.if.org Git - zpackage/blobdiff - t/hash.t
cleanup sha256 hash code
[zpackage] / t / hash.t
index c727066d2d46b8f5bb82b1790682fb4269c048a0..342ddefd72611075b28f6f5c6fb0c16cd064209a 100755 (executable)
--- a/t/hash.t
+++ b/t/hash.t
@@ -6,22 +6,31 @@
 
 vtest() {
        res=$(zpm-hash "$1" "$2")
-       okstreq "$res" "$2" "$1 == $2"
+       okstreq "$res" "$2" "$3"
 }
 
-plan 4
+plan 7
 
 printf '' > hash.test
-vtest hash.test e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
+vtest hash.test e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 "empty file"
 printf 'foo\n' > hash.test
-vtest hash.test b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c
+vtest hash.test b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c "one line file"
 
 rm hash.test
 
 res=$(printf 'foo\n' | zpm-hash)
-okstreq $res b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c
+okstreq $res b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c "foo"
 
 res=$(printf 'foo\n' | zpm-hash -)
-okstreq $res b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c
+okstreq $res b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c "foo stdin"
+
+stest() {
+       res=$(printf '%s' $1 | zpm-hash -)
+       okstreq "$res" "$2" "${1:-empty string}"
+}
+
+stest abc ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
+stest '' e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
+stest 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq' '248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1'
 
 finish