Skip to content

Commit

Permalink
Fix testpackage lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
bodgit committed Apr 30, 2022
1 parent 5766fbc commit f583c59
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
4 changes: 0 additions & 4 deletions reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,6 @@ func NewReader(r io.ReaderAt, size int64) (*Reader, error) {
return NewReaderWithPassword(r, size, "")
}

func crc32Compare(b []byte, c uint32) int {
return bytes.Compare(b, []byte{byte(0xff & (c >> 24)), byte(0xff & (c >> 16)), byte(0xff & (c >> 8)), byte(0xff & c)})
}

func readUint64(r io.ByteReader) (uint64, error) {
b, err := r.ReadByte()
if err != nil {
Expand Down
15 changes: 9 additions & 6 deletions reader_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sevenzip
package sevenzip_test

import (
"errors"
Expand All @@ -7,6 +7,9 @@ import (
"io"
"path/filepath"
"testing"

"github.com/bodgit/sevenzip"
"github.com/bodgit/sevenzip/internal/util"
)

func TestOpenReader(t *testing.T) {
Expand Down Expand Up @@ -38,7 +41,7 @@ func TestOpenReader(t *testing.T) {

t.Run(table.name, func(t *testing.T) {
t.Parallel()
r, err := OpenReader(filepath.Join("testdata", table.file))
r, err := sevenzip.OpenReader(filepath.Join("testdata", table.file))
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -70,7 +73,7 @@ func TestOpenReaderWithPassword(t *testing.T) {

t.Run(table.name, func(t *testing.T) {
t.Parallel()
r, err := OpenReaderWithPassword(filepath.Join("testdata", table.file), table.password)
r, err := sevenzip.OpenReaderWithPassword(filepath.Join("testdata", table.file), table.password)
if err != nil {
t.Fatal(err)
}
Expand All @@ -80,7 +83,7 @@ func TestOpenReaderWithPassword(t *testing.T) {
}

func ExampleOpenReader() {
r, err := OpenReader(filepath.Join("testdata", "multi.7z.001"))
r, err := sevenzip.OpenReader(filepath.Join("testdata", "multi.7z.001"))
if err != nil {
panic(err)
}
Expand All @@ -107,7 +110,7 @@ func benchmarkArchive(b *testing.B, file string) {
h := crc32.NewIEEE()

for n := 0; n < b.N; n++ {
r, err := OpenReader(filepath.Join("testdata", file))
r, err := sevenzip.OpenReader(filepath.Join("testdata", file))
if err != nil {
b.Fatal(err)
}
Expand All @@ -128,7 +131,7 @@ func benchmarkArchive(b *testing.B, file string) {

rc.Close()

if crc32Compare(h.Sum(nil), f.CRC32) != 0 {
if !util.CRC32Equal(h.Sum(nil), f.CRC32) {
b.Fatal(errors.New("CRC doesn't match"))
}
}
Expand Down

0 comments on commit f583c59

Please sign in to comment.