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. Bug: 275313114 Test: m nothing (cherry picked from https://android-review.googlesource.com/q/commit:cc4da765113299fa11dcb1e651ec4ae33e6f8f9b) Merged-In: I91063ebbe5013cbda5d8f70efde4683c66581599 Change-Id: I91063ebbe5013cbda5d8f70efde4683c66581599
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user