mirror of
https://github.com/tailscale/tailscale.git
synced 2026-07-19 12:02:07 -04:00
Adds eailed critters and scaly ones. No anole was harmed (it was already in the list), and the loris was turned away at the door for being suspiciously tailless. Removes a word that was misread/misinterpreted and starts a rejection list in the test suite. Updates #words Signed-off-by: James Tucker <james@tailscale.com>
47 lines
1.0 KiB
Go
47 lines
1.0 KiB
Go
// Copyright (c) Tailscale Inc & contributors
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
package words
|
|
|
|
import (
|
|
"slices"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
var nopes = []string{
|
|
"chub", "bangus", "hellbender",
|
|
}
|
|
|
|
func TestWords(t *testing.T) {
|
|
test := func(t *testing.T, words []string) {
|
|
t.Helper()
|
|
if len(words) == 0 {
|
|
t.Error("no words")
|
|
}
|
|
seen := map[string]bool{}
|
|
for _, w := range words {
|
|
if seen[w] {
|
|
t.Errorf("dup word %q", w)
|
|
}
|
|
seen[w] = true
|
|
if w == "" || strings.IndexFunc(w, nonASCIILower) != -1 {
|
|
t.Errorf("malformed word %q", w)
|
|
}
|
|
if slices.Contains(nopes, w) {
|
|
t.Errorf("word %q has been previously rejected/removed and should not be added", w)
|
|
}
|
|
}
|
|
}
|
|
t.Run("tails", func(t *testing.T) { test(t, Tails()) })
|
|
t.Run("scales", func(t *testing.T) { test(t, Scales()) })
|
|
t.Logf("%v tails * %v scales = %v beautiful combinations", len(Tails()), len(Scales()), len(Tails())*len(Scales()))
|
|
}
|
|
|
|
func nonASCIILower(r rune) bool {
|
|
if 'a' <= r && r <= 'z' {
|
|
return false
|
|
}
|
|
return true
|
|
}
|