Changeset 8811 in josm for trunk/test/unit
- Timestamp:
- 2015-10-01T21:06:10+02:00 (9 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/actions/CreateMultipolygonActionTest.groovy
r7938 r8811 5 5 import org.openstreetmap.josm.JOSMFixture 6 6 import org.openstreetmap.josm.TestUtils 7 import org.openstreetmap.josm.actions.search.SearchAction 7 8 import org.openstreetmap.josm.actions.search.SearchCompiler 8 9 import org.openstreetmap.josm.data.osm.Relation … … 26 27 } 27 28 29 static def regexpSearch(String search) { 30 def setting = new SearchAction.SearchSetting() 31 setting.text = search 32 setting.regexSearch = true 33 return setting 34 } 35 28 36 @Test 29 37 public void testCreate1() { … … 37 45 public void testCreate2() { 38 46 def ds = OsmReader.parseDataSet(new FileInputStream(TestUtils.getTestDataRoot() + "create_multipolygon.osm"), null); 39 def ways = Utils.filter(ds.getWays(), SearchCompiler.compile("ref=1 OR ref:1.1." , false, false))47 def ways = Utils.filter(ds.getWays(), SearchCompiler.compile("ref=1 OR ref:1.1.")) 40 48 def mp = CreateMultipolygonAction.createMultipolygonCommand(ways as Collection<Way>, null) 41 49 assert getRefToRoleMap(mp.b).toString() == "[1:outer, 1.1.1:inner, 1.1.2:inner]" … … 45 53 public void testUpdate1() { 46 54 def ds = OsmReader.parseDataSet(new FileInputStream(TestUtils.getTestDataRoot() + "create_multipolygon.osm"), null); 47 def ways = Utils.filter(ds.getWays(), SearchCompiler.compile( "ref=\".*1\$\"", false, true))55 def ways = Utils.filter(ds.getWays(), SearchCompiler.compile(regexpSearch("ref=\".*1\$\""))) 48 56 def mp = CreateMultipolygonAction.createMultipolygonCommand(ways as Collection<Way>, null) 49 57 assert mp.b.getMembersCount() == 3 50 58 assert getRefToRoleMap(mp.b).toString() == "[1:outer, 1.1:inner, 1.1.1:outer]" 51 def ways2 = Utils.filter(ds.getWays(), SearchCompiler.compile( "ref=1.2", false, true))59 def ways2 = Utils.filter(ds.getWays(), SearchCompiler.compile(regexpSearch("ref=1.2"))) 52 60 def mp2 = CreateMultipolygonAction.createMultipolygonCommand(ways2 as Collection<Way>, mp.b) 53 61 assert mp2.b.getMembersCount() == 4 … … 58 66 public void testUpdate2() { 59 67 def ds = OsmReader.parseDataSet(new FileInputStream(TestUtils.getTestDataRoot() + "create_multipolygon.osm"), null); 60 def ways = Utils.filter(ds.getWays(), SearchCompiler.compile("ref=1 OR ref:1.1.1" , false, false))68 def ways = Utils.filter(ds.getWays(), SearchCompiler.compile("ref=1 OR ref:1.1.1")) 61 69 def mp = CreateMultipolygonAction.createMultipolygonCommand(ways as Collection<Way>, null) 62 70 assert getRefToRoleMap(mp.b).toString() == "[1:outer, 1.1.1:inner]" 63 def ways2 = Utils.filter(ds.getWays(), SearchCompiler.compile( "ref=1.1 OR ref=1.2 OR ref=1.1.2", false, true))71 def ways2 = Utils.filter(ds.getWays(), SearchCompiler.compile(regexpSearch("ref=1.1 OR ref=1.2 OR ref=1.1.2"))) 64 72 def mp2 = CreateMultipolygonAction.createMultipolygonCommand(ways2 as Collection<Way>, mp.b) 65 73 assert getRefToRoleMap(mp2.b).toString() == "[1:outer, 1.1:inner, 1.1.1:outer, 1.1.2:outer, 1.2:inner]" -
trunk/test/unit/org/openstreetmap/josm/actions/search/SearchCompilerTest.java
r8509 r8811 31 31 @Test 32 32 public void testAny() throws Exception { 33 final SearchCompiler.Match c = SearchCompiler.compile("foo" , false, false);33 final SearchCompiler.Match c = SearchCompiler.compile("foo"); 34 34 Assert.assertTrue(c.match(newPrimitive("foobar", "true"))); 35 35 Assert.assertTrue(c.match(newPrimitive("name", "hello-foo-xy"))); … … 39 39 @Test 40 40 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"); 42 42 Assert.assertFalse(c.match(newPrimitive("foobar", "true"))); 43 43 Assert.assertTrue(c.match(newPrimitive("foo", "bar"))); … … 48 48 @Test 49 49 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"); 51 51 Assert.assertTrue(c1.match(newPrimitive("start_date", "1950-01-01"))); 52 52 Assert.assertTrue(c1.match(newPrimitive("start_date", "1960"))); … … 54 54 Assert.assertFalse(c1.match(newPrimitive("start_date", "1000"))); 55 55 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"); 57 57 Assert.assertTrue(c2.match(newPrimitive("start_date", "1950-01-01"))); 58 58 Assert.assertFalse(c2.match(newPrimitive("start_date", "1960"))); … … 60 60 Assert.assertTrue(c2.match(newPrimitive("start_date", "1000"))); 61 61 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"); 63 63 Assert.assertTrue(c3.match(newPrimitive("name", "Alpha"))); 64 64 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"); 66 66 Assert.assertTrue(c4.match(newPrimitive("start_date", "1950-01-01"))); 67 67 Assert.assertFalse(c4.match(newPrimitive("start_date", "2000"))); … … 83 83 way.addNode(node1); 84 84 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)); 93 93 } 94 94 95 95 @Test 96 96 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}")); 98 98 99 99 } -
trunk/test/unit/org/openstreetmap/josm/tools/template_engine/TemplateEngineTest.java
r8540 r8811 61 61 62 62 private static Match compile(String expression) throws org.openstreetmap.josm.actions.search.SearchCompiler.ParseError { 63 return SearchCompiler.compile(expression , false, false);63 return SearchCompiler.compile(expression); 64 64 } 65 65
Note:
See TracChangeset
for help on using the changeset viewer.