(t *testing.T)
| 88 | } |
| 89 | |
| 90 | func TestRandomStringEncoding(t *testing.T) { |
| 91 | size := 1000 |
| 92 | round := 2000 |
| 93 | strList := make([]string, size) |
| 94 | for r := 0; r < round; r++ { |
| 95 | for i := 0; i < size; i++ { |
| 96 | strList[i] = RandString(rand.Intn(50)) |
| 97 | } |
| 98 | buf := bytes.NewBuffer(nil) |
| 99 | enc := NewEncoder(buf) |
| 100 | for _, str := range strList { |
| 101 | err := enc.writeString(str) |
| 102 | if err != nil { |
| 103 | t.Error(err) |
| 104 | return |
| 105 | } |
| 106 | } |
| 107 | dec := NewDecoder(buf) |
| 108 | for _, expect := range strList { |
| 109 | actual, err := dec.readString() |
| 110 | if err != nil { |
| 111 | t.Error(err) |
| 112 | continue |
| 113 | } |
| 114 | if string(actual) != expect { |
| 115 | t.Errorf("expect %s, actual %s", expect, string(actual)) |
| 116 | } |
| 117 | } |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | func TestLZFString(t *testing.T) { |
| 122 | buf := bytes.NewBuffer(nil) |
nothing calls this directly
no test coverage detected
searching dependent graphs…