You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by rw...@apache.org on 2018/04/23 19:42:36 UTC
svn commit: r1829929 -
/pivot/trunk/core/test/org/apache/pivot/collections/test/DictionaryTest.java
Author: rwhitcomb
Date: Mon Apr 23 19:42:36 2018
New Revision: 1829929
URL: http://svn.apache.org/viewvc?rev=1829929&view=rev
Log:
PIVOT-999: Add two new default methods to Dictionary:
* containsAny(K...) that will check if any of the given keys are in the dictionary.
* getFirst(K...) that will retrieve the first value for which "containsKey" is true.
Add tests of these new methods to DictionaryTest.
Modified:
pivot/trunk/core/test/org/apache/pivot/collections/test/DictionaryTest.java
Modified: pivot/trunk/core/test/org/apache/pivot/collections/test/DictionaryTest.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/test/org/apache/pivot/collections/test/DictionaryTest.java?rev=1829929&r1=1829928&r2=1829929&view=diff
==============================================================================
--- pivot/trunk/core/test/org/apache/pivot/collections/test/DictionaryTest.java (original)
+++ pivot/trunk/core/test/org/apache/pivot/collections/test/DictionaryTest.java Mon Apr 23 19:42:36 2018
@@ -54,4 +54,14 @@ public class DictionaryTest {
assertEquals(map.getColor("black"), Color.BLACK);
}
+ @Test
+ public void anyTest() {
+ HashMap<String, Integer> map = new HashMap<>();
+ map.put("one", 1);
+ map.put("two", 2);
+ map.put("three", 300);
+ assertEquals(map.containsAny("a", "b", "one"), true);
+ Integer first = map.getFirst("c", "d", "two");
+ assertEquals(first.intValue(), 2);
+ }
}