1package numeric 2 3import "testing" 4 5func TestInterleaveDeinterleave(t *testing.T) { 6 tests := []struct { 7 v1 uint64 8 v2 uint64 9 }{ 10 {0, 0}, 11 {1, 1}, 12 {27, 39}, 13 {1<<32 - 1, 1<<32 - 1}, // largest that should still work 14 } 15 16 for _, test := range tests { 17 i := Interleave(test.v1, test.v2) 18 gotv1 := Deinterleave(i) 19 gotv2 := Deinterleave(i >> 1) 20 if gotv1 != test.v1 { 21 t.Errorf("expected v1: %d, got %d, interleaved was %x", test.v1, gotv1, i) 22 } 23 if gotv2 != test.v2 { 24 t.Errorf("expected v2: %d, got %d, interleaved was %x", test.v2, gotv2, i) 25 } 26 } 27} 28