You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2019/10/29 14:21:43 UTC
[commons-collections] branch master updated: Test subMap and
tailMap (#94)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-collections.git
The following commit(s) were added to refs/heads/master by this push:
new 82cfa66 Test subMap and tailMap (#94)
82cfa66 is described below
commit 82cfa665a054310fe1389195896a35a01cd536ba
Author: dota17 <50...@users.noreply.github.com>
AuthorDate: Tue Oct 29 22:21:36 2019 +0800
Test subMap and tailMap (#94)
* add a junit for the HeadMap in the UnmodifiableSortedMapTest
* add junit for the subMap and tailMap in the UnmodifiableSortedMapTest
---
.../map/UnmodifiableSortedMapTest.java | 35 ++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/src/test/java/org/apache/commons/collections4/map/UnmodifiableSortedMapTest.java b/src/test/java/org/apache/commons/collections4/map/UnmodifiableSortedMapTest.java
index b0844bb..0101ada 100644
--- a/src/test/java/org/apache/commons/collections4/map/UnmodifiableSortedMapTest.java
+++ b/src/test/java/org/apache/commons/collections4/map/UnmodifiableSortedMapTest.java
@@ -86,6 +86,41 @@ public class UnmodifiableSortedMapTest<K, V> extends AbstractSortedMapTest<K, V>
final SortedMap<K, V> m = new TreeMap<>();
// "again" is the first key of the map
assertSame(m.isEmpty(), map.headMap((K) "again").isEmpty());
+ assertSame(18, map.size());
+ // "you" is the last key of the map
+ assertSame(17, map.headMap((K) "you").size());
+ // "we'll" is the before key of "you"
+ assertSame(16, map.headMap((K) "we'll").size());
+ }
+
+ //-----------------------------------------------------------------------
+
+ public void testTailMap() {
+ final SortedMap<K, V> map = makeFullMap();
+
+ assertSame(18, map.size());
+ // "you" is the last key of the map
+ assertSame(1, map.tailMap((K) "you").size());
+ // "we'll" is the before key of "you"
+ assertSame(2, map.tailMap((K) "we'll").size());
+ // "again" is the first key of the map
+ assertSame(18, map.tailMap((K) "again").size());
+ }
+
+ //-----------------------------------------------------------------------
+
+ public void testSubMap() {
+ final SortedMap<K, V> map = makeFullMap();
+
+ assertSame(18, map.size());
+ // get the sub map from again to you(exclusive)
+ assertSame(17, map.subMap((K) "again", (K) "you").size());
+ // get the sub map from again to we'll(exclusive)
+ assertSame(16, map.subMap((K) "again", (K) "we'll").size());
+ // "again" is the first key of the map
+ assertSame(0, map.subMap((K) "again", (K) "again").size());
+
+ assertSame(map.headMap((K)"you").size(), map.subMap((K) "again", (K) "you").size());
}
//-----------------------------------------------------------------------