Start work on more sophisticated indent+wrap implementation
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
// License: GPLv3 Copyright: 2022, Kovid Goyal, <kovid at kovidgoyal.net>
|
||||
|
||||
package cli
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestFormatWithIndent(t *testing.T) {
|
||||
var output strings.Builder
|
||||
indent := "__"
|
||||
screen_width := 11
|
||||
|
||||
run := func(text string, expected ...string) {
|
||||
output.Reset()
|
||||
q := indent + strings.Join(expected, "\n"+indent) + "\n"
|
||||
format_with_indent(&output, text, indent, screen_width)
|
||||
if output.String() != q {
|
||||
t.Fatalf("expected != actual: %#v != %#v", q, output.String())
|
||||
}
|
||||
}
|
||||
run("testing \x1b[31mstyled\x1b[m", "testing ", "\x1b[31mstyled\x1b[m")
|
||||
run("testing\n\ntwo", "testing", "", "two")
|
||||
run("testing\n \ntwo", "testing", "", "two")
|
||||
}
|
||||
Reference in New Issue
Block a user