Changeset 8250 in josm for trunk/test/unit/org
- Timestamp:
- 2015-04-23T18:59:15+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/actions/search/SearchCompilerTest.java
r7937 r8250 1 1 package org.openstreetmap.josm.actions.search; 2 2 3 import org.hamcrest.CoreMatchers; 3 4 import org.junit.Assert; 4 5 import org.junit.Before; 5 6 import org.junit.Test; 6 7 import org.openstreetmap.josm.JOSMFixture; 8 import org.openstreetmap.josm.data.coor.LatLon; 9 import org.openstreetmap.josm.data.osm.DataSet; 7 10 import org.openstreetmap.josm.data.osm.Node; 8 11 import org.openstreetmap.josm.data.osm.OsmPrimitive; 12 import org.openstreetmap.josm.data.osm.Way; 9 13 10 14 public class SearchCompilerTest { … … 63 67 64 68 } 69 70 @Test 71 public void testNth() throws Exception { 72 final DataSet dataSet = new DataSet(); 73 final Way way = new Way(); 74 final Node node0 = new Node(new LatLon(1, 1)); 75 final Node node1 = new Node(new LatLon(2, 2)); 76 final Node node2 = new Node(new LatLon(3, 3)); 77 dataSet.addPrimitive(way); 78 dataSet.addPrimitive(node0); 79 dataSet.addPrimitive(node1); 80 dataSet.addPrimitive(node2); 81 way.addNode(node0); 82 way.addNode(node1); 83 way.addNode(node2); 84 Assert.assertFalse(SearchCompiler.compile("nth:2", false, false).match(node1)); 85 Assert.assertTrue(SearchCompiler.compile("nth:1", false, false).match(node1)); 86 Assert.assertFalse(SearchCompiler.compile("nth:0", false, false).match(node1)); 87 Assert.assertTrue(SearchCompiler.compile("nth:0", false, false).match(node0)); 88 Assert.assertTrue(SearchCompiler.compile("nth:2", false, false).match(node2)); 89 Assert.assertTrue(SearchCompiler.compile("nth:-1", false, false).match(node2)); 90 Assert.assertTrue(SearchCompiler.compile("nth:-2", false, false).match(node1)); 91 Assert.assertTrue(SearchCompiler.compile("nth:-3", false, false).match(node0)); 92 } 93 94 @Test 95 public void testNthParseNegative() throws Exception { 96 Assert.assertThat(SearchCompiler.compile("nth:-1", false, false).toString(), CoreMatchers.is("Nth{nth=-1, modulo=false}")); 97 98 } 65 99 }
Note:
See TracChangeset
for help on using the changeset viewer.