util_test.go
1package diffview
2
3import (
4 "testing"
5)
6
7func TestPad(t *testing.T) {
8 tests := []struct {
9 input any
10 width int
11 expected string
12 }{
13 {7, 2, " 7"},
14 {7, 3, " 7"},
15 {"a", 2, " a"},
16 {"a", 3, " a"},
17 {"…", 2, " …"},
18 {"…", 3, " …"},
19 }
20
21 for _, tt := range tests {
22 result := pad(tt.input, tt.width)
23 if result != tt.expected {
24 t.Errorf("expected %q, got %q", tt.expected, result)
25 }
26 }
27}