MCPcopy
hub / github.com/jesseduffield/lazygit / TestLimitStr

Function TestLimitStr

pkg/utils/slice_test.go:176–232  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

174}
175
176func TestLimitStr(t *testing.T) {
177 for _, test := range []struct {
178 values string
179 limit int
180 want string
181 }{
182 {
183 values: "",
184 limit: 10,
185 want: "",
186 },
187 {
188 values: "",
189 limit: 0,
190 want: "",
191 },
192 {
193 values: "a",
194 limit: 1,
195 want: "a",
196 },
197 {
198 values: "ab",
199 limit: 2,
200 want: "ab",
201 },
202 {
203 values: "abc",
204 limit: 3,
205 want: "abc",
206 },
207 {
208 values: "abcd",
209 limit: 3,
210 want: "abc",
211 },
212 {
213 values: "abcde",
214 limit: 3,
215 want: "abc",
216 },
217 {
218 values: "あいう",
219 limit: 1,
220 want: "あ",
221 },
222 {
223 values: "あいう",
224 limit: 2,
225 want: "あい",
226 },
227 } {
228 if got := LimitStr(test.values, test.limit); !assert.EqualValues(t, got, test.want) {
229 t.Errorf("LimitString(%v, %d) = %v; want %v", test.values, test.limit, got, test.want)
230 }
231 }
232}
233

Callers

nothing calls this directly

Calls 2

LimitStrFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected