diff options
author | Dianne Hackborn <hackbod@google.com> | 2013-07-25 16:42:59 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2013-07-25 16:53:09 -0700 |
commit | 62d708f4dd8e2a8554df4967837df9896efeff7c (patch) | |
tree | ce65deb60a6e33a6fed2fd6ca3d6da820a15ffc0 /tests/ActivityTests | |
parent | 9deaa286d8db51cd53118b3c14a418c512cf55db (diff) | |
download | frameworks_base-62d708f4dd8e2a8554df4967837df9896efeff7c.zip frameworks_base-62d708f4dd8e2a8554df4967837df9896efeff7c.tar.gz frameworks_base-62d708f4dd8e2a8554df4967837df9896efeff7c.tar.bz2 |
Okay, I give in, add null key support to ArrayMap and ArraySet.
Change-Id: Iac5035f9c5884a9f9d5acb38132bb128d7a55249
Diffstat (limited to 'tests/ActivityTests')
-rw-r--r-- | tests/ActivityTests/src/com/google/android/test/activity/ArrayMapTests.java | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/tests/ActivityTests/src/com/google/android/test/activity/ArrayMapTests.java b/tests/ActivityTests/src/com/google/android/test/activity/ArrayMapTests.java index 9b54927..28e86bf 100644 --- a/tests/ActivityTests/src/com/google/android/test/activity/ArrayMapTests.java +++ b/tests/ActivityTests/src/com/google/android/test/activity/ArrayMapTests.java @@ -48,15 +48,17 @@ public class ArrayMapTests { OP_ADD, OP_ADD, OP_ADD, OP_ADD, OP_ADD, OP_ADD, OP_ADD, OP_ADD, OP_ADD, OP_ADD, OP_ADD, OP_ADD, OP_ADD, OP_ADD, OP_ADD, OP_ADD, OP_ADD, OP_ADD, + OP_ADD, OP_ADD, OP_ADD, OP_REM, OP_REM, OP_REM, OP_REM, OP_REM, OP_REM, OP_REM, OP_REM, OP_REM, + OP_REM, OP_REM, OP_REM, OP_REM, OP_REM, OP_REM, OP_REM, OP_REM, OP_REM, OP_REM, OP_REM, OP_REM, }; static int[] KEYS = new int[] { // General adding and removing. - 100, 1900, 600, 200, 1200, 1500, 1800, 100, 1900, + -1, 1900, 600, 200, 1200, 1500, 1800, 100, 1900, 2100, 300, 800, 600, 1100, 1300, 2000, 1000, 1400, - 600, 100, 1900, 600, 300, 2100, 200, 800, 800, + 600, -1, 1900, 600, 300, 2100, 200, 800, 800, 1800, 1500, 1300, 1100, 2000, 1400, 1000, 1200, 1900, // Shrink when removing item from end. @@ -74,7 +76,9 @@ public class ArrayMapTests { // Test hash collisions. 105, 106, 108, 104, 102, 102, 107, 5, 205, 4, 202, 203, 3, 5, 101, 109, 200, 201, + 0, -1, 100, 106, 108, 104, 102, 103, 105, 107, 101, 109, + -1, 100, 0, 4, 5, 3, 5, 200, 203, 202, 201, 205, }; @@ -87,6 +91,9 @@ public class ArrayMapTests { @Override public final boolean equals(Object o) { + if (o == null) { + return false; + } return mValue == ((ControlledHash)o).mValue; } @@ -277,20 +284,21 @@ public class ArrayMapTests { Integer oldArray; boolean hashChanged; boolean arrayChanged; + ControlledHash key = KEYS[i] < 0 ? null : new ControlledHash(KEYS[i]); switch (OPS[i]) { case OP_ADD: Log.i("test", "Adding key: " + KEYS[i]); - oldHash = hashMap.put(new ControlledHash(KEYS[i]), i); - oldArray = arrayMap.put(new ControlledHash(KEYS[i]), i); - hashChanged = hashSet.add(new ControlledHash(KEYS[i])); - arrayChanged = arraySet.add(new ControlledHash(KEYS[i])); + oldHash = hashMap.put(key, i); + oldArray = arrayMap.put(key, i); + hashChanged = hashSet.add(key); + arrayChanged = arraySet.add(key); break; case OP_REM: Log.i("test", "Removing key: " + KEYS[i]); - oldHash = hashMap.remove(new ControlledHash(KEYS[i])); - oldArray = arrayMap.remove(new ControlledHash(KEYS[i])); - hashChanged = hashSet.remove(new ControlledHash(KEYS[i])); - arrayChanged = arraySet.remove(new ControlledHash(KEYS[i])); + oldHash = hashMap.remove(key); + oldArray = arrayMap.remove(key); + hashChanged = hashSet.remove(key); + arrayChanged = arraySet.remove(key); break; default: Log.e("test", "Bad operation " + OPS[i] + " @ " + i); |