]>
Commit | Line | Data |
---|---|---|
c45c1bca SW |
1 | package main |
2 | ||
3 | import "testing" | |
4 | ||
5 | func TestEncodeDecode(t *testing.T) { | |
a29aebec | 6 | dims := LogicalIndex{3, 2, 4, 17, 26, 15, 2, 1, 2, 1} |
db81510d | 7 | var i PhysicalIndex |
ebe808f6 | 8 | for i = 0; i < 636480; i++ { // Product of dims |
c45c1bca SW |
9 | addr := DecodeIndex(dims, i) |
10 | for j := 0; j < len(dims); j++ { | |
11 | if addr[j] >= dims[j] { | |
12 | t.Fail() | |
13 | } | |
14 | } | |
15 | if EncodeIndex(dims, addr) != i { | |
16 | t.Fail() | |
17 | } | |
18 | } | |
19 | } | |
b7a6e28b SW |
20 | |
21 | func TestCommas(t *testing.T) { | |
fc93fd36 | 22 | cases := map[Value]string{ |
a49e368f SW |
23 | 1: "1", |
24 | 10: "10", | |
25 | 100: "100", | |
26 | 1000: "1,000", | |
27 | 10000: "10,000", | |
28 | 100000: "100,000", | |
b7a6e28b SW |
29 | 1000000: "1,000,000", |
30 | 1234567: "1,234,567", | |
31 | 1000567: "1,000,567", | |
32 | 1234000: "1,234,000", | |
a49e368f | 33 | 525000: "525,000", |
b7a6e28b SW |
34 | } |
35 | for n, s := range cases { | |
36 | if Commas(n) != s { | |
37 | t.Error(n, "not", s) | |
38 | } | |
39 | } | |
40 | } |