mirror of
https://github.com/tiennm99/tiennm99bot.git
synced 2026-10-11 03:13:46 +00:00
Phase 5b of go-port-cloud-run plan. Port 14855-word dictionary (89 KB, byte-identical to JS source) and four wordle commands (/wordle, /wordle_new, /wordle_giveup, /wordle_stats). KV wire-format parity: GameState/Stats JSON match JS shape; *int64 LastResultAt for null-value compatibility. Two real bugs caught and fixed: (1) defaultRNG data race in handlers — switched to math/rand.Intn (mutex-protected package-level); (2) Get→mutate→Put logical race in groups — added per-subject sync.Mutex map to serialize access. TTL deferred (Firestore has no expirationTtl equiv — Phase 11 GC).
25 lines
751 B
Go
25 lines
751 B
Go
package wordle
|
|
|
|
import "testing"
|
|
|
|
// TestLoadWords_EmbeddedDictIsValid asserts the embedded data file: every
|
|
// entry is exactly 5 lowercase a-z, count is plausible, and a known word
|
|
// is present. Cheap insurance against a bad regen of words.txt.
|
|
func TestLoadWords_EmbeddedDictIsValid(t *testing.T) {
|
|
words, set := loadWords()
|
|
|
|
if len(words) < 14000 || len(words) > 15000 {
|
|
t.Errorf("word count = %d, want ~14855", len(words))
|
|
}
|
|
if len(words) != len(set) {
|
|
t.Errorf("words/set length mismatch: %d vs %d (duplicates?)", len(words), len(set))
|
|
}
|
|
|
|
// Spot-check known words from the dracos list.
|
|
for _, sample := range []string{"crane", "abase", "zymic"} {
|
|
if _, ok := set[sample]; !ok {
|
|
t.Errorf("expected %q in dict", sample)
|
|
}
|
|
}
|
|
}
|