### Question:
LangProfile { public void add(String gram) { if (name == null || gram == null) return; int len = gram.length(); if (len < 1 || len > NGram.N_GRAM) return; ++n_words[len - 1]; if (freq.containsKey(gram)) { freq.put(gram, freq.get(gram) + 1); } else { freq.put(gram, 1); } } LangProfile();  LangProfile(String name); void add(String gram); void omitLessFreq(); void update(String text); public String name; public HashMap<String, Integer> freq; public int[] n_words; }### Answer:
@Test public final void testAdd() { LangProfile profile = new LangProfile("en"); profile.add("a"); assertEquals((int)profile.freq.get("a"), 1); profile.add("a"); assertEquals((int)profile.freq.get("a"), 2); profile.omitLessFreq(); }
@Test public final void testAddIllegally1() { LangProfile profile = new LangProfile(); profile.add("a"); assertEquals(profile.freq.get("a"), null); }
@Test public final void testAddIllegally2() { LangProfile profile = new LangProfile("en"); profile.add("a"); profile.add(""); profile.add("abcd"); assertEquals((int)profile.freq.get("a"), 1); assertEquals(profile.freq.get(""), null); assertEquals(profile.freq.get("abcd"), null); }