Index: trunk/test/unit/org/openstreetmap/josm/actions/search/SearchCompilerTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/actions/search/SearchCompilerTest.java	(revision 9939)
+++ trunk/test/unit/org/openstreetmap/josm/actions/search/SearchCompilerTest.java	(revision 9940)
@@ -19,4 +19,5 @@
 import org.openstreetmap.josm.data.osm.RelationData;
 import org.openstreetmap.josm.data.osm.RelationMember;
+import org.openstreetmap.josm.data.osm.Tag;
 import org.openstreetmap.josm.data.osm.User;
 import org.openstreetmap.josm.data.osm.Way;
@@ -427,3 +428,21 @@
         assertEquals("foo1 || (bar1 && bar2 && (baz1 ^ baz2)) || foo2", c4.toString());
     }
+
+    /**
+     * Tests {@code buildSearchStringForTag}.
+     * @throws ParseError if an error has been encountered while compiling
+     */
+    @Test
+    public void testBuildSearchStringForTag() throws ParseError {
+        final Tag tag1 = new Tag("foo=", "bar\"");
+        final Tag tag2 = new Tag("foo=", "=bar");
+        final String search1 = SearchCompiler.buildSearchStringForTag(tag1.getKey(), tag1.getValue());
+        assertEquals("\"foo=\"=\"bar\\\"\"", search1);
+        assertTrue(SearchCompiler.compile(search1).match(tag1));
+        assertFalse(SearchCompiler.compile(search1).match(tag2));
+        final String search2 = SearchCompiler.buildSearchStringForTag(tag1.getKey(), "");
+        assertEquals("\"foo=\"=*", search2);
+        assertTrue(SearchCompiler.compile(search2).match(tag1));
+        assertTrue(SearchCompiler.compile(search2).match(tag2));
+    }
 }
Index: trunk/test/unit/org/openstreetmap/josm/gui/dialogs/properties/RecentTagCollectionTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/gui/dialogs/properties/RecentTagCollectionTest.java	(revision 9939)
+++ trunk/test/unit/org/openstreetmap/josm/gui/dialogs/properties/RecentTagCollectionTest.java	(revision 9940)
@@ -12,4 +12,6 @@
 import org.junit.Test;
 import org.openstreetmap.josm.JOSMFixture;
+import org.openstreetmap.josm.actions.search.SearchAction;
+import org.openstreetmap.josm.actions.search.SearchCompiler;
 import org.openstreetmap.josm.data.osm.Tag;
 import org.openstreetmap.josm.data.preferences.CollectionProperty;
@@ -30,7 +32,9 @@
     /**
      * Performs various tests on a {@link RecentTagCollection}.
-      */
+     *
+     * @throws SearchCompiler.ParseError if an error has been encountered while compiling
+     */
     @Test
-    public void test() {
+    public void test() throws SearchCompiler.ParseError {
         final RecentTagCollection recentTags = new RecentTagCollection(2);
         assertTrue(recentTags.isEmpty());
@@ -55,4 +59,22 @@
         assertEquals(Collections.singletonList(new Tag("key=", "=value")), recentTags.toList());
 
+        recentTags.add(foo);
+        recentTags.add(bar);
+        recentTags.add(baz);
+        final SearchAction.SearchSetting searchSetting = new SearchAction.SearchSetting();
+        recentTags.ignoreTag(baz, searchSetting);
+        recentTags.ignoreTag(new Tag("something", "else"), searchSetting);
+        assertEquals("\"name\"=\"baz\" OR \"something\"=\"else\"", searchSetting.text);
+        assertEquals(Collections.singletonList(bar), recentTags.toList());
+        recentTags.add(baz);
+        assertEquals(Collections.singletonList(bar), recentTags.toList());
+        searchSetting.text = "";
+        recentTags.setTagsToIgnore(searchSetting);
+        assertEquals(Collections.singletonList(bar), recentTags.toList());
+        recentTags.add(baz);
+        assertEquals(Arrays.asList(bar, baz), recentTags.toList());
+        recentTags.ignoreTag(new Tag("name", /*all values */""), searchSetting);
+        assertEquals(Collections.emptyList(), recentTags.toList());
+
     }
 }
