Files
scrabble-solver/internal/wordlist/wordlist_test.go
T
Ilia Denisov 15c7959d96 Implement Scrabble move generator (DAWG) with English and Russian rules
A Go library that returns every legal play ranked by score and scores or
validates plays, using the Appel-Jacobson DAWG algorithm over
github.com/iliadenisov/dafsa v1.1.0.

- DAWG move generation (across / down / both), full tournament scoring with a
  per-tile breakdown; public Solver: GenerateMoves (ranked), ScorePlay,
  ValidatePlay.
- Rulesets: English Scrabble, Russian Scrabble, Эрудит (parameterizable Ruleset).
- cmd/builddict (build the DAWG from the dictionaries submodule), cmd/stress
  (self-play benchmark), selfplay engine; brute-force test oracle.
- A GADDAG was implemented, benchmarked and removed (the DAWG was smaller and
  faster for a scoring solver); see RESULTS.md and ALGORITHM.md.
2026-06-01 16:07:32 +02:00

38 lines
881 B
Go

package wordlist
import (
"testing"
"github.com/iliadenisov/alphabet"
)
func TestFoldYo(t *testing.T) {
if got := FoldYo("ёлка"); got != "елка" {
t.Errorf("FoldYo(ёлка) = %q, want елка", got)
}
if got := FoldYo("Ёжик"); got != "Ежик" {
t.Errorf("FoldYo(Ёжик) = %q, want Ежик", got)
}
}
func TestEncodeFilterSortDedupe(t *testing.T) {
got := Encode([]string{
"cat", "CATS", "ab", "b", "abcdefghi", "cat", " do ", "qu1rk",
}, alphabet.Latin(), 2, 8)
want := [][]byte{
{0, 1}, // ab
{2, 0, 19}, // cat
{2, 0, 19, 18}, // cats (from CATS, case-folded)
{3, 14}, // do (trimmed)
}
if len(got) != len(want) {
t.Fatalf("got %d words %v, want %d", len(got), got, len(want))
}
for i := range want {
if string(got[i]) != string(want[i]) {
t.Errorf("word %d = %v, want %v", i, got[i], want[i])
}
}
}