1 package org.unicode.cldr.unittest.web;
2 
3 import java.util.HashSet;
4 import java.util.Set;
5 
6 import org.unicode.cldr.web.IntHash;
7 
8 import com.ibm.icu.dev.test.TestFmwk;
9 
10 public class TestIntHash extends TestFmwk {
11     // static TestInfo testInfo = TestInfo.getInstance();
12 
main(String[] args)13     public static void main(String[] args) {
14         new TestIntHash().run(args);
15     }
16 
17     public static final int TEST_COUNT = 10000;
18 
TestGetPut()19     public void TestGetPut() {
20         IntHash<Integer> hash = new IntHash<>();
21         Set<Integer> s = new HashSet<>();
22         for (int i = 0; i < TEST_COUNT; i++) {
23             int n = (i * 12) + i;
24             hash.put(n, n);
25             s.add(n);
26             hash.put(i, i);
27             s.add(i);
28         }
29 
30         int ii = 0;
31         for (int n : s) {
32             int j = hash.get(n);
33             if (j != n) {
34                 errln("Error: hash.get(" + n + ") returned " + j + "\n");
35             } else {
36                 ++ii;
37                 // log(".."+n+(((ii)%30)==0?"\n":""));
38             }
39         }
40         log("Tested " + ii + " values");
41     }
42 
43 }
44