byteio - zigzag_test.go
1 package byteio
2
3 import "testing"
4
5 func TestZigZag(t *testing.T) {
6 for n, test := range [...]struct {
7 In int64
8 Out uint64
9 }{
10 {0, 0},
11 {-1, 1},
12 {1, 2},
13 {-2, 3},
14 {2, 4},
15 {-9223372036854775807, 18446744073709551613},
16 {9223372036854775807, 18446744073709551614},
17 } {
18 if i := zigzag(test.In); i != test.Out {
19 t.Errorf("test %d.1: from %d expecting %d, got %d", n+1, test.In, test.Out, i)
20 }
21 if j := unzigzag(test.Out); j != test.In {
22 t.Errorf("test %d.2: from %d expecting %d, got %d", n+1, test.Out, test.In, j)
23 }
24 }
25 }
26