Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Lewis <ianmlewis@gmail.com>
  • Loading branch information
ianlewis committed Jan 17, 2025
1 parent 769904f commit 2b51fd0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
10 changes: 2 additions & 8 deletions internal/testutil/syn.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ package testutil

import (
"encoding/binary"
"fmt"
"math"
"testing"

"github.com/ianlewis/go-stardict/syn"
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions stardict_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ idxfilesize=6`,
}

func TestSearch(t *testing.T) {
t.Parallel()

tests := []struct {
name string
dict *testDict
Expand Down
3 changes: 2 additions & 1 deletion syn/syn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions syn/syn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down

0 comments on commit 2b51fd0

Please # to comment.