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

44 lines
1.1 KiB
Go

package graph_test
import (
"testing"
"github.com/iliadenisov/alphabet"
dawg "github.com/iliadenisov/dafsa"
"gitea.iliadenisov.ru/developer/scrabble-solver/internal/graph"
)
// TestSpellSmoke also exercises the go.mod replace => ../dafsa wiring and the new
// dafsa traversal API end-to-end from the solver module.
func TestSpellSmoke(t *testing.T) {
d := dawg.New(alphabet.Latin())
for _, w := range []string{"cat", "cats", "dog"} {
if err := d.Add(w); err != nil {
t.Fatalf("Add(%q): %v", w, err)
}
}
c, err := dawg.NewCursor(d.Finish())
if err != nil {
t.Fatal(err)
}
enc := func(s string) []byte {
b, err := alphabet.Latin().Encode(s)
if err != nil {
t.Fatalf("Encode(%q): %v", s, err)
}
return b
}
if _, final, ok := graph.Spell(c, enc("cat")); !ok || !final {
t.Errorf("Spell(cat): ok=%v final=%v, want both true", ok, final)
}
if _, final, ok := graph.Spell(c, enc("ca")); !ok || final {
t.Errorf("Spell(ca): ok=%v final=%v, want ok=true final=false", ok, final)
}
if _, _, ok := graph.Spell(c, enc("xyz")); ok {
t.Errorf("Spell(xyz): ok=true, want false")
}
}