diff --git a/internal/testutil/syn.go b/internal/testutil/syn.go index ae53d57..863b59a 100644 --- a/internal/testutil/syn.go +++ b/internal/testutil/syn.go @@ -16,8 +16,6 @@ package testutil import ( "encoding/binary" - "fmt" - "math" "testing" "github.com/ianlewis/go-stardict/syn" @@ -31,18 +29,14 @@ func MakeSyn(t *testing.T, words []*syn.Word) []byte { for _, w := range words { // Allow for zero byte terminator and 4 extra bytes for the word index. bWord := make([]byte, len(w.Word)+5) - copy(bWord, []byte(w.Word)) + copy(bWord, w.Word) i := len(w.Word) // NOTE: byte array entries are already initialized to zero but we set // it anyway for clarity. bWord[i] = 0 i++ - if w.OriginalWordIndex > math.MaxUint32 { - panic(fmt.Sprintf("index too large: %d", w.OriginalWordIndex)) - } - //nolint:gosec // test code, offset size determined by idxoffsetbits - binary.BigEndian.PutUint32(bWord[i:], uint32(w.OriginalWordIndex)) + binary.BigEndian.PutUint32(bWord[i:], w.OriginalWordIndex) b = append(b, bWord...) } return b diff --git a/stardict_test.go b/stardict_test.go index 68be8d3..627e499 100644 --- a/stardict_test.go +++ b/stardict_test.go @@ -128,6 +128,8 @@ idxfilesize=6`, } func TestSearch(t *testing.T) { + t.Parallel() + tests := []struct { name string dict *testDict diff --git a/syn/syn.go b/syn/syn.go index 95b29e9..02f599f 100644 --- a/syn/syn.go +++ b/syn/syn.go @@ -24,11 +24,12 @@ import ( "strings" "unicode" - "github.com/ianlewis/go-stardict/internal/folding" "golang.org/x/text/cases" "golang.org/x/text/runes" "golang.org/x/text/transform" "golang.org/x/text/unicode/norm" + + "github.com/ianlewis/go-stardict/internal/folding" ) // Word is a .syn file entry. diff --git a/syn/syn_test.go b/syn/syn_test.go index 5367a23..3024378 100644 --- a/syn/syn_test.go +++ b/syn/syn_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" + "github.com/ianlewis/go-stardict/internal/testutil" "github.com/ianlewis/go-stardict/syn" )