37 lines
639 B
Go
37 lines
639 B
Go
package server
|
|
|
|
import "testing"
|
|
|
|
func TestTrimLines(t *testing.T) {
|
|
t.Run("no newline at end", func(t *testing.T) {
|
|
s := `
|
|
hello
|
|
world`
|
|
s += " "
|
|
s += " \t"
|
|
got := trimLines(s)
|
|
want := `
|
|
hello
|
|
world`
|
|
if got != want {
|
|
t.Fatalf("want %q, got %q", want, got)
|
|
}
|
|
})
|
|
t.Run("noop", func(t *testing.T) {
|
|
s := `hi`
|
|
got := trimLines(s)
|
|
want := `hi`
|
|
if got != want {
|
|
t.Fatalf("want %q, got %q", want, got)
|
|
}
|
|
})
|
|
t.Run("newline", func(t *testing.T) {
|
|
s := "hi\n"
|
|
got := trimLines(s)
|
|
want := "hi\n"
|
|
if got != want {
|
|
t.Fatalf("want %q, got %q", want, got)
|
|
}
|
|
})
|
|
}
|