lucene-multilingual

Multilingual enhancements for the Lucene text search library
git clone https://code.djc.id.au/git/lucene-multilingual/

src/test/java/au/com/miskinhill/search/analysis/TrieUnitTest.java (1337B) - raw

      1 package au.com.miskinhill.search.analysis;
      2 
      3 import static org.junit.Assert.*;
      4 
      5 import org.junit.Test;
      6 
      7 import au.com.miskinhill.search.analysis.Trie;
      8 
      9 public class TrieUnitTest {
     10 	
     11 	@Test
     12 	public void testEmptyTrie() {
     13 		Trie<String> t = new Trie<String>("asdf");
     14 		assertEquals("asdf", t.get(""));
     15 		assertEquals("asdf", t.get("somekey"));
     16 	}
     17 	
     18 	@Test
     19 	public void testNoPrefix() {
     20 		Trie<String> t = new Trie<String>("root");
     21 		t.put("en", "English");
     22 		t.put("de", "Deutsch");
     23 		assertEquals("root", t.get("pl"));
     24 	}
     25 	
     26 	@Test
     27 	public void testPrefixButNoMatch() {
     28 		Trie<String> t = new Trie<String>("root");
     29 		t.put("en", "English");
     30 		t.put("de", "Deutsch");
     31 		assertEquals("root", t.get("es"));
     32 	}
     33 	
     34 	@Test
     35 	public void testPrefixMatch() {
     36 		Trie<String> t = new Trie<String>("root");
     37 		t.put("en", "English");
     38 		t.put("de", "Deutsch");
     39 		assertEquals("English", t.get("en-AU"));
     40 	}
     41 	
     42 	@Test
     43 	public void testExactMatch() {
     44 		Trie<String> t = new Trie<String>("root");
     45 		t.put("en", "English");
     46 		t.put("en-AU", "Australian");
     47 		t.put("de", "Deutsch");
     48 		assertEquals("Australian", t.get("en-AU"));
     49 	}
     50 	
     51 	@Test
     52 	public void testDifferentPrefixMatch() {
     53 		Trie<String> t = new Trie<String>("root");
     54 		t.put("en", "English");
     55 		t.put("en-AU", "Australian");
     56 		t.put("de", "Deutsch");
     57 		assertEquals("English", t.get("en-GB"));
     58 	}
     59 
     60 }