kinow commented on a change in pull request #281:
URL:
https://github.com/apache/commons-collections/pull/281#discussion_r818149695
##########
File path:
src/test/java/org/apache/commons/collections4/trie/PatriciaTrieTest.java
##########
@@ -274,14 +271,13 @@ public void testPrefixMap() {
map = trie.prefixMap("\0");
Assertions.assertTrue(map.isEmpty());
Assertions.assertEquals(0, map.size());
- try {
- final Object o = map.firstKey();
- Assertions.fail("got a first key: " + o);
- } catch(final NoSuchElementException nsee) {}
- try {
- final Object o = map.lastKey();
- Assertions.fail("got a last key: " + o);
- } catch(final NoSuchElementException nsee) {}
+
+ final SortedMap<String, String> map5 = map;
+ Assertions.assertThrows(NoSuchElementException.class, () ->
map5.firstKey());
+
+ final SortedMap<String, String> map6 = map;
+ Assertions.assertThrows(NoSuchElementException.class, () ->
map6.lastKey());
Review comment:
Ditto here.
##########
File path:
src/test/java/org/apache/commons/collections4/trie/PatriciaTrieTest.java
##########
@@ -243,28 +242,26 @@ public void testPrefixMap() {
map = trie.prefixMap("Ab");
Assertions.assertTrue(map.isEmpty());
Assertions.assertEquals(0, map.size());
- try {
- final Object o = map.firstKey();
- Assertions.fail("got a first key: " + o);
- } catch(final NoSuchElementException nsee) {}
- try {
- final Object o = map.lastKey();
- Assertions.fail("got a last key: " + o);
- } catch(final NoSuchElementException nsee) {}
+
+ final SortedMap<String, String> map1 = map;
+ Assertions.assertThrows(NoSuchElementException.class, () ->
map1.firstKey());
+
+ final SortedMap<String, String> map2 = map;
+ Assertions.assertThrows(NoSuchElementException.class, () ->
map2.lastKey());
+
iterator = map.values().iterator();
Assertions.assertFalse(iterator.hasNext());
map = trie.prefixMap("Albertooo");
Assertions.assertTrue(map.isEmpty());
Assertions.assertEquals(0, map.size());
- try {
- final Object o = map.firstKey();
- Assertions.fail("got a first key: " + o);
- } catch(final NoSuchElementException nsee) {}
- try {
- final Object o = map.lastKey();
- Assertions.fail("got a last key: " + o);
- } catch(final NoSuchElementException nsee) {}
+
+ final SortedMap<String, String> map3 = map;
+ Assertions.assertThrows(NoSuchElementException.class, () ->
map3.firstKey());
+
+ final SortedMap<String, String> map4 = map;
+ Assertions.assertThrows(NoSuchElementException.class, () ->
map4.lastKey());
Review comment:
Maybe keep the comments above. I don't know what first or last key
represent in this case, but I assume it could be useful to see that in the test
failure output (I guess that's why the original developer put them there).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]