| 18 | ) |
| 19 | |
| 20 | func Test_slidingWindow(t *testing.T) { |
| 21 | t.Parallel() |
| 22 | |
| 23 | const testCount = 99 |
| 24 | const maxWindow = 99999 |
| 25 | for range testCount { |
| 26 | t.Run("", func(t *testing.T) { |
| 27 | t.Parallel() |
| 28 | |
| 29 | input := xrand.String(maxWindow) |
| 30 | windowLength := xrand.Int(maxWindow) |
| 31 | var sw slidingWindow |
| 32 | sw.init(windowLength) |
| 33 | sw.write([]byte(input)) |
| 34 | |
| 35 | assert.Equal(t, "window length", windowLength, cap(sw.buf)) |
| 36 | if !strings.HasSuffix(input, string(sw.buf)) { |
| 37 | t.Fatalf("r.buf is not a suffix of input: %q and %q", input, sw.buf) |
| 38 | } |
| 39 | }) |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | func BenchmarkFlateWriter(b *testing.B) { |
| 44 | b.ReportAllocs() |