MCPcopy Create free account
hub / github.com/egonelbre/exp / TestByteModel

Function TestByteModel

coder/arith/models_test.go:62–86  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

60}
61
62func TestByteModel(t *testing.T) {
63 B := func() Model { return &Shift{Prob(0.5), 5} }
64 T := func() Model { return NewTree(8, B) }
65
66 encm, decm := T(), T()
67
68 data := make([]byte, 25192)
69 for i := range data {
70 data[i] = byte(rand.Int())
71 }
72
73 enc := NewEncoder()
74 for _, b := range data {
75 encm.Encode(enc, uint(b))
76 }
77 enc.Close()
78
79 dec := NewDecoder(enc.Bytes())
80 for i, v := range data {
81 x := decm.Decode(dec)
82 if byte(x) != v {
83 t.Fatalf("fail %v: got %v exp %v", i, x, v)
84 }
85 }
86}
87
88func TestShiftZeros(t *testing.T) {
89 model := func() Model { return &Shift{MaxP / 1000, 7} }

Callers

nothing calls this directly

Calls 8

CloseMethod · 0.95
BytesMethod · 0.95
ProbFunction · 0.85
NewTreeFunction · 0.85
NewEncoderFunction · 0.85
NewDecoderFunction · 0.70
EncodeMethod · 0.65
DecodeMethod · 0.65

Tested by

no test coverage detected