MCPcopy Create free account
hub / github.com/github/gh-aw / TestBuildSanitizePreservePattern

Function TestBuildSanitizePreservePattern

pkg/stringutil/sanitize_test.go:716–755  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

714}
715
716func TestBuildSanitizePreservePattern(t *testing.T) {
717 tests := []struct {
718 name string
719 preserve []rune
720 expected string
721 }{
722 {
723 name: "no special chars",
724 expected: "a-z0-9-",
725 },
726 {
727 name: "dot only",
728 preserve: []rune{'.'},
729 expected: "a-z0-9-.",
730 },
731 {
732 name: "underscore only",
733 preserve: []rune{'_'},
734 expected: "a-z0-9-_",
735 },
736 {
737 name: "duplicates and order are canonicalized",
738 preserve: []rune{'_', '.', '_', '.'},
739 expected: "a-z0-9-._",
740 },
741 }
742
743 for _, tt := range tests {
744 t.Run(tt.name, func(t *testing.T) {
745 opts := &SanitizeOptions{PreserveSpecialChars: tt.preserve}
746 assertSanitizeResultWithContext(
747 t,
748 "buildSanitizePreservePattern",
749 fmt.Sprintf("opts=%+v", opts),
750 buildSanitizePreservePattern(opts),
751 tt.expected,
752 )
753 })
754 }
755}

Callers

nothing calls this directly

Calls 3

RunMethod · 0.45

Tested by

no test coverage detected