garydgregory commented on code in PR #669:
URL:
https://github.com/apache/commons-collections/pull/669#discussion_r2649128105
##########
src/test/java/org/apache/commons/collections4/MultiMapUtilsTest.java:
##########
@@ -118,6 +118,50 @@ void testGetValuesAsSet() {
assertEquals(new HashSet<>(Arrays.asList(values)), set);
}
+ @Test
+ void testGetValuesAsBagIsSafeCopy() {
+ final String[] values = { "v1", "v2", "v3" };
+ final MultiValuedMap<String, String> map = new
ArrayListValuedHashMap<>();
+ for (final String val : values) {
+ map.put("key1", val);
+ map.put("key1", val);
+ }
+
+ final Bag<String> bag = MultiMapUtils.getValuesAsBag(map, "key1");
+ bag.add("v4");
+ assertFalse(map.containsMapping("key1", "v4"));
+ assertEquals(6, MultiMapUtils.getValuesAsBag(map, "key1").size());
+ }
+
+ @Test
+ void testGetValuesAsListIsSafeCopy() {
+ final String[] values = { "v1", "v2", "v3" };
+ final MultiValuedMap<String, String> map = new
ArrayListValuedHashMap<>();
+ for (final String val : values) {
+ map.put("key1", val);
+ }
+
+ final List<String> list = MultiMapUtils.getValuesAsList(map, "key1");
+ list.add("v4");
+ assertFalse(map.containsMapping("key1", "v4"));
+ assertEquals(Arrays.asList(values), MultiMapUtils.getValuesAsList(map,
"key1"));
+ }
+
+ @Test
+ void testGetValuesAsSetIsSafeCopy() {
Review Comment:
This test doesn't prove anything about the changes in `main` because it
passes without changes to `main`.
##########
src/test/java/org/apache/commons/collections4/MultiMapUtilsTest.java:
##########
@@ -118,6 +118,50 @@ void testGetValuesAsSet() {
assertEquals(new HashSet<>(Arrays.asList(values)), set);
}
+ @Test
+ void testGetValuesAsBagIsSafeCopy() {
+ final String[] values = { "v1", "v2", "v3" };
+ final MultiValuedMap<String, String> map = new
ArrayListValuedHashMap<>();
+ for (final String val : values) {
+ map.put("key1", val);
+ map.put("key1", val);
+ }
+
+ final Bag<String> bag = MultiMapUtils.getValuesAsBag(map, "key1");
+ bag.add("v4");
+ assertFalse(map.containsMapping("key1", "v4"));
+ assertEquals(6, MultiMapUtils.getValuesAsBag(map, "key1").size());
+ }
+
+ @Test
+ void testGetValuesAsListIsSafeCopy() {
Review Comment:
OTOH, this test _does_ prove the changes in `main` matter because it fails
without changes to `main`.
##########
src/test/java/org/apache/commons/collections4/MultiMapUtilsTest.java:
##########
@@ -118,6 +118,50 @@ void testGetValuesAsSet() {
assertEquals(new HashSet<>(Arrays.asList(values)), set);
}
+ @Test
+ void testGetValuesAsBagIsSafeCopy() {
Review Comment:
This test doesn't prove anything about the changes in `main` because it
passes without changes to `main`.
--
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]