Changeset 16262 in josm for trunk/test/unit/org


Ignore:
Timestamp:
2020-04-11T18:00:31+02:00 (5 years ago)
Author:
simon04
Message:

fix #18164 - Migrate OverpassTurboQueryWizard to Java

The new OverpassTurboQueryWizard first invokes SearchCompiler, and then turns the AST into an Overpass QL.

File:
1 edited

Legend:

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

    r16261 r16262  
    3939    public void testKeyValue() {
    4040        assertQueryEquals("  nwr[\"amenity\"=\"drinking_water\"];\n", "amenity=drinking_water");
     41        assertQueryEquals("  nwr[\"amenity\"];\n", "amenity=*");
    4142    }
    4243
     
    4647    @Test
    4748    public void testKeyNotValue() {
    48         assertQueryEquals("  nwr[\"amenity\"!=\"drinking_water\"];\n", "amenity!=drinking_water");
    49         assertQueryEquals("  nwr[\"amenity\"!=\"drinking_water\"];\n", "amenity<>drinking_water");
     49        assertQueryEquals("  nwr[\"amenity\"!=\"drinking_water\"];\n", "-amenity=drinking_water");
     50        assertQueryEquals("  nwr[!\"amenity\"];\n", "-amenity=*");
    5051    }
    5152
     
    5758        assertQueryEquals("  nwr[\"foo\"~\"bar\"];\n", "foo~bar");
    5859        assertQueryEquals("  nwr[\"foo\"~\"bar\"];\n", "foo~/bar/");
    59         assertQueryEquals("  nwr[\"foo\"~\"bar\"];\n", "foo~=bar");
    60         assertQueryEquals("  nwr[\"foo\"~\"bar\"];\n", "foo~=/bar/");
    61         assertQueryEquals("  nwr[\"foo\"~\"bar\"];\n", "foo like bar");
    62         assertQueryEquals("  nwr[\"foo\"~\"bar\"];\n", "foo like /bar/");
    6360        // case insensitive
    6461        assertQueryEquals("  nwr[\"foo\"~\"bar\",i];\n", "foo~/bar/i");
    6562        // negated
    66         assertQueryEquals("  nwr[\"foo\"!~\"bar\"];\n", "foo!~bar");
    67         assertQueryEquals("  nwr[\"foo\"!~\"bar\"];\n", "foo not like bar");
     63        assertQueryEquals("  nwr[\"foo\"!~\"bar\"];\n", "-foo~bar");
     64        assertQueryEquals("  nwr[\"foo\"!~\"bar\",i];\n", "-foo~/bar/i");
     65    }
     66
     67    /**
     68     * Test OSM boolean true/false.
     69     */
     70    @Test
     71    public void testOsmBoolean() {
     72        assertQueryEquals("  nwr[\"highway\"][\"oneway\"~\"true|yes|1|on\"];\n", "highway=* AND oneway?");
     73        assertQueryEquals("  nwr[\"highway\"][\"oneway\"~\"false|no|0|off\"];\n", "highway=* AND -oneway?");
    6874    }
    6975
     
    8490    public void testBooleanOr() {
    8591        assertQueryEquals("  nwr[\"foo\"=\"bar\"];\n  nwr[\"baz\"=\"42\"];\n", "foo=bar or baz=42");
    86         assertQueryEquals("  nwr[\"foo\"=\"bar\"];\n  nwr[\"baz\"=\"42\"];\n", "foo=bar || baz=42");
    8792        assertQueryEquals("  nwr[\"foo\"=\"bar\"];\n  nwr[\"baz\"=\"42\"];\n", "foo=bar | baz=42");
    8893    }
     
    118123    @Test
    119124    public void testUser() {
    120         assertQueryEquals("  nwr(user:\"foo\");\n  nwr(uid:42);\n", "user:foo or uid:42");
     125        assertQueryEquals("  nwr(user:\"foo\");\n  nwr(uid:42);\n", "user:foo or user:42");
    121126    }
    122127
     
    126131    @Test
    127132    public void testEmpty() {
    128         assertQueryEquals("  way[\"foo\"~\"^$\"];\n", "foo='' and type:way");
     133        assertQueryEquals("  way[\"foo\"~\"^$\"];\n", "foo=\"\" and type:way");
    129134    }
    130135
     
    220225    @Test(expected = UncheckedParseException.class)
    221226    public void testErroneous() {
    222         OverpassTurboQueryWizard.getInstance().constructQuery("foo");
     227        OverpassTurboQueryWizard.getInstance().constructQuery("-(foo or bar)");
    223228    }
    224229}
Note: See TracChangeset for help on using the changeset viewer.