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

Function TestNormalizeWhitespace_OnlyWhitespace

pkg/stringutil/stringutil_test.go:213–247  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

211}
212
213func TestNormalizeWhitespace_OnlyWhitespace(t *testing.T) {
214 tests := []struct {
215 name string
216 content string
217 expected string
218 }{
219 {
220 name: "only spaces",
221 content: " ",
222 expected: "", // After trimming trailing spaces and newlines, becomes empty
223 },
224 {
225 name: "only tabs",
226 content: "\t\t\t",
227 expected: "", // After trimming trailing tabs and newlines, becomes empty
228 },
229 {
230 name: "mixed spaces and tabs",
231 content: " \t \t",
232 expected: "", // After trimming, becomes empty
233 },
234 {
235 name: "only newlines",
236 content: "\n\n\n",
237 expected: "",
238 },
239 }
240
241 for _, tt := range tests {
242 t.Run(tt.name, func(t *testing.T) {
243 result := NormalizeWhitespace(tt.content)
244 assert.Equal(t, tt.expected, result, "NormalizeWhitespace(%q) should handle whitespace-only input", tt.content)
245 })
246 }
247}
248
249func TestNormalizeWhitespace_ManyLines(t *testing.T) {
250 // Test with many lines

Callers

nothing calls this directly

Calls 2

NormalizeWhitespaceFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected