MCPcopy
hub / github.com/yusing/godoxy / TestStringToSlice

Function TestStringToSlice

internal/serialization/serialization_test.go:241–263  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

239}
240
241func TestStringToSlice(t *testing.T) {
242 t.Run("comma_separated", func(t *testing.T) {
243 dst := make([]string, 0)
244 convertible, err := ConvertString("a,b,c", reflect.ValueOf(&dst))
245 expect.True(t, convertible)
246 expect.NoError(t, err)
247 expect.Equal(t, dst, []string{"a", "b", "c"})
248 })
249 t.Run("yaml-like", func(t *testing.T) {
250 dst := make([]string, 0)
251 convertible, err := ConvertString("- a\n- b\n- c", reflect.ValueOf(&dst))
252 expect.True(t, convertible)
253 expect.NoError(t, err)
254 expect.Equal(t, dst, []string{"a", "b", "c"})
255 })
256 t.Run("single-line-yaml-like", func(t *testing.T) {
257 dst := make([]string, 0)
258 convertible, err := ConvertString("- a", reflect.ValueOf(&dst))
259 expect.True(t, convertible)
260 expect.NoError(t, err)
261 expect.Equal(t, dst, []string{"a"})
262 })
263}
264
265func TestStringToMap(t *testing.T) {
266 t.Run("yaml-like", func(t *testing.T) {

Callers

nothing calls this directly

Calls 1

ConvertStringFunction · 0.85

Tested by

no test coverage detected