@Test public void testTermCodes() { TermCodes.reset(); TObjectIntHashMap<String> check = new TObjectIntHashMap<String>(); final int termsLength = terms.length; for (int i = 0; i < termsLength; i++) { int id = TermCodes.getCode(terms[i]); check.put(terms[i], id); } int code; for (int j = 0; j < 1000000; j++) { for (int i = 0; i < termsLength; i++) { code = TermCodes.getCode(terms[i]); assertEquals(check.get(terms[i]), code); } } // TODO: get a new term, then check that the new id is unique }
@Test public void testTermCodesPut() { TermCodes.reset(); final int termsLength = terms.length; TObjectIntHashMap<String> check = new TObjectIntHashMap<String>(); for (int i = 0; i < termsLength; i++) { TermCodes.setTermCode(terms[i], i); check.put(terms[i], i); } for (int j = 0; j < 1000000; j++) { for (int i = 0; i < termsLength; i++) { int code = TermCodes.getCode(terms[i]); assertEquals(check.get(terms[i]), code); } } }