Failing test for an expansion with negation

Change-Id: I6d379e739c38e0c2a5d06171cc423c71c4e76331
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestSpanExpansionIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestSpanExpansionIndex.java
index 81a6ef0..6f7fe92 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestSpanExpansionIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestSpanExpansionIndex.java
@@ -479,6 +479,71 @@
         
     }
 
+
+    @Test
+    public void indexExpansionWithNegationDifferentFragments () throws Exception {
+        KrillIndex ki = new KrillIndex();
+
+        // Add to the index in a single fragment
+        FieldDocument fd = new FieldDocument();
+        fd.addTV("base",
+                 "a B c",
+                 "[(0-1)s:a|i:a|_1$<i>0<i>1]"
+                 + "[(1-2)s:B|i:b|_2$<i>1<i>2|]"
+                 + "[(2-3)s:c|i:c|_3$<i>2<i>3]");
+        ki.addDoc(fd);
+        ki.commit();
+        fd.addTV("base",
+                 "a b c",
+                 "[(0-1)s:a|i:a|_1$<i>0<i>1]"
+                 + "[(1-2)s:b|i:b|_2$<i>1<i>2|]"
+                 + "[(2-3)s:c|i:c|_3$<i>2<i>3]");
+        ki.addDoc(fd);
+        ki.commit();
+
+        QueryBuilder kq = new QueryBuilder("base");
+        SpanQuery sq = kq.seq(kq.seg("s:a")).append(kq.seg().without("s:B")).append(kq.seg("s:c")).toQuery();
+        assertEquals("spanNext(base:s:a, spanExpansion(base:s:c, !base:s:B{1, 1}, left))", sq.toString());
+        Krill ks = new Krill(sq);
+        ks.getMeta().getContext().left.setToken(true).setLength(0);
+        ks.getMeta().getContext().right.setToken(true).setLength(0);
+
+        Result kr = ki.search(ks);
+        assertEquals((long) 1, kr.getTotalResults());
+    };
+
+    @Test
+    public void indexExpansionWithNegationSameFragmentBug () throws Exception {
+        KrillIndex ki = new KrillIndex();
+
+        // Add to the index in a single fragment
+        FieldDocument fd = new FieldDocument();
+        fd.addTV("base",
+                 "a B c",
+                 "[(0-1)s:a|i:a|_1$<i>0<i>1]"
+                 + "[(1-2)s:B|i:b|_2$<i>1<i>2|]"
+                 + "[(2-3)s:c|i:c|_3$<i>2<i>3]");
+        ki.addDoc(fd);
+        fd.addTV("base",
+                 "a b c",
+                 "[(0-1)s:a|i:a|_1$<i>0<i>1]"
+                 + "[(1-2)s:b|i:b|_2$<i>1<i>2|]"
+                 + "[(2-3)s:c|i:c|_3$<i>2<i>3]");
+        ki.addDoc(fd);
+        ki.commit();
+
+        QueryBuilder kq = new QueryBuilder("base");
+        SpanQuery sq = kq.seq(kq.seg("s:a")).append(kq.seg().without("s:B")).append(kq.seg("s:c")).toQuery();
+        assertEquals("spanNext(base:s:a, spanExpansion(base:s:c, !base:s:B{1, 1}, left))", sq.toString());
+        Krill ks = new Krill(sq);
+        ks.getMeta().getContext().left.setToken(true).setLength(0);
+        ks.getMeta().getContext().right.setToken(true).setLength(0);
+
+        Result kr = ki.search(ks);
+        assertEquals((long) 1, kr.getTotalResults());
+    };
+
+    
     private FieldDocument createFieldDoc6 () {
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-6");