mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-19 05:30:43 +00:00
make a new collection if given a null one as input.
This commit is contained in:
@ -22,9 +22,11 @@
|
||||
package com.kingsrook.qqq.backend.core.utils.collections;
|
||||
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import com.kingsrook.qqq.backend.core.BaseTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@ -48,4 +50,22 @@ class MutableListTest extends BaseTest
|
||||
list.remove(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
@Test
|
||||
void testNullInput()
|
||||
{
|
||||
List<Integer> list = new MutableList<>(null);
|
||||
list.add(1);
|
||||
assertEquals(1, list.size());
|
||||
|
||||
MutableList<Integer> mutableList = new MutableList<>(null, LinkedList::new);
|
||||
mutableList.add(1);
|
||||
assertEquals(1, mutableList.size());
|
||||
assertEquals(LinkedList.class, mutableList.getUnderlyingList().getClass());
|
||||
}
|
||||
|
||||
}
|
@ -22,9 +22,11 @@
|
||||
package com.kingsrook.qqq.backend.core.utils.collections;
|
||||
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import com.kingsrook.qqq.backend.core.BaseTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@ -48,4 +50,22 @@ class MutableMapTest extends BaseTest
|
||||
map.putAll(Map.of("c", 3, "d", 4));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
@Test
|
||||
void testNullInput()
|
||||
{
|
||||
Map<Integer, String> map = new MutableMap<>(null);
|
||||
map.put(1, "one");
|
||||
assertEquals(1, map.size());
|
||||
|
||||
MutableMap<Integer, String> mutableMap = new MutableMap<>(null, LinkedHashMap::new);
|
||||
mutableMap.put(1, "uno");
|
||||
assertEquals(1, mutableMap.size());
|
||||
assertEquals(LinkedHashMap.class, mutableMap.getUnderlyingMap().getClass());
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user