| 8 | ) |
| 9 | |
| 10 | func Test_StringSliceCSV(t *testing.T) { |
| 11 | type TestStruct struct { |
| 12 | CSV StringSliceCSV `yaml:"csv"` |
| 13 | } |
| 14 | |
| 15 | var testStruct TestStruct |
| 16 | s := "a,b,c,d" |
| 17 | assert.Nil(t, testStruct.CSV.Set(s)) |
| 18 | |
| 19 | assert.Equal(t, []string{"a", "b", "c", "d"}, []string(testStruct.CSV)) |
| 20 | assert.Equal(t, s, testStruct.CSV.String()) |
| 21 | |
| 22 | expected := []byte(`csv: a,b,c,d |
| 23 | `) |
| 24 | |
| 25 | actual, err := yaml.Marshal(testStruct) |
| 26 | assert.Nil(t, err) |
| 27 | assert.Equal(t, expected, actual) |
| 28 | |
| 29 | var testStruct2 TestStruct |
| 30 | |
| 31 | err = yaml.Unmarshal(expected, &testStruct2) |
| 32 | assert.Nil(t, err) |
| 33 | assert.Equal(t, testStruct, testStruct2) |
| 34 | } |
| 35 | |
| 36 | func Test_EmptyStringSliceCSV(t *testing.T) { |
| 37 | type TestStruct struct { |