Index: trunk/test/unit/org/openstreetmap/josm/actions/search/SearchCompilerTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/actions/search/SearchCompilerTest.java	(revision 8239)
+++ trunk/test/unit/org/openstreetmap/josm/actions/search/SearchCompilerTest.java	(revision 8250)
@@ -1,10 +1,14 @@
 package org.openstreetmap.josm.actions.search;
 
+import org.hamcrest.CoreMatchers;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.openstreetmap.josm.JOSMFixture;
+import org.openstreetmap.josm.data.coor.LatLon;
+import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.data.osm.Way;
 
 public class SearchCompilerTest {
@@ -63,3 +67,33 @@
 
     }
+
+    @Test
+    public void testNth() throws Exception {
+        final DataSet dataSet = new DataSet();
+        final Way way = new Way();
+        final Node node0 = new Node(new LatLon(1, 1));
+        final Node node1 = new Node(new LatLon(2, 2));
+        final Node node2 = new Node(new LatLon(3, 3));
+        dataSet.addPrimitive(way);
+        dataSet.addPrimitive(node0);
+        dataSet.addPrimitive(node1);
+        dataSet.addPrimitive(node2);
+        way.addNode(node0);
+        way.addNode(node1);
+        way.addNode(node2);
+        Assert.assertFalse(SearchCompiler.compile("nth:2", false, false).match(node1));
+        Assert.assertTrue(SearchCompiler.compile("nth:1", false, false).match(node1));
+        Assert.assertFalse(SearchCompiler.compile("nth:0", false, false).match(node1));
+        Assert.assertTrue(SearchCompiler.compile("nth:0", false, false).match(node0));
+        Assert.assertTrue(SearchCompiler.compile("nth:2", false, false).match(node2));
+        Assert.assertTrue(SearchCompiler.compile("nth:-1", false, false).match(node2));
+        Assert.assertTrue(SearchCompiler.compile("nth:-2", false, false).match(node1));
+        Assert.assertTrue(SearchCompiler.compile("nth:-3", false, false).match(node0));
+    }
+
+    @Test
+    public void testNthParseNegative() throws Exception {
+        Assert.assertThat(SearchCompiler.compile("nth:-1", false, false).toString(), CoreMatchers.is("Nth{nth=-1, modulo=false}"));
+
+    }
 }
