Changeset 17758 in josm for trunk/test/unit
- Timestamp:
- 2021-04-12T21:20:31+02:00 (4 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactoryTest.java
r17275 r17758 8 8 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 9 9 import net.trajano.commons.testing.UtilityClassTestUtil; 10 11 import java.lang.reflect.Method; 12 import java.lang.reflect.Modifier; 10 13 11 14 /** … … 29 32 UtilityClassTestUtil.assertUtilityClassWellDefined(Functions.class); 30 33 } 34 35 /** 36 * Tests that all functions have been registered to {@link ExpressionFactory#FACTORY_MAP} 37 * 38 * For instance to register {@link Functions#osm_id}, {@code FACTORY_MAP.put("osm_id", Factory.ofEnv(Functions::osm_id))} 39 */ 40 @Test 41 void testNoUnregisteredFunctions() { 42 for (Method m : Functions.class.getDeclaredMethods()) { 43 if (!Modifier.isPrivate(m.getModifiers()) && !ExpressionFactory.FACTORY_MAP.containsKey(m.getName())) { 44 throw new AssertionError(m + " has not registered in ExpressionFactory.FACTORY_MAP"); 45 } 46 } 47 } 31 48 } -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.java
r17745 r17758 368 368 MultiCascade mc = new MultiCascade(); 369 369 sheet.apply(mc, OsmUtils.createPrimitive("way foo=bar"), 20, false); 370 assertEquals( Float.valueOf(5f), mc.getCascade(null).get("width"));370 assertEquals(5.0f, mc.getCascade(null).get("width")); 371 371 sheet.apply(mc, OsmUtils.createPrimitive("way keyA=true"), 20, false); 372 assertEquals( Float.valueOf(15f), mc.getCascade(null).get("width"));372 assertEquals(15.0, mc.getCascade(null).get("width")); 373 373 sheet.apply(mc, OsmUtils.createPrimitive("way keyB=true"), 20, false); 374 assertEquals( Float.valueOf(15f), mc.getCascade(null).get("width"));374 assertEquals(15.0, mc.getCascade(null).get("width")); 375 375 sheet.apply(mc, OsmUtils.createPrimitive("way keyA=true keyB=true"), 20, false); 376 assertEquals( Float.valueOf(15f), mc.getCascade(null).get("width"));376 assertEquals(15.0, mc.getCascade(null).get("width")); 377 377 } 378 378 … … 480 480 @Test 481 481 void testSort() throws Exception { 482 assertEquals(Arrays.asList(new String[] {"alpha", "beta"}), Functions.sort( "beta", "alpha"));482 assertEquals(Arrays.asList(new String[] {"alpha", "beta"}), Functions.sort(null, "beta", "alpha")); 483 483 Way way1 = TestUtils.newWay("highway=residential name=Alpha alt_name=Beta ref=\"A9;A8\"", new Node(new LatLon(0.001, 0.001)), 484 484 new Node(new LatLon(0.002, 0.002))); … … 490 490 assertTrue(source.rules.get(0).matches(e)); 491 491 source.rules.get(0).declaration.execute(e); 492 assertEquals(Functions.join( ",", "Alpha", "Beta"), e.getCascade(null).get("sorted", null, String.class));492 assertEquals(Functions.join(null, ",", "Alpha", "Beta"), e.getCascade(null).get("sorted", null, String.class)); 493 493 494 494 source = new MapCSSStyleSource("way[ref] {sorted: join_list(\",\", sort_list(split(\";\", tag(\"ref\"))));}"); … … 497 497 assertTrue(source.rules.get(0).matches(e)); 498 498 source.rules.get(0).declaration.execute(e); 499 assertEquals(Functions.join( ",", "A8", "A9"), e.getCascade(null).get("sorted", null, String.class));499 assertEquals(Functions.join(null, ",", "A8", "A9"), e.getCascade(null).get("sorted", null, String.class)); 500 500 } 501 501 … … 503 503 void testUniqueValues() throws Exception { 504 504 assertEquals(Arrays.asList(new String[] {"alpha", "beta"}), 505 Functions.uniq( "alpha", "alpha", "alpha", "beta"));505 Functions.uniq(null, "alpha", "alpha", "alpha", "beta")); 506 506 assertEquals(Arrays.asList(new String[] {"one", "two", "three"}), 507 507 Functions.uniq_list(Arrays.asList(new String[] {"one", "one", "two", "two", "two", "three"}))); … … 597 597 598 598 @Test 599 void testMath() { 600 MapCSSStyleSource source = new MapCSSStyleSource("node { add: 1 + 2 + 3 + 4; mul: 2 * 3 * 5 * 7; sub: 0 - 1 - 2 - 3; div: 360 / 15; }"); 601 source.loadStyleSource(); 602 MultiCascade mc = new MultiCascade(); 603 source.apply(mc, OsmUtils.createPrimitive("node"), 20, false); 604 assertEquals(10.0, mc.getCascade(null).get("add")); 605 assertEquals(210.0, mc.getCascade(null).get("mul")); 606 assertEquals(-6.0, mc.getCascade(null).get("sub")); 607 assertEquals(24.0, mc.getCascade(null).get("div")); 608 } 609 610 @Test 599 611 void testMinMaxFunctions() throws Exception { 600 612 MapCSSStyleSource sheet = new MapCSSStyleSource("* {" +
Note:
See TracChangeset
for help on using the changeset viewer.