github.com/andrewhsu/cli/v2@v2.0.1-0.20210910131313-d4b4061f5b89/pkg/text/sanitize_test.go (about) 1 package text 2 3 import "testing" 4 5 func TestReplaceExcessiveWhitespace(t *testing.T) { 6 tests := []struct { 7 name string 8 input string 9 want string 10 }{ 11 { 12 name: "no replacements", 13 input: "one two three", 14 want: "one two three", 15 }, 16 { 17 name: "whitespace b-gone", 18 input: "\n one\n\t two three\r\n ", 19 want: "one two three", 20 }, 21 } 22 for _, tt := range tests { 23 t.Run(tt.name, func(t *testing.T) { 24 if got := ReplaceExcessiveWhitespace(tt.input); got != tt.want { 25 t.Errorf("ReplaceExcessiveWhitespace() = %v, want %v", got, tt.want) 26 } 27 }) 28 } 29 }