From b3ea1498cfdbd3a2a788b7871f49db5b6a0ca9ae Mon Sep 17 00:00:00 2001
From: Jakob Unterwurzacher
Date: Sat, 31 Oct 2015 23:08:40 +0100
Subject: tests: verify file size in testWriteN

---
 main_test.go | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/main_test.go b/main_test.go
index 4d21dde..2d4f578 100644
--- a/main_test.go
+++ b/main_test.go
@@ -85,6 +85,7 @@ func TestMain(m *testing.M) {
 	os.Exit(r)
 }
 
+// Write "n" zero bytes to filename "fn", read again, compare hash
 func testWriteN(t *testing.T, fn string, n int) string {
 	file, err := os.Create(plainDir + fn)
 	if err != nil {
@@ -99,13 +100,23 @@ func testWriteN(t *testing.T, fn string, n int) string {
 	}
 	file.Close()
 
+	fi, err := os.Stat(plainDir + fn)
+	if err != nil {
+		t.Errorf("Stat on file %s failed: %v", fn, err)
+	} else {
+		if fi.Size() != int64(n) {
+			t.Errorf("Wrong file fize, got=%d want=%d", fi.Size(), n)
+		}
+	}
+
+
 	bin := md5.Sum(d)
 	hashWant := hex.EncodeToString(bin[:])
 
 	hashActual := md5fn(plainDir + fn)
 
 	if hashActual != hashWant {
-		fmt.Printf("hashWant=%s hashActual=%s\n", hashWant, hashActual)
+		fmt.Printf("Content corruption in file %s: hashWant=%s hashActual=%s\n", fn, hashWant, hashActual)
 		t.Fail()
 	}
 
-- 
cgit v1.2.3