@Test public void testMinMax() { NumberDictionaryBuilder builder = new NumberDictionaryBuilder(); builder.addValue("" + Long.MAX_VALUE); builder.addValue("" + Long.MIN_VALUE); NumberDictionary<String> dict = builder.build(0); int minId = dict.getIdFromValue("" + Long.MIN_VALUE); int maxId = dict.getIdFromValue("" + Long.MAX_VALUE); assertEquals(0, minId); assertEquals(1, maxId); }
dict.getIdFromValue(randStr, -1); fail(); } catch (IllegalArgumentException ex) { assertEquals(expectedLowerId, dict.getIdFromValue(randStr, -1)); dict.getIdFromValue(randStr, 1); fail(); } catch (IllegalArgumentException ex) { assertEquals(expectedHigherId, dict.getIdFromValue(randStr, 1));
@Ignore @SuppressWarnings("unchecked") @Test public void testEmptyInput() throws IOException { String[] ints = new String[] { "", "0", "5", "100", "13" }; // check "" is treated as NULL, not a code of dictionary Dictionary<?> dict = DictionaryGenerator.buildDictionary(DataType.getType("integer"), new IterableDictionaryValueEnumerator(ints)); assertEquals(4, dict.getSize()); final int id = ((NumberDictionary<String>) dict).getIdFromValue(""); assertEquals(id, dict.nullId()); }
dict.getIdFromValue(randStr, -1); fail(); } catch (IllegalArgumentException ex) { assertEquals(expectedLowerId, dict.getIdFromValue(randStr, -1)); dict.getIdFromValue(randStr, 1); fail(); } catch (IllegalArgumentException ex) { assertEquals(expectedHigherId, dict.getIdFromValue(randStr, 1));