Ignore:
Timestamp:
2015-10-01T21:06:10+02:00 (9 years ago)
Author:
simon04
Message:

see #11916 - Refactoring of SearchAction/SearchCompiler

File:
1 edited

Legend:

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

    r8509 r8811  
    3131    @Test
    3232    public void testAny() throws Exception {
    33         final SearchCompiler.Match c = SearchCompiler.compile("foo", false, false);
     33        final SearchCompiler.Match c = SearchCompiler.compile("foo");
    3434        Assert.assertTrue(c.match(newPrimitive("foobar", "true")));
    3535        Assert.assertTrue(c.match(newPrimitive("name", "hello-foo-xy")));
     
    3939    @Test
    4040    public void testEquals() throws Exception {
    41         final SearchCompiler.Match c = SearchCompiler.compile("foo=bar", false, false);
     41        final SearchCompiler.Match c = SearchCompiler.compile("foo=bar");
    4242        Assert.assertFalse(c.match(newPrimitive("foobar", "true")));
    4343        Assert.assertTrue(c.match(newPrimitive("foo", "bar")));
     
    4848    @Test
    4949    public void testCompare() throws Exception {
    50         final SearchCompiler.Match c1 = SearchCompiler.compile("start_date>1950", false, false);
     50        final SearchCompiler.Match c1 = SearchCompiler.compile("start_date>1950");
    5151        Assert.assertTrue(c1.match(newPrimitive("start_date", "1950-01-01")));
    5252        Assert.assertTrue(c1.match(newPrimitive("start_date", "1960")));
     
    5454        Assert.assertFalse(c1.match(newPrimitive("start_date", "1000")));
    5555        Assert.assertTrue(c1.match(newPrimitive("start_date", "101010")));
    56         final SearchCompiler.Match c2 = SearchCompiler.compile("start_date<1960", false, false);
     56        final SearchCompiler.Match c2 = SearchCompiler.compile("start_date<1960");
    5757        Assert.assertTrue(c2.match(newPrimitive("start_date", "1950-01-01")));
    5858        Assert.assertFalse(c2.match(newPrimitive("start_date", "1960")));
     
    6060        Assert.assertTrue(c2.match(newPrimitive("start_date", "1000")));
    6161        Assert.assertTrue(c2.match(newPrimitive("start_date", "200")));
    62         final SearchCompiler.Match c3 = SearchCompiler.compile("name<I", false, false);
     62        final SearchCompiler.Match c3 = SearchCompiler.compile("name<I");
    6363        Assert.assertTrue(c3.match(newPrimitive("name", "Alpha")));
    6464        Assert.assertFalse(c3.match(newPrimitive("name", "Sigma")));
    65         final SearchCompiler.Match c4 = SearchCompiler.compile("\"start_date\"<1960", false, false);
     65        final SearchCompiler.Match c4 = SearchCompiler.compile("\"start_date\"<1960");
    6666        Assert.assertTrue(c4.match(newPrimitive("start_date", "1950-01-01")));
    6767        Assert.assertFalse(c4.match(newPrimitive("start_date", "2000")));
     
    8383        way.addNode(node1);
    8484        way.addNode(node2);
    85         Assert.assertFalse(SearchCompiler.compile("nth:2", false, false).match(node1));
    86         Assert.assertTrue(SearchCompiler.compile("nth:1", false, false).match(node1));
    87         Assert.assertFalse(SearchCompiler.compile("nth:0", false, false).match(node1));
    88         Assert.assertTrue(SearchCompiler.compile("nth:0", false, false).match(node0));
    89         Assert.assertTrue(SearchCompiler.compile("nth:2", false, false).match(node2));
    90         Assert.assertTrue(SearchCompiler.compile("nth:-1", false, false).match(node2));
    91         Assert.assertTrue(SearchCompiler.compile("nth:-2", false, false).match(node1));
    92         Assert.assertTrue(SearchCompiler.compile("nth:-3", false, false).match(node0));
     85        Assert.assertFalse(SearchCompiler.compile("nth:2").match(node1));
     86        Assert.assertTrue(SearchCompiler.compile("nth:1").match(node1));
     87        Assert.assertFalse(SearchCompiler.compile("nth:0").match(node1));
     88        Assert.assertTrue(SearchCompiler.compile("nth:0").match(node0));
     89        Assert.assertTrue(SearchCompiler.compile("nth:2").match(node2));
     90        Assert.assertTrue(SearchCompiler.compile("nth:-1").match(node2));
     91        Assert.assertTrue(SearchCompiler.compile("nth:-2").match(node1));
     92        Assert.assertTrue(SearchCompiler.compile("nth:-3").match(node0));
    9393    }
    9494
    9595    @Test
    9696    public void testNthParseNegative() throws Exception {
    97         Assert.assertThat(SearchCompiler.compile("nth:-1", false, false).toString(), CoreMatchers.is("Nth{nth=-1, modulo=false}"));
     97        Assert.assertThat(SearchCompiler.compile("nth:-1").toString(), CoreMatchers.is("Nth{nth=-1, modulo=false}"));
    9898
    9999    }
Note: See TracChangeset for help on using the changeset viewer.