Mercurial > hg4j
comparison test/org/tmatesoft/hg/test/TestIntMap.java @ 278:55fad5e0e98b
Ensure capacity grows regardless of initial map size. Separate unit test
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Mon, 29 Aug 2011 23:31:37 +0200 |
parents | |
children | ee8264d80747 |
comparison
equal
deleted
inserted
replaced
277:74e7493a042a | 278:55fad5e0e98b |
---|---|
1 /* | |
2 * Copyright (c) 2011 TMate Software Ltd | |
3 * | |
4 * This program is free software; you can redistribute it and/or modify | |
5 * it under the terms of the GNU General Public License as published by | |
6 * the Free Software Foundation; version 2 of the License. | |
7 * | |
8 * This program is distributed in the hope that it will be useful, | |
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 * GNU General Public License for more details. | |
12 * | |
13 * For information on how to redistribute this software under | |
14 * the terms of a license other than GNU General Public License | |
15 * contact TMate Software at support@hg4j.com | |
16 */ | |
17 package org.tmatesoft.hg.test; | |
18 | |
19 import static org.junit.Assert.assertEquals; | |
20 | |
21 import org.junit.Test; | |
22 import org.tmatesoft.hg.internal.IntMap; | |
23 | |
24 /** | |
25 * | |
26 * @author Artem Tikhomirov | |
27 * @author TMate Software Ltd. | |
28 */ | |
29 public class TestIntMap { | |
30 | |
31 public static void main(String[] args) { | |
32 TestIntMap t = new TestIntMap(); | |
33 t.testBasic(); | |
34 } | |
35 | |
36 @Test | |
37 public void testBasic() { | |
38 IntMap<String> m = new IntMap<String>(2); | |
39 m.put(18, "18"); | |
40 m.put(1, "1"); | |
41 m.put(9, "9"); | |
42 m.put(20, "20"); | |
43 m.put(2, "2"); | |
44 m.put(3, "3"); | |
45 m.put(21, "21"); | |
46 m.put(15, "15"); | |
47 m.put(12, "12"); | |
48 m.put(11, "11"); | |
49 m.put(31, "31"); | |
50 assertEquals(11, m.size()); | |
51 assertEquals(1, m.firstKey()); | |
52 assertEquals(31, m.lastKey()); | |
53 int actualCount = 0; | |
54 for (int i = m.firstKey(); i <= m.lastKey(); i++) { | |
55 if (m.containsKey(i)) { | |
56 actualCount++; | |
57 assertEquals(m.get(i), Integer.toString(i)); | |
58 } | |
59 } | |
60 assertEquals(m.size(), actualCount); | |
61 } | |
62 } |