From be34a9a809042618cf06903de971b5fabcab365d Mon Sep 17 00:00:00 2001 From: asdf Date: Thu, 5 Sep 2019 21:52:12 +1000 Subject: [PATCH] identified more issues, added tests --- cui/cui_test.go | 73 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 3 deletions(-) diff --git a/cui/cui_test.go b/cui/cui_test.go index 0c3f198..dc719ae 100644 --- a/cui/cui_test.go +++ b/cui/cui_test.go @@ -13,17 +13,84 @@ func Test_wrapLines_doesnt_break_indents(t *testing.T) { linelength int }{ { - //20 character input - should not wrap + //indented long word - 20 characters - should not wrap []string{indent + "012345678"}, []string{indent + "012345678"}, 20, }, { - //21 character input - should wrap - []string{indent + "0123456789"}, + //indented long word - 21 characters - should wrap []string{indent + "0123456789"}, + []string{indent + "012345678", indent + "9"}, 20, }, + { + //indented really long word - should wrap + []string{indent + "0123456789zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"}, + []string{ + indent + "012345678", + indent + "9zzzzzzzz", + indent + "zzzzzzzzz", + indent + "zzzzzzzzz", + indent + "zzzzz"}, + 20, + }, { + //non-indented long word - 20 characters - should not wrap + []string{"01234567890123456789"}, + []string{"01234567890123456789"}, + 20, + }, + { + //non-indented long word - 21 characters - should wrap + []string{"01234567890123456789a"}, + []string{"01234567890123456789", "a"}, + 20, + }, + { + //non-indented really long word - should wrap + []string{"01234567890123456789zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"}, + []string{ + "01234567890123456789", + "zzzzzzzzzzzzzzzzzzzz", + "zzzzzzzzzzzzzzzzzzzz", + "zzzzzzzzzzzzzzzzzzzz", + "zzzz"}, + 20, + }, + { + //indented normal sentence - 20 characters - should not wrap + []string{indent + "it is her"}, + []string{indent + "it is her"}, + 20, + }, + { + //indented normal sentence - more than 20 characters - should wrap + []string{indent + "it is her favourite thing in the world"}, + []string{ + indent + "it is her", + indent + "favourite", + indent + "thing in", + indent + "the world", + }, + 20, + }, + { + //non-indented normal sentence - 20 characters - should not wrap + []string{"it is her fav thingy"}, + []string{"it is her fav thingy"}, + 20, + }, + { + //non-indented normal sentence - more than 20 characters - should wrap + []string{"it is her favourite thing in the world"}, + []string{ + "it is her favourite", + "thing in the world", + }, + 20, + }, + //TODO further tests + //lines that are just spaces don't get misidentified as indents and then mangled } for _, table := range tables {