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

Function TestSpec_PublicAPI_NormalizeWhitespace

pkg/stringutil/spec_test.go:73–96  ·  view source on GitHub ↗

TestSpec_PublicAPI_NormalizeWhitespace validates the documented behavior of NormalizeWhitespace as described in the package README.md. Specification: "Normalizes trailing whitespace in multi-line content. Trims trailing spaces and tabs from every line, then ensures the content ends with exactly one

(t *testing.T)

Source from the content-addressed store, hash-verified

71// trailing spaces and tabs from every line, then ensures the content ends with
72// exactly one newline (or is empty)."
73func TestSpec_PublicAPI_NormalizeWhitespace(t *testing.T) {
74 t.Run("trims trailing spaces from each line", func(t *testing.T) {
75 input := "line one \nline two\t\t\nline three"
76 result := NormalizeWhitespace(input)
77 for line := range strings.SplitSeq(strings.TrimRight(result, "\n"), "\n") {
78 assert.Equal(t, strings.TrimRight(line, " \t"), line,
79 "each line should have no trailing spaces or tabs")
80 }
81 })
82
83 t.Run("ensures content ends with exactly one newline", func(t *testing.T) {
84 result := NormalizeWhitespace("content\n\n\n")
85 assert.True(t, strings.HasSuffix(result, "\n"),
86 "non-empty result should end with a newline")
87 assert.False(t, strings.HasSuffix(result, "\n\n"),
88 "result should not end with multiple newlines")
89 })
90
91 t.Run("empty input returns empty (no trailing newline added)", func(t *testing.T) {
92 result := NormalizeWhitespace("")
93 assert.Empty(t, result,
94 "empty input should remain empty (no trailing newline added)")
95 })
96}
97
98// TestSpec_PublicAPI_ParseVersionValue validates the documented behavior of
99// ParseVersionValue as described in the package README.md.

Callers

nothing calls this directly

Calls 2

NormalizeWhitespaceFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected