Files
Ilia Denisov 256999b42c Publish as versioned Gitea module; move dictionary pipeline out
- Rename module to gitea.iliadenisov.ru/developer/scrabble-solver so it can be
  consumed as a versioned dependency (no go.work replace / CI clone).
- De-internalize wordlist and dictdawg as public packages.
- Remove cmd/builddict, dictprep/, the dictionaries submodule and the dawg
  Makefile: the word-list parsing and DAWG build now live in the separate
  scrabble-dictionary repository, which publishes the DAWG set as a release artifact.
- internal/dict loads the committed dawg/en_sowpods.dawg fixture for cmd/stress.
- Update README/CLAUDE docs accordingly.
2026-06-04 19:11:46 +02:00

45 lines
1.1 KiB
Go

package dictdawg_test
import (
"path/filepath"
"testing"
"github.com/iliadenisov/alphabet"
"gitea.iliadenisov.ru/developer/scrabble-solver/dictdawg"
"gitea.iliadenisov.ru/developer/scrabble-solver/wordlist"
)
func TestBuildAndQuery(t *testing.T) {
words := wordlist.Encode([]string{"care", "cares", "cat"}, alphabet.Latin(), 2, 15)
f, err := dictdawg.Build(alphabet.Latin(), words)
if err != nil {
t.Fatal(err)
}
if f.NumAdded() != 3 {
t.Fatalf("NumAdded = %d, want 3", f.NumAdded())
}
if i := f.IndexOfB([]byte{2, 0, 17, 4}); i != 0 { // care
t.Errorf("IndexOf(care) = %d, want 0", i)
}
if i := f.IndexOfB([]byte{2, 0, 19}); i != 2 { // cat
t.Errorf("IndexOf(cat) = %d, want 2", i)
}
if i := f.IndexOfB([]byte{2, 0, 17}); i != -1 { // car (absent)
t.Errorf("IndexOf(car) = %d, want -1", i)
}
path := filepath.Join(t.TempDir(), "d.dawg")
if err := dictdawg.Save(f, path); err != nil {
t.Fatal(err)
}
g, err := dictdawg.Load(path)
if err != nil {
t.Fatal(err)
}
defer g.Close()
if i := g.IndexOfB([]byte{2, 0, 17, 4, 18}); i != 1 { // cares
t.Errorf("loaded IndexOf(cares) = %d, want 1", i)
}
}