From 6995fa9b0ca696c292b1ee5d4daaff6472ec7ffe Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Thu, 10 May 2018 11:47:10 +0900 Subject: [PATCH] goimagehash: Add test --- hashcompute_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/hashcompute_test.go b/hashcompute_test.go index 9b88c59..5d8e0ef 100644 --- a/hashcompute_test.go +++ b/hashcompute_test.go @@ -98,6 +98,32 @@ func TestHashCompute(t *testing.T) { } } +func NilHashComputeTest(t *testing.T) { + hash, err := AverageHash(nil) + if err == nil { + t.Errorf("Error should be got.") + } + if hash != nil { + t.Errorf("Nil hash should be got. but got %v", hash) + } + + hash, err = DifferenceHash(nil) + if err == nil { + t.Errorf("Error should be got.") + } + if hash != nil { + t.Errorf("Nil hash should be got. but got %v", hash) + } + + hash, err = PerceptionHash(nil) + if err == nil { + t.Errorf("Error should be got.") + } + if hash != nil { + t.Errorf("Nil hash should be got. but got %v", hash) + } +} + func BenchmarkDistanceIdentical(b *testing.B) { h1 := &ImageHash{hash: 0xe48ae53c05e502f7} h2 := &ImageHash{hash: 0xe48ae53c05e502f7}