From 83e1f4565362bee14544dfd6c25fb930f0b25073 Mon Sep 17 00:00:00 2001 From: Joel Leitch Date: Thu, 4 Apr 2013 22:29:29 +0000 Subject: [PATCH] Re-add non-comparable key tests to LinkedHashTreeMap. --- .../gson/internal/LinkedHashTreeMapTest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gson/src/test/java/com/google/gson/internal/LinkedHashTreeMapTest.java b/gson/src/test/java/com/google/gson/internal/LinkedHashTreeMapTest.java index 897b7429..822afe96 100644 --- a/gson/src/test/java/com/google/gson/internal/LinkedHashTreeMapTest.java +++ b/gson/src/test/java/com/google/gson/internal/LinkedHashTreeMapTest.java @@ -59,6 +59,20 @@ public final class LinkedHashTreeMapTest extends TestCase { } } + public void testPutNonComparableKeyFails() { + LinkedHashTreeMap map = new LinkedHashTreeMap(); + try { + map.put(new Object(), "android"); + } catch (ClassCastException expected) {} + } + + @SuppressWarnings("SuspiciousMethodCalls") + public void testContainsNonComparableKeyReturnsFalse() { + LinkedHashTreeMap map = new LinkedHashTreeMap(); + map.put("a", "android"); + assertFalse(map.containsKey(new Object())); + } + public void testContainsNullKeyFails() { LinkedHashTreeMap map = new LinkedHashTreeMap(); map.put("a", "android");