pdqhash-go

git clone git://archive.git.mtrnord.blog/MTRNord/pdqhash-go.git
Log | Files | Refs | LICENSE

commit 766cf5f5806a085708b549c205df052bdd1a024f
parent fed35bf1bf1a41a79809467ba475fd5c05618cc1
Author: MTRNord <mtrnord1@gmail.com>
Date:   Sun, 25 Feb 2024 15:32:05 +0100

Fix vips init in test

Diffstat:
Mpdq_hasher_test.go | 39+++++++++++++++++----------------------
1 file changed, 17 insertions(+), 22 deletions(-)

diff --git a/pdq_hasher_test.go b/pdq_hasher_test.go @@ -1,6 +1,7 @@ package pdq import ( + "os" "testing" "github.com/MTRNord/pdqhash-go/types" @@ -13,6 +14,22 @@ type Pair struct { Second string } +func TestMain(m *testing.M) { + vips.LoggingSettings(nil, vips.LogLevelMessage) + vips.Startup(&vips.Config{ + ConcurrencyLevel: 0, + MaxCacheFiles: 5, + MaxCacheMem: 50 * 1024 * 1024, + MaxCacheSize: 100, + ReportLeaks: false, + CacheTrace: false, + CollectStats: false, + }) + defer vips.Shutdown() + + os.Exit(m.Run()) +} + var DATA_ARRAY = [19]Pair{ { "./test-images/misc-images/b.jpg", @@ -93,17 +110,6 @@ var DATA_ARRAY = [19]Pair{ } func TestPDQHasher(t *testing.T) { - vips.LoggingSettings(nil, vips.LogLevelMessage) - vips.Startup(&vips.Config{ - ConcurrencyLevel: 0, - MaxCacheFiles: 5, - MaxCacheMem: 50 * 1024 * 1024, - MaxCacheSize: 100, - ReportLeaks: false, - CacheTrace: false, - CollectStats: false, - }) - defer vips.Shutdown() pdqHasher := NewPDQHasher() hammingTolerance := 16 @@ -124,17 +130,6 @@ func TestPDQHasher(t *testing.T) { } func TestPDQHasherDehidral(t *testing.T) { - vips.LoggingSettings(nil, vips.LogLevelMessage) - vips.Startup(&vips.Config{ - ConcurrencyLevel: 0, - MaxCacheFiles: 5, - MaxCacheMem: 50 * 1024 * 1024, - MaxCacheSize: 100, - ReportLeaks: false, - CacheTrace: false, - CollectStats: false, - }) - defer vips.Shutdown() pdqHasher := NewPDQHasher() hashes := pdqHasher.DihedralFromFile("./test-images/reg-test-input/labelme-subset/q0004.jpg", PDQ_DO_DIH_ALL)