decode_test.go 863 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright (c) 2019 Klaus Post. 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 s2
  5. import (
  6. "bytes"
  7. "io/ioutil"
  8. "strings"
  9. "testing"
  10. "github.com/klauspost/compress/zip"
  11. )
  12. func TestDecodeRegression(t *testing.T) {
  13. data, err := ioutil.ReadFile("testdata/dec-block-regressions.zip")
  14. if err != nil {
  15. t.Fatal(err)
  16. }
  17. zr, err := zip.NewReader(bytes.NewReader(data), int64(len(data)))
  18. if err != nil {
  19. t.Fatal(err)
  20. }
  21. for _, tt := range zr.File {
  22. if !strings.HasSuffix(t.Name(), "") {
  23. continue
  24. }
  25. t.Run(tt.Name, func(t *testing.T) {
  26. r, err := tt.Open()
  27. if err != nil {
  28. t.Error(err)
  29. return
  30. }
  31. in, err := ioutil.ReadAll(r)
  32. if err != nil {
  33. t.Error(err)
  34. }
  35. got, err := Decode(nil, in)
  36. t.Log("Received:", len(got), err)
  37. })
  38. }
  39. }