From 881286df39331948fb600ec937458e3a8f4f829b Mon Sep 17 00:00:00 2001 From: mappu Date: Sat, 25 Nov 2017 14:22:38 +1300 Subject: [PATCH] tth: expand test coverage --HG-- branch : adc --- tth_test.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tth_test.go b/tth_test.go index e4be70c..1756872 100644 --- a/tth_test.go +++ b/tth_test.go @@ -1,6 +1,7 @@ package libnmdc import ( + "strings" "testing" ) @@ -10,16 +11,25 @@ func TestTTH(t *testing.T) { testCases := [][2]string{ [2]string{"hello world", "ZIIVRZDR2FD3W4KKNMNYUU3765LPPK7BWY64CHI"}, [2]string{"", "LWPNACQDBZRYXW3VHJVCJ64QBZNGHOHHHZWCLNQ"}, + [2]string{"\x00", "VK54ZIEEVTWNAUI5D5RDFIL37LX2IQNSTAXFKSA"}, + [2]string{strings.Repeat("A", 1024), "L66Q4YVNAFWVS23X2HJIRA5ZJ7WXR3F26RSASFA"}, + } + + short := func(s string) string { + if len(s) > 15 { + return s[0:15] + "..." + } + return s } for _, testCase := range testCases { input, expected := testCase[0], testCase[1] result, err := tth([]byte(input)) if err != nil { - t.Fatalf("Error getting TTH for '%s': %s", input, err.Error()) + t.Fatalf("Error getting TTH for '%s': %s", short(input), err.Error()) } if result != expected { - t.Fatalf("Wrong TTH for '%s' (got '%s' expected '%s')", input, result, expected) + t.Fatalf("Wrong TTH for '%s' (got '%s' expected '%s')", short(input), result, expected) } } }