shad-go/utf8/spacecollapse/collapse_test.go

30 lines
687 B
Go
Raw Normal View History

package spacecollapse
2020-02-24 19:54:48 +00:00
import (
"fmt"
"testing"
"github.com/stretchr/testify/require"
)
func TestCollapseSpaces(t *testing.T) {
for i, tc := range []struct {
input string
output string
}{
{input: "", output: ""},
{input: "x", output: "x"},
{input: "Hello, World!", output: "Hello, World!"},
{input: "Привет,\tМир!", output: "Привет, Мир!"},
{input: "\r\n", output: " "},
{input: "\n\n", output: " "},
{input: "\t*", output: " *"},
{input: " \t \t ", output: " "},
{input: " \tx\t ", output: " x "},
} {
t.Run(fmt.Sprintf("#%v: %v", i, tc.input), func(t *testing.T) {
require.Equal(t, tc.output, CollapseSpaces(tc.input))
})
}
}