diff options
author | 2021-03-27 19:04:05 +0000 | |
---|---|---|
committer | 2021-03-28 22:06:33 +0100 | |
commit | 1461c4dbcaca93880bf326346f74c5ff4e3b6376 (patch) | |
tree | d4db9adb72e63ae2b7c8fa16dc4b2920d76657e1 /android/util_test.go | |
parent | 32312eb75afe65dbe95c9668e5792d36ff529131 (diff) |
Add FilterListPred.
Test: cd build/soong; go test ./android
Change-Id: Ibbdd3cbdb822bd2e843096a22cdd08c827b70526
Diffstat (limited to 'android/util_test.go')
-rw-r--r-- | android/util_test.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/android/util_test.go b/android/util_test.go index fa26c77ac..09bec01cc 100644 --- a/android/util_test.go +++ b/android/util_test.go @@ -18,6 +18,7 @@ import ( "fmt" "reflect" "strconv" + "strings" "testing" ) @@ -299,6 +300,14 @@ func TestFilterList(t *testing.T) { } } +func TestFilterListPred(t *testing.T) { + pred := func(s string) bool { return strings.HasPrefix(s, "a/") } + AssertArrayString(t, "filter", FilterListPred([]string{"a/c", "b/a", "a/b"}, pred), []string{"a/c", "a/b"}) + AssertArrayString(t, "filter", FilterListPred([]string{"b/c", "a/a", "b/b"}, pred), []string{"a/a"}) + AssertArrayString(t, "filter", FilterListPred([]string{"c/c", "b/a", "c/b"}, pred), []string{}) + AssertArrayString(t, "filter", FilterListPred([]string{"a/c", "a/a", "a/b"}, pred), []string{"a/c", "a/a", "a/b"}) +} + func TestRemoveListFromList(t *testing.T) { input := []string{"a", "b", "c", "d", "a", "c", "d"} filter := []string{"a", "c"} |