(t *testing.T)
| 11 | } |
| 12 | |
| 13 | func TestRandomEncodeDecode(t *testing.T) { |
| 14 | bits := make([]pair, 2141) |
| 15 | for i := range bits { |
| 16 | bits[i].bit = uint(rand.Intn(2)) |
| 17 | bits[i].prob = P(rand.Intn(MaxP)) |
| 18 | } |
| 19 | |
| 20 | enc := NewEncoder() |
| 21 | for _, v := range bits { |
| 22 | enc.Encode(v.bit, v.prob) |
| 23 | } |
| 24 | enc.Close() |
| 25 | data := enc.Bytes() |
| 26 | |
| 27 | dec := NewDecoder(data) |
| 28 | for i, v := range bits { |
| 29 | x := dec.Decode(v.prob) |
| 30 | if x != v.bit { |
| 31 | t.Fatalf("fail %v: %v got %v exp %v", bits, i, x, v.bit) |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | func TestPacking(t *testing.T) { |
| 37 | const N = 1 << 16 |
nothing calls this directly
no test coverage detected