File: sliceutil_test.go

package info (click to toggle)
golang-k8s-sigs-kustomize-kyaml 0.20.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,180 kB
  • sloc: makefile: 220; sh: 68
file content (25 lines) | stat: -rw-r--r-- 809 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright 2021 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0

package sliceutil

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestContains(t *testing.T) {
	assert.True(t, Contains([]string{"foo", "bar"}, "bar"))
	assert.False(t, Contains([]string{"foo", "bar"}, "baz"))
	assert.False(t, Contains([]string{}, "bar"))
	assert.False(t, Contains([]string{}, ""))
}

func TestRemove(t *testing.T) {
	assert.Equal(t, Remove([]string{"foo", "bar"}, "bar"), []string{"foo"})
	assert.Equal(t, Remove([]string{"foo", "bar", "foo"}, "foo"), []string{"bar", "foo"})
	assert.Equal(t, Remove([]string{"foo"}, "foo"), []string{})
	assert.Equal(t, Remove([]string{}, "foo"), []string{})
	assert.Equal(t, Remove([]string{"foo", "bar", "foo"}, "baz"), []string{"foo", "bar", "foo"})
}