File: bin_test.go

package info (click to toggle)
golang-github-blevesearch-bleve 0.5.0%2Bgit20170912.278.6eea5b78-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,764 kB
  • sloc: yacc: 311; sh: 51; makefile: 7
file content (27 lines) | stat: -rw-r--r-- 570 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package numeric

import "testing"

func TestInterleaveDeinterleave(t *testing.T) {
	tests := []struct {
		v1 uint64
		v2 uint64
	}{
		{0, 0},
		{1, 1},
		{27, 39},
		{1<<32 - 1, 1<<32 - 1}, // largest that should still work
	}

	for _, test := range tests {
		i := Interleave(test.v1, test.v2)
		gotv1 := Deinterleave(i)
		gotv2 := Deinterleave(i >> 1)
		if gotv1 != test.v1 {
			t.Errorf("expected v1: %d, got %d, interleaved was %x", test.v1, gotv1, i)
		}
		if gotv2 != test.v2 {
			t.Errorf("expected v2: %d, got %d, interleaved was %x", test.v2, gotv2, i)
		}
	}
}