aboutsummaryrefslogtreecommitdiff
path: root/sketch_test.go
diff options
context:
space:
mode:
authorn-peugnet <n.peugnet@free.fr>2021-08-26 19:21:46 +0200
committern-peugnet <n.peugnet@free.fr>2021-08-26 19:21:46 +0200
commit78251f11c91b2504edfc02b760ef53bd352b856c (patch)
tree1101f5da1f37597eec68c378ed086022dee5dc59 /sketch_test.go
parentd25d38b8989787551c8b29500f580ea331afc4e8 (diff)
downloaddna-backup-78251f11c91b2504edfc02b760ef53bd352b856c.tar.gz
dna-backup-78251f11c91b2504edfc02b760ef53bd352b856c.zip
add SketchChunk function
Diffstat (limited to 'sketch_test.go')
-rw-r--r--sketch_test.go30
1 files changed, 30 insertions, 0 deletions
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++
+ }
+}