go.mondoo.com/cnquery@v0.0.0-20231005093811-59568235f6ea/utils/stringx/intersection_test.go (about) 1 // Copyright (c) Mondoo, Inc. 2 // SPDX-License-Identifier: BUSL-1.1 3 4 package stringx_test 5 6 import ( 7 "testing" 8 9 "github.com/stretchr/testify/assert" 10 "go.mondoo.com/cnquery/utils/stringx" 11 ) 12 13 func TestIntersection(t *testing.T) { 14 a := []string{"a", "b", "c"} 15 b := []string{"b", "c", "d", "f"} 16 17 actual := stringx.Intersection(a, b) 18 expected := []string{"b", "c"} 19 assert.ElementsMatch(t, actual, expected) 20 } 21 22 func TestIntersectionNoOverlap(t *testing.T) { 23 a := []string{"a", "b", "c"} 24 b := []string{"d", "f"} 25 26 actual := stringx.Intersection(a, b) 27 assert.Empty(t, actual) 28 }