inflate_test.go 773 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright 2014 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package flate
  5. import (
  6. "bytes"
  7. "io"
  8. "testing"
  9. )
  10. func TestReset(t *testing.T) {
  11. ss := []string{
  12. "lorem ipsum izzle fo rizzle",
  13. "the quick brown fox jumped over",
  14. }
  15. deflated := make([]bytes.Buffer, 2)
  16. for i, s := range ss {
  17. w, _ := NewWriter(&deflated[i], 1)
  18. w.Write([]byte(s))
  19. w.Close()
  20. }
  21. inflated := make([]bytes.Buffer, 2)
  22. f := NewReader(&deflated[0])
  23. io.Copy(&inflated[0], f)
  24. f.(Resetter).Reset(&deflated[1], nil)
  25. io.Copy(&inflated[1], f)
  26. f.Close()
  27. for i, s := range ss {
  28. if s != inflated[i].String() {
  29. t.Errorf("inflated[%d]:\ngot %q\nwant %q", i, inflated[i], s)
  30. }
  31. }
  32. }