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


Ignore:
Timestamp:
2015-10-08T21:38:54+02:00 (9 years ago)
Author:
simon04
Message:

fix #11894 - Search: ">" unexpected behavior when values are not numbers

key<X and key>X behave as follows:

  • missing tag for key: no match
  • if value for key or X is in ISO8601 format, perform string comparison
  • if X is a numeric value, perform numeric comparison
  • otherwise perform natural string comparison using AlphanumComparator
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/actions/search/SearchCompilerTest.java

    r8811 r8838  
    5454        Assert.assertFalse(c1.match(newPrimitive("start_date", "1000")));
    5555        Assert.assertTrue(c1.match(newPrimitive("start_date", "101010")));
     56
    5657        final SearchCompiler.Match c2 = SearchCompiler.compile("start_date<1960");
    5758        Assert.assertTrue(c2.match(newPrimitive("start_date", "1950-01-01")));
     
    6061        Assert.assertTrue(c2.match(newPrimitive("start_date", "1000")));
    6162        Assert.assertTrue(c2.match(newPrimitive("start_date", "200")));
     63
    6264        final SearchCompiler.Match c3 = SearchCompiler.compile("name<I");
    6365        Assert.assertTrue(c3.match(newPrimitive("name", "Alpha")));
    6466        Assert.assertFalse(c3.match(newPrimitive("name", "Sigma")));
     67
    6568        final SearchCompiler.Match c4 = SearchCompiler.compile("\"start_date\"<1960");
    6669        Assert.assertTrue(c4.match(newPrimitive("start_date", "1950-01-01")));
    6770        Assert.assertFalse(c4.match(newPrimitive("start_date", "2000")));
    6871
     72        final SearchCompiler.Match c5 = SearchCompiler.compile("height>180");
     73        Assert.assertTrue(c5.match(newPrimitive("height", "200")));
     74        Assert.assertTrue(c5.match(newPrimitive("height", "99999")));
     75        Assert.assertFalse(c5.match(newPrimitive("height", "50")));
     76        Assert.assertFalse(c5.match(newPrimitive("height", "-9999")));
     77        Assert.assertFalse(c5.match(newPrimitive("height", "fixme")));
     78
     79        final SearchCompiler.Match c6 = SearchCompiler.compile("name>C");
     80        Assert.assertTrue(c6.match(newPrimitive("name", "Delta")));
     81        Assert.assertFalse(c6.match(newPrimitive("name", "Alpha")));
    6982    }
    7083
Note: See TracChangeset for help on using the changeset viewer.