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

Function TestStringSetUnion

pkg/set/stringset_test.go:240–261  ·  view source on GitHub ↗

StringSet.Union() 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

238
239// StringSet.Union() is called with series of cases for valid and erroneous inputs and the result is validated.
240func TestStringSetUnion(t *testing.T) {
241 testCases := []struct {
242 set1 StringSet
243 set2 StringSet
244 expectedResult StringSet
245 }{
246 // Test union same values.
247 {CreateStringSet("foo", "bar"), CreateStringSet("foo", "bar"), CreateStringSet("foo", "bar")},
248 // Test union same values in second set.
249 {CreateStringSet("foo", "bar", "baz"), CreateStringSet("foo", "bar"), CreateStringSet("foo", "bar", "baz")},
250 // Test union different values in both set.
251 {CreateStringSet("foo", "baz"), CreateStringSet("baz", "bar"), CreateStringSet("foo", "baz", "bar")},
252 // Test union all different values.
253 {CreateStringSet("foo", "baz"), CreateStringSet("poo", "bar"), CreateStringSet("foo", "baz", "poo", "bar")},
254 }
255
256 for _, testCase := range testCases {
257 if result := testCase.set1.Union(testCase.set2); !result.Equals(testCase.expectedResult) {
258 t.Fatalf("expected: %s, got: %s", testCase.expectedResult, result)
259 }
260 }
261}
262
263// StringSet.MarshalJSON() is called with series of cases for valid and erroneous inputs and the result is validated.
264func TestStringSetMarshalJSON(t *testing.T) {

Callers

nothing calls this directly

Calls 3

CreateStringSetFunction · 0.85
UnionMethod · 0.45
EqualsMethod · 0.45

Tested by

no test coverage detected