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

Function TestStringToSlice

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

Source from the content-addressed store, hash-verified

122}
123
124func TestStringToSlice(t *testing.T) {
125 tests := []struct {
126 name string
127 input string
128 expected []string
129 }{
130 {
131 name: "no element",
132 input: "",
133 expected: []string{""},
134 },
135 {
136 name: "one element",
137 input: "maguro",
138 expected: []string{"maguro"},
139 },
140 {
141 name: "comma separated",
142 input: "maguro,otoro",
143 expected: []string{"maguro", "otoro"},
144 },
145 {
146 name: "with spaces",
147 input: "maguro ",
148 expected: []string{"maguro"},
149 },
150 {
151 name: "comma separated with spaces",
152 input: "maguro , otoro, tamago",
153 expected: []string{"maguro", "otoro", "tamago"},
154 },
155 {
156 name: "space separated",
157 input: "maguro otoro tamago",
158 expected: []string{"magurootorotamago"},
159 },
160 }
161
162 for _, tt := range tests {
163 t.Run(tt.name, func(t *testing.T) {
164 assert.Equal(t, tt.expected, StringToSlice(tt.input))
165 })
166 }
167}
168
169func TestSliceToString(t *testing.T) {
170 tests := []struct {

Callers

nothing calls this directly

Calls 2

StringToSliceFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected