diff options
| author | Hubert Hirtz <hubert@hirtzfr.eu> | 2020-08-03 23:04:51 +0200 |
|---|---|---|
| committer | Hubert Hirtz <hubert@hirtzfr.eu> | 2020-08-04 11:12:32 +0200 |
| commit | 3c8dceaf96964eae12a06abb04035cf184bdbf61 (patch) | |
| tree | e3de1c86b31a488ccf687a27d57d7d7e3e463f6e /ui/style_test.go | |
| parent | Improve line editing (diff) | |
Rework display
- Put timestamps, nicks and messages into separate columns
- Print a bar in the "typing" row
- Fix word wrapping
- Improve channel list display
Diffstat (limited to 'ui/style_test.go')
| -rw-r--r-- | ui/style_test.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/ui/style_test.go b/ui/style_test.go new file mode 100644 index 0000000..ae478ab --- /dev/null +++ b/ui/style_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) +} |
