@Test
public void testBasicRules() {

    String needle = "needle";
    String neele = "neele";
    String needDle = "needDle";
    // equal strings have distance 0
    assertThat(levenshteinMatch(needle,needle).getDistance(), is(0));
    // appending or prepending adds 1 to the distance
    assertThat(levenshteinMatch(needle,needle + "a").getDistance(), is(1));
    assertThat(levenshteinMatch(needle, "a" + needle ).getDistance(), is(1));
    assertThat(levenshteinMatch(needle, "a" + needle + "a").getDistance(), is(2));
    assertThat(levenshteinMatch(needle, needDle).getDistance(), is(1));
    assertThat(levenshteinMatch(needDle, needle).getDistance(), is(1));
    // dropping adds 1 to the distance
    assertThat(levenshteinMatch(needle, neele).getDistance(), is(1));
    assertThat(levenshteinMatch(neele, needle).getDistance(), is(1));
    // should be able to find the best match
    assertThat(levenshteinMatch(needle, needle + " " + neele).getDistance(), is(0));
    assertThat(levenshteinMatch(needle, neele + " " + needle).getDistance(), is(0));
    // seperated by spaces does not change distance
    assertThat(levenshteinMatch(needle,needle + " a").getDistance(), is(0));
    assertThat(levenshteinMatch(needle, "a " + needle ).getDistance(), is(0));
    assertThat(levenshteinMatch(needle, "a" + needle + " a").getDistance(), is(1));
    assertThat(levenshteinMatch(needle, "a " + needle + "a").getDistance(), is(1));
    assertThat(levenshteinMatch(needle, "a " + needle + " a").getDistance(), is(0));
}