X-Git-Url: http://git.scottworley.com/planeteer/blobdiff_plain/5f1a50e1c7d4ae2908197673d5dbf948b3509a8f..c45c1bcae7063b858bfa08a2376efe3a87b2c7f2:/planeteer_test.go diff --git a/planeteer_test.go b/planeteer_test.go new file mode 100644 index 0000000..0cc7f65 --- /dev/null +++ b/planeteer_test.go @@ -0,0 +1,18 @@ +package main + +import "testing" + +func TestEncodeDecode(t *testing.T) { + dims := []int{3, 2, 4, 17, 26, 15, 1, 2, 1} + for i := 0; i < 318240; i++ { // Product of dims + addr := DecodeIndex(dims, i) + for j := 0; j < len(dims); j++ { + if addr[j] >= dims[j] { + t.Fail() + } + } + if EncodeIndex(dims, addr) != i { + t.Fail() + } + } +}