Ticket #18408: 18408.patch
File 18408.patch, 1.9 KB (added by , 6 years ago) |
---|
-
src/org/openstreetmap/josm/gui/mappaint/mapcss/Functions.java
982 1023 } 983 1024 984 1025 /** 1026 * Trim whitespaces from the strings {@code strings}. 1027 * 1028 * @param strings The list of strings to strip 1029 * @return The resulting string 1030 * @see Utils#strip 1031 * @since xxx 1032 */ 1033 public static List<String> trim_list(List<String> strings) { 1034 return strings.stream().map(Utils::strip).filter(str -> !str.isEmpty()).collect(Collectors.toList()); 1035 } 1036 1037 /** 985 1038 * Check if two strings are similar, but not identical, i.e., have a Levenshtein distance of 1 or 2. 986 1039 * @param string1 first string to compare 987 1040 * @param string2 second string to compare -
test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.java
324 324 assertTrue(c1.matches(new Environment(n1))); 325 325 } 326 326 327 /** 328 * Test case for {@link Functions#trim_list} 329 */ 327 330 @Test 331 public void testTrimList() { 332 List<String> trimmed = Functions.trim_list(Arrays.asList(" A1 ", "A2", " A3", "A4 ", "")); 333 assertEquals(4, trimmed.size()); 334 assertEquals("A1", trimmed.get(0)); 335 assertEquals("A2", trimmed.get(1)); 336 assertEquals("A3", trimmed.get(2)); 337 assertEquals("A4", trimmed.get(3)); 338 } 339 340 @Test 328 341 public void testTicket8568() throws Exception { 329 342 MapCSSStyleSource sheet = new MapCSSStyleSource( 330 343 "way { width: 5; }\n" +