diff options
author | Hubert Hirtz <hubert.hirtz@laposte.net> | 2020-06-04 22:55:15 +0200 |
---|---|---|
committer | Hubert Hirtz <hubert.hirtz@laposte.net> | 2020-06-04 22:55:15 +0200 |
commit | f7331d1c665bd997fe5bc41c6d375d30ea9f4457 (patch) | |
tree | fe3ba9f932ace2b8582fa0f9b903349aa44017cb /ui/width_test.go | |
parent | Fix color codes (diff) |
Buffers are now shown (mostly) correctly
senpai must now split on whitespace when drawing
Diffstat (limited to '')
-rw-r--r-- | ui/width_test.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/ui/width_test.go b/ui/width_test.go new file mode 100644 index 0000000..ae478ab --- /dev/null +++ b/ui/width_test.go @@ -0,0 +1,25 @@ +package ui + +import "testing" + +func assertStringWidth(t *testing.T, input string, expected int) { + actual := StringWidth(input) + if actual != expected { + t.Errorf("%q: expected width of %d got %d", input, expected, actual) + } +} + +func TestStringWidth(t *testing.T) { + assertStringWidth(t, "", 0) + + assertStringWidth(t, "hello", 5) + assertStringWidth(t, "\x02hello", 5) + assertStringWidth(t, "\x035hello", 5) + assertStringWidth(t, "\x0305hello", 5) + assertStringWidth(t, "\x0305,0hello", 5) + assertStringWidth(t, "\x0305,09hello", 5) + + assertStringWidth(t, "\x0305,hello", 6) + assertStringWidth(t, "\x03050hello", 6) + assertStringWidth(t, "\x0305,090hello", 6) +} |