MCPcopy
hub / github.com/minio/minio-go / TestStringSetToSlice

Function TestStringSetToSlice

pkg/set/stringset_test.go:329–350  ·  view source on GitHub ↗

StringSet.ToSlice() is called with series of cases for valid and erroneous inputs and the result is validated.

(t *testing.T)

Source from the content-addressed store, hash-verified

327
328// StringSet.ToSlice() is called with series of cases for valid and erroneous inputs and the result is validated.
329func TestStringSetToSlice(t *testing.T) {
330 testCases := []struct {
331 set StringSet
332 expectedResult string
333 }{
334 // Test empty set.
335 {NewStringSet(), `[]`},
336 // Test set with empty value.
337 {CreateStringSet(""), `[]`},
338 // Test set with value.
339 {CreateStringSet("foo"), `[foo]`},
340 // Test set with value.
341 {CreateStringSet("foo", "bar"), `[bar foo]`},
342 }
343
344 for _, testCase := range testCases {
345 sslice := testCase.set.ToSlice()
346 if str := fmt.Sprintf("%s", sslice); str != testCase.expectedResult {
347 t.Fatalf("expected: %s, got: %s", testCase.expectedResult, str)
348 }
349 }
350}
351
352func TestStringSet_UnmarshalJSON(t *testing.T) {
353 type args struct {

Callers

nothing calls this directly

Calls 3

NewStringSetFunction · 0.85
CreateStringSetFunction · 0.85
ToSliceMethod · 0.45

Tested by

no test coverage detected