01: package fitnesse.util;
02:
03: import java.util.*;
04:
05: import junit.framework.TestCase;
06:
07: public class CollectionsUtilTest extends TestCase {
08:
09: public void testCreateListNull() {
10: try {
11: CollectionsUtil.createList(null);
12: fail();
13: } catch (NullPointerException e) {
14: // pass
15: }
16: }
17:
18: public void testCreateListEmpty() {
19: List list = CollectionsUtil.createList(new Object[0]);
20: assertEquals(0, list.size());
21: }
22:
23: public void testCreateList() {
24: List list = CollectionsUtil.createList(new Object[] { "hello",
25: "world" });
26: assertEquals(2, list.size());
27: assertEquals("hello", list.get(0));
28: assertEquals("world", list.get(1));
29: }
30:
31: public void testCreateMapNull() {
32: try {
33: CollectionsUtil.createMap(null);
34: fail();
35: } catch (NullPointerException e) {
36: // pass
37: }
38: }
39:
40: public void testCreateMapEmpty() {
41: Map map = CollectionsUtil.createMap(new Object[0]);
42: assertEquals(0, map.size());
43: }
44:
45: public void testCreateMap() {
46: Map map = CollectionsUtil.createMap(new Object[] { "hello",
47: new Integer(1), "world", new Integer(2) });
48: assertEquals(2, map.size());
49: assertEquals(new Integer(1), map.get("hello"));
50: assertEquals(new Integer(2), map.get("world"));
51: }
52:
53: }
|