diff options
author | 2023-04-27 19:34:08 +0000 | |
---|---|---|
committer | 2023-04-27 19:34:08 +0000 | |
commit | cc4da765113299fa11dcb1e651ec4ae33e6f8f9b (patch) | |
tree | 6f57185cd8799247ab9cca3db71da16e03ad9ef1 /android/util_test.go | |
parent | 8a8714c781175f8f1a6c189d919ee8b0ee8c1e27 (diff) |
Differentiate between empty and nil input
Previously, CopyOf on an empty list was returning nil. With the updates
to SortedUniqueStrings and FirstUniqueStrings, we need to differentiate
between empty lists and nil.
Test: m nothing
Change-Id: I91063ebbe5013cbda5d8f70efde4683c66581599
Diffstat (limited to 'android/util_test.go')
-rw-r--r-- | android/util_test.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/android/util_test.go b/android/util_test.go index 5584b38f7..a2ef58958 100644 --- a/android/util_test.go +++ b/android/util_test.go @@ -381,6 +381,14 @@ func TestRemoveFromList(t *testing.T) { } } +func TestCopyOfEmptyAndNil(t *testing.T) { + emptyList := []string{} + copyOfEmptyList := CopyOf(emptyList) + AssertBoolEquals(t, "Copy of an empty list should be an empty list and not nil", true, copyOfEmptyList != nil) + copyOfNilList := CopyOf(nil) + AssertBoolEquals(t, "Copy of a nil list should be a nil list and not an empty list", true, copyOfNilList == nil) +} + func ExampleCopyOf() { a := []string{"1", "2", "3"} b := CopyOf(a) |