From aa82d484239e4ec07fc3a51e1746be713de0740f Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Sun, 5 Apr 2015 20:20:25 +0000 Subject: [PATCH] add more equivalence tests for SpanNotQuery git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1671424 13f79535-47bb-0310-9956-ffa450edef68 --- .../spans/TestSpanSearchEquivalence.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/lucene/core/src/test/org/apache/lucene/search/spans/TestSpanSearchEquivalence.java b/lucene/core/src/test/org/apache/lucene/search/spans/TestSpanSearchEquivalence.java index 094605561ac..b3720437e7e 100644 --- a/lucene/core/src/test/org/apache/lucene/search/spans/TestSpanSearchEquivalence.java +++ b/lucene/core/src/test/org/apache/lucene/search/spans/TestSpanSearchEquivalence.java @@ -58,6 +58,35 @@ public class TestSpanSearchEquivalence extends SearchEquivalenceTestBase { assertSubsetOf(new SpanNotQuery(new SpanTermQuery(t1), new SpanTermQuery(t2)), new SpanTermQuery(t1)); } + /** SpanNotQuery(A, [B C]) ⊆ SpanTermQuery(A) */ + public void testSpanNotNearVersusSpanTerm() throws Exception { + Term t1 = randomTerm(); + Term t2 = randomTerm(); + Term t3 = randomTerm(); + SpanQuery near = new SpanNearQuery(new SpanQuery[] { new SpanTermQuery(t2), new SpanTermQuery(t3) }, 10, random().nextBoolean()); + assertSubsetOf(new SpanNotQuery(new SpanTermQuery(t1), near), new SpanTermQuery(t1)); + } + + /** SpanNotQuery([A B], C) ⊆ SpanNearQuery([A B]) */ + public void testSpanNotVersusSpanNear() throws Exception { + Term t1 = randomTerm(); + Term t2 = randomTerm(); + Term t3 = randomTerm(); + SpanQuery near = new SpanNearQuery(new SpanQuery[] { new SpanTermQuery(t1), new SpanTermQuery(t2) }, 10, random().nextBoolean()); + assertSubsetOf(new SpanNotQuery(near, new SpanTermQuery(t3)), near); + } + + /** SpanNotQuery([A B], [C D]) ⊆ SpanNearQuery([A B]) */ + public void testSpanNotNearVersusSpanNear() throws Exception { + Term t1 = randomTerm(); + Term t2 = randomTerm(); + Term t3 = randomTerm(); + Term t4 = randomTerm(); + SpanQuery near1 = new SpanNearQuery(new SpanQuery[] { new SpanTermQuery(t1), new SpanTermQuery(t2) }, 10, random().nextBoolean()); + SpanQuery near2 = new SpanNearQuery(new SpanQuery[] { new SpanTermQuery(t3), new SpanTermQuery(t4) }, 10, random().nextBoolean()); + assertSubsetOf(new SpanNotQuery(near1, near2), near1); + } + /** SpanFirstQuery(A, 10) ⊆ SpanTermQuery(A) */ public void testSpanFirstVersusSpanTerm() throws Exception { Term t1 = randomTerm();