]>
Commit | Line | Data |
---|---|---|
c45c1bca SW |
1 | package main |
2 | ||
3 | import "testing" | |
4 | ||
5 | func TestEncodeDecode(t *testing.T) { | |
6 | dims := []int{3, 2, 4, 17, 26, 15, 1, 2, 1} | |
7 | for i := 0; i < 318240; i++ { // Product of dims | |
8 | addr := DecodeIndex(dims, i) | |
9 | for j := 0; j < len(dims); j++ { | |
10 | if addr[j] >= dims[j] { | |
11 | t.Fail() | |
12 | } | |
13 | } | |
14 | if EncodeIndex(dims, addr) != i { | |
15 | t.Fail() | |
16 | } | |
17 | } | |
18 | } |