From 78251f11c91b2504edfc02b760ef53bd352b856c Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Thu, 26 Aug 2021 19:21:46 +0200 Subject: add SketchChunk function --- sketch_test.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 sketch_test.go (limited to 'sketch_test.go') diff --git a/sketch_test.go b/sketch_test.go new file mode 100644 index 0000000..ac4ab70 --- /dev/null +++ b/sketch_test.go @@ -0,0 +1,30 @@ +package main + +import ( + "path" + "testing" + + "github.com/google/go-cmp/cmp" +) + +func TestSketchChunk(t *testing.T) { + dataDir := path.Join("test", "data", "repo_8k") + chunks := make(chan Chunk, 16) + repo := NewRepo(dataDir) + versions := repo.loadVersions() + go repo.loadChunks(versions, chunks) + var i int + for c := range chunks { + if i < 1 { + sketch, err := SketchChunk(c, 32, 3, 4) + if err != nil { + t.Error(err) + } + expected := []uint64{429857165471867, 6595034117354675, 8697818304802825} + if !cmp.Equal(sketch, expected) { + t.Errorf("Sketch does not match, expected: %d, actual: %d", expected, sketch) + } + } + i++ + } +} -- cgit v1.2.3