MCPcopy Create free account
hub / github.com/algolia/cli / TestSliceToReadableString

Function TestSliceToReadableString

pkg/utils/utils_test.go:204–242  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

202}
203
204func TestSliceToReadableString(t *testing.T) {
205 tests := []struct {
206 name string
207 input []string
208 expected string
209 }{
210 {
211 name: "no element",
212 input: []string{""},
213 expected: "",
214 },
215 {
216 name: "one element",
217 input: []string{"maguro"},
218 expected: "maguro",
219 },
220 {
221 name: "two element",
222 input: []string{"maguro", "otoro"},
223 expected: "maguro and otoro",
224 },
225 {
226 name: "three element",
227 input: []string{"maguro", "otoro", "tamago"},
228 expected: "maguro, otoro and tamago",
229 },
230 {
231 name: "five element",
232 input: []string{"one", "two", "three", "four", "five"},
233 expected: "one, two, three, four and five",
234 },
235 }
236
237 for _, tt := range tests {
238 t.Run(tt.name, func(t *testing.T) {
239 assert.Equal(t, tt.expected, SliceToReadableString(tt.input))
240 })
241 }
242}

Callers

nothing calls this directly

Calls 2

SliceToReadableStringFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected