01: /*
02: * Copyright(c) 2007, NEXVU Technologies
03: * All rights reserved.
04: */
05: package gnu.trove;
06:
07: import junit.framework.TestCase;
08:
09: import java.util.Arrays;
10: import java.util.List;
11:
12: /**
13: *
14: */
15: public class P2OHashMapTest extends TestCase {
16: public P2OHashMapTest(String name) {
17: super (name);
18: }
19:
20: public void testGetValues() {
21: TIntObjectHashMap<String> map = new TIntObjectHashMap<String>();
22:
23: map.put(1, "one");
24: map.put(2, "two");
25: map.put(3, "three");
26: map.put(4, "four");
27:
28: // Exact size
29: String[] template = new String[map.size()];
30: String[] values = map.getValues(template);
31: assertSame(template, values);
32:
33: List<String> list = Arrays.asList(values);
34: assertTrue(list.contains("one"));
35: assertTrue(list.contains("two"));
36: assertTrue(list.contains("three"));
37: assertTrue(list.contains("four"));
38:
39: // Zero length
40: template = new String[0];
41: values = map.getValues(template);
42: assertNotSame(template, values);
43:
44: list = Arrays.asList(values);
45: assertTrue(list.contains("one"));
46: assertTrue(list.contains("two"));
47: assertTrue(list.contains("three"));
48: assertTrue(list.contains("four"));
49:
50: // Longer than needed
51: template = new String[10];
52: values = map.getValues(template);
53: assertSame(template, values);
54:
55: list = Arrays.asList(values);
56: assertTrue(list.contains("one"));
57: assertTrue(list.contains("two"));
58: assertTrue(list.contains("three"));
59: assertTrue(list.contains("four"));
60: }
61: }
|