1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
package shared
import (
"testing"
)
func TestEllipticalTruncate(t *testing.T) {
for _, tc := range []struct {
maxLen int
want string
}{
{0, "…"},
{1, "1…"},
{2, "1…"},
{3, "1 2…"},
{5, "1 2 3"},
} {
if got := TruncateWithEllipsis("1 2 3", tc.maxLen); got != tc.want {
t.Errorf("TruncateWithEllipsis(%q, %d) = %q, want %q", "1 2 3", tc.maxLen, got, tc.want)
}
}
}
|