(t *testing.T)
| 107 | } |
| 108 | |
| 109 | func TestTruncateString(t *testing.T) { |
| 110 | tests := []struct { |
| 111 | input string |
| 112 | maxLen int |
| 113 | expected string |
| 114 | }{ |
| 115 | {"hello", 10, "hello"}, |
| 116 | {"hello world", 5, "he..."}, |
| 117 | {"", 5, ""}, |
| 118 | {"abc", 3, "abc"}, |
| 119 | {"abcd", 3, "..."}, |
| 120 | } |
| 121 | |
| 122 | for _, tt := range tests { |
| 123 | result := truncateString(tt.input, tt.maxLen) |
| 124 | if result != tt.expected { |
| 125 | t.Errorf("truncateString(%q, %d) = %q, want %q", tt.input, tt.maxLen, result, tt.expected) |
| 126 | } |
| 127 | } |
| 128 | } |
nothing calls this directly
no test coverage detected