Changeset 9940 in josm for trunk/test/unit
- Timestamp:
- 2016-03-06T17:12:42+01:00 (9 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/actions/search/SearchCompilerTest.java
r9930 r9940 19 19 import org.openstreetmap.josm.data.osm.RelationData; 20 20 import org.openstreetmap.josm.data.osm.RelationMember; 21 import org.openstreetmap.josm.data.osm.Tag; 21 22 import org.openstreetmap.josm.data.osm.User; 22 23 import org.openstreetmap.josm.data.osm.Way; … … 427 428 assertEquals("foo1 || (bar1 && bar2 && (baz1 ^ baz2)) || foo2", c4.toString()); 428 429 } 430 431 /** 432 * Tests {@code buildSearchStringForTag}. 433 * @throws ParseError if an error has been encountered while compiling 434 */ 435 @Test 436 public void testBuildSearchStringForTag() throws ParseError { 437 final Tag tag1 = new Tag("foo=", "bar\""); 438 final Tag tag2 = new Tag("foo=", "=bar"); 439 final String search1 = SearchCompiler.buildSearchStringForTag(tag1.getKey(), tag1.getValue()); 440 assertEquals("\"foo=\"=\"bar\\\"\"", search1); 441 assertTrue(SearchCompiler.compile(search1).match(tag1)); 442 assertFalse(SearchCompiler.compile(search1).match(tag2)); 443 final String search2 = SearchCompiler.buildSearchStringForTag(tag1.getKey(), ""); 444 assertEquals("\"foo=\"=*", search2); 445 assertTrue(SearchCompiler.compile(search2).match(tag1)); 446 assertTrue(SearchCompiler.compile(search2).match(tag2)); 447 } 429 448 } -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/properties/RecentTagCollectionTest.java
r9939 r9940 12 12 import org.junit.Test; 13 13 import org.openstreetmap.josm.JOSMFixture; 14 import org.openstreetmap.josm.actions.search.SearchAction; 15 import org.openstreetmap.josm.actions.search.SearchCompiler; 14 16 import org.openstreetmap.josm.data.osm.Tag; 15 17 import org.openstreetmap.josm.data.preferences.CollectionProperty; … … 30 32 /** 31 33 * Performs various tests on a {@link RecentTagCollection}. 32 */ 34 * 35 * @throws SearchCompiler.ParseError if an error has been encountered while compiling 36 */ 33 37 @Test 34 public void test() { 38 public void test() throws SearchCompiler.ParseError { 35 39 final RecentTagCollection recentTags = new RecentTagCollection(2); 36 40 assertTrue(recentTags.isEmpty()); … … 55 59 assertEquals(Collections.singletonList(new Tag("key=", "=value")), recentTags.toList()); 56 60 61 recentTags.add(foo); 62 recentTags.add(bar); 63 recentTags.add(baz); 64 final SearchAction.SearchSetting searchSetting = new SearchAction.SearchSetting(); 65 recentTags.ignoreTag(baz, searchSetting); 66 recentTags.ignoreTag(new Tag("something", "else"), searchSetting); 67 assertEquals("\"name\"=\"baz\" OR \"something\"=\"else\"", searchSetting.text); 68 assertEquals(Collections.singletonList(bar), recentTags.toList()); 69 recentTags.add(baz); 70 assertEquals(Collections.singletonList(bar), recentTags.toList()); 71 searchSetting.text = ""; 72 recentTags.setTagsToIgnore(searchSetting); 73 assertEquals(Collections.singletonList(bar), recentTags.toList()); 74 recentTags.add(baz); 75 assertEquals(Arrays.asList(bar, baz), recentTags.toList()); 76 recentTags.ignoreTag(new Tag("name", /*all values */""), searchSetting); 77 assertEquals(Collections.emptyList(), recentTags.toList()); 78 57 79 } 58 80 }
Note:
See TracChangeset
for help on using the changeset viewer.