MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / TestStringMatch

Function TestStringMatch

internal/util/util_test.go:564–588  ·  view source on GitHub ↗

TestStringMatch tests the stringMatch function with various conditions.

(t *testing.T)

Source from the content-addressed store, hash-verified

562
563// TestStringMatch tests the stringMatch function with various conditions.
564func TestStringMatch(t *testing.T) {
565 tests := []struct {
566 name string
567 searchFor string
568 searchIn string
569 allowContains bool
570 wantPartial bool
571 wantFull bool
572 }{
573 {"exact", "sword", "sword", false, true, true},
574 {"partial prefix", "sw", "sword", false, true, false},
575 {"no match prefix", "abc", "sword", false, false, false},
576 {"contains partial", "wor", "sword", true, false, false},
577 {"contains full", "sword", "MYswordX", true, false, false}, // "sword" is not a prefix of the single word "myswordx"
578 {"case mismatch", "SWORD", "sword", false, true, true},
579 }
580 for _, tt := range tests {
581 partial, full := stringMatch(tt.searchFor, tt.searchIn, tt.allowContains)
582 if partial != tt.wantPartial || full != tt.wantFull {
583 t.Errorf("stringMatch(%q, %q, %t) got (%v, %v), want (%v, %v)",
584 tt.searchFor, tt.searchIn, tt.allowContains,
585 partial, full, tt.wantPartial, tt.wantFull)
586 }
587 }
588}
589
590// TestHash checks Hash outputs a known format.
591func TestHash(t *testing.T) {

Callers

nothing calls this directly

Calls 1

stringMatchFunction · 0.85

Tested by

no test coverage detected