Changeset 6513 in josm for trunk/test


Ignore:
Timestamp:
2013-12-23T00:13:58+01:00 (6 years ago)
Author:
simon04
Message:

see #9414 - convert some tagchecker tests to MapCSS, extend MapCSS by test for false values

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java

    r6512 r6513  
    1010import org.openstreetmap.josm.data.osm.Tag;
    1111import org.openstreetmap.josm.data.osm.Way;
     12import org.openstreetmap.josm.tools.TextTagParser;
    1213
    1314import java.io.StringReader;
     
    5556
    5657    OsmPrimitive createPrimitiveForAssertion(String assertion) {
    57         final String[] x = assertion.split("\\s+");
     58        final String[] x = assertion.split("\\s+", 2);
    5859        final OsmPrimitive p = "n".equals(x[0]) || "node".equals(x[0])
    5960                ? new Node()
     
    6667            throw new IllegalArgumentException("Expecting n/node/w/way/r/relation, but got " + x[0]);
    6768        }
    68         for (int i = 1; i < x.length; i++) {
    69             final Tag tag = Tag.ofString(x[i]);
    70             p.put(tag.getKey(), tag.getValue());
     69        for (final Map.Entry<String, String> i : TextTagParser.getValidatedTagsFromText(x[1]).entrySet()) {
     70            p.put(i.getKey(), i.getValue());
    7171        }
    7272        return p;
     
    9595        for (final MapCSSTagChecker.TagCheck check : c.checks) {
    9696            for (final Map.Entry<String, Boolean> i : check.assertions.entrySet()) {
    97                 if (check.matchesPrimitive(createPrimitiveForAssertion(i.getKey())) != i.getValue()) {
    98                     final String error = "Expecting test '" + check.getMessage() + "' to " + (i.getValue() ? "" : "not ") + "match " + i.getKey();
     97                final OsmPrimitive p = createPrimitiveForAssertion(i.getKey());
     98                if (check.matchesPrimitive(p) != i.getValue()) {
     99                    final String error = "Expecting test '" + check.getMessage() + "' to " + (i.getValue() ? "" : "not ") + "match " + i.getKey() + ", i.e., " + p.getKeys();
    99100                    System.err.println(error);
    100101                    assertionErrors.add(error);
Note: See TracChangeset for help on using the changeset viewer.