added unit test

This commit is contained in:
asdf 2019-09-10 21:06:14 +10:00
parent 0894827563
commit 864bb7c2c0
1 changed files with 29 additions and 0 deletions

View File

@ -38,6 +38,35 @@ func Test_wrapLines_space_preservation(t *testing.T) {
}
}
func Test_wrapLines_incorrect_wrapping_endash(t *testing.T) {
tables := []struct {
testinput []string
expectedoutput []string
linelength int
}{
{
//a specific test from cat's phlog that was wrapping and I'm not sure why
//TODO this test passes but in reality it does not
[]string{
" Suldusk Really cool dark folk/black metal sort of deal. The lead singer",
"is a tiny fairy of a person and she's very charming. It's the bass players",
},
[]string{
" Suldusk Really cool dark folk/black metal sort of deal. The lead singer",
"is a tiny fairy of a person and she's very charming. It's the bass players",
},
80,
},
}
for _, table := range tables {
output := wrapLines(table.testinput, table.linelength)
if !reflect.DeepEqual(output, table.expectedoutput) {
t.Errorf("Expected %v, got %v", table.expectedoutput, output)
}
}
}
func Benchmark_wrapLines(b *testing.B) {
teststring := []string{
"0123456789",