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

Function TestNormalizeWhitespace_ManyLines

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

Source from the content-addressed store, hash-verified

247}
248
249func TestNormalizeWhitespace_ManyLines(t *testing.T) {
250 // Test with many lines
251 lines := make([]string, 100)
252 for i := range 100 {
253 lines[i] = "line with trailing spaces "
254 }
255 var content strings.Builder
256 for _, line := range lines {
257 content.WriteString(line + "\n")
258 }
259
260 result := NormalizeWhitespace(content.String())
261
262 // Check that all trailing spaces are removed
263 expectedLines := make([]string, 100)
264 for i := range 100 {
265 expectedLines[i] = "line with trailing spaces"
266 }
267 var expected strings.Builder
268 for _, line := range expectedLines {
269 expected.WriteString(line + "\n")
270 }
271
272 assert.Equal(t, expected.String(), result, "NormalizeWhitespace should remove trailing spaces from all lines in large inputs")
273}
274
275func TestNormalizeWhitespace_PreservesContent(t *testing.T) {
276 // Ensure that non-trailing whitespace is preserved

Callers

nothing calls this directly

Calls 2

NormalizeWhitespaceFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected