(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func TestLengthEncoding(t *testing.T) { |
| 13 | buf := bytes.NewBuffer(nil) |
| 14 | enc := NewEncoder(buf) |
| 15 | lens := []uint64{1 << 5, 1 << 13, 1 << 31, 1 << 63} |
| 16 | for _, v := range lens { |
| 17 | err := enc.writeLength(v) |
| 18 | if err != nil { |
| 19 | t.Error(err) |
| 20 | return |
| 21 | } |
| 22 | } |
| 23 | dec := NewDecoder(buf) |
| 24 | for _, expect := range lens { |
| 25 | actual, special, err := dec.readLength() |
| 26 | if err != nil { |
| 27 | t.Error(err) |
| 28 | return |
| 29 | } |
| 30 | if special { |
| 31 | t.Error("expect normal actual special") |
| 32 | return |
| 33 | } |
| 34 | if actual != expect { |
| 35 | t.Errorf("expect %d, actual %d", expect, actual) |
| 36 | } |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | func TestStringEncoding(t *testing.T) { |
| 41 | buf := bytes.NewBuffer(nil) |
nothing calls this directly
no test coverage detected
searching dependent graphs…