From 429656bc4149b8d682cbc3a0f5dce21c419db74f Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Sat, 30 Aug 2014 21:54:46 -0500 Subject: [PATCH] Add unit tests for nvm_checksum. --- test/fast/Unit tests/nvm_checksum | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 test/fast/Unit tests/nvm_checksum diff --git a/test/fast/Unit tests/nvm_checksum b/test/fast/Unit tests/nvm_checksum new file mode 100755 index 0000000..408659b --- /dev/null +++ b/test/fast/Unit tests/nvm_checksum @@ -0,0 +1,18 @@ +#!/bin/sh + +cleanup () { + rm tmp/emptyfile tmp/testfile + rmdir tmp +} +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +mkdir -p tmp +touch tmp/emptyfile +echo -n "test" > tmp/testfile + +nvm_checksum tmp/emptyfile "da39a3ee5e6b4b0d3255bfef95601890afd80709" || die "nvm_checksum on an empty file did not match the SHA1 digest of the empty string" +nvm_checksum tmp/testfile "da39a3ee5e6b4b0d3255bfef95601890afd80709" && die "nvm_checksum allowed a bad checksum" + +cleanup