Changeset 14371 in josm for trunk/test/unit


Ignore:
Timestamp:
2018-10-27T13:34:59+02:00 (6 years ago)
Author:
simon04
Message:

fix #15889 - add MapCSS function is_similar

This function tests if two strings are similar. Logic extracted from SimilarNamedWays validation test.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/tools/UtilsTest.java

    r13520 r14371  
    295295        assertEquals("Empty on null stream", 0, Utils.readBytesFromStream(null).length);
    296296    }
     297
     298    /**
     299     * Test of {@link Utils#getLevenshteinDistance} method.
     300     */
     301    @Test
     302    public void testLevenshteinDistance() {
     303        assertEquals(0, Utils.getLevenshteinDistance("foo", "foo"));
     304        assertEquals(3, Utils.getLevenshteinDistance("foo", "bar"));
     305        assertEquals(1, Utils.getLevenshteinDistance("bar", "baz"));
     306    }
     307
     308    /**
     309     * Test of {@link Utils#isSimilar} method.
     310     */
     311    @Test
     312    public void testIsSimilar() {
     313        assertFalse(Utils.isSimilar("foo", "foo"));
     314        assertFalse(Utils.isSimilar("foo", "bar"));
     315        assertTrue(Utils.isSimilar("bar", "baz"));
     316        assertTrue(Utils.isSimilar("bar", "baz"));
     317        assertTrue(Utils.isSimilar("Rua São João", "Rua SAO Joao"));
     318    }
    297319}
Note: See TracChangeset for help on using the changeset viewer.