github.com/panmari/cuckoofilter@v1.0.7-0.20231223155748-763d1d471ee8/util_test.go (about)

     1  package cuckoo
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  func TestIndexAndFP(t *testing.T) {
     8  	data := []byte("seif")
     9  	numBuckets := uint(1024)
    10  	i1, fp := getIndexAndFingerprint(data, numBuckets)
    11  	i2 := getAltIndex(fp, i1, numBuckets)
    12  	i11 := getAltIndex(fp, i2, numBuckets)
    13  	i22 := getAltIndex(fp, i1, numBuckets)
    14  	if i1 != i11 {
    15  		t.Errorf("Expected i1 == i11, instead %d != %d", i1, i11)
    16  	}
    17  	if i2 != i22 {
    18  		t.Errorf("Expected i2 == i22, instead %d != %d", i2, i22)
    19  	}
    20  }