diff options
Diffstat (limited to 'predicate-search/src/test/java/com/yahoo/search/predicate/index/ZeroConstraintPostingListTest.java')
-rw-r--r-- | predicate-search/src/test/java/com/yahoo/search/predicate/index/ZeroConstraintPostingListTest.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/predicate-search/src/test/java/com/yahoo/search/predicate/index/ZeroConstraintPostingListTest.java b/predicate-search/src/test/java/com/yahoo/search/predicate/index/ZeroConstraintPostingListTest.java new file mode 100644 index 00000000000..652441b796a --- /dev/null +++ b/predicate-search/src/test/java/com/yahoo/search/predicate/index/ZeroConstraintPostingListTest.java @@ -0,0 +1,36 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.search.predicate.index; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +/** + * @author <a href="mailto:magnarn@yahoo-inc.com">Magnar Nedland</a> + */ +public class ZeroConstraintPostingListTest { + + @Test + public void requireThatPostingListCanIterate() { + ZeroConstraintPostingList postingList = + new ZeroConstraintPostingList(new int[] {2, 4, 6, 8}); + assertEquals(-1, postingList.getDocId()); + assertEquals(Interval.fromBoundaries(1, Interval.ZERO_CONSTRAINT_RANGE), postingList.getInterval()); + assertEquals(0xffffffffffffffffL, postingList.getSubquery()); + + assertTrue(postingList.nextDocument(0)); + assertEquals(2, postingList.getDocId()); + assertTrue(postingList.prepareIntervals()); + assertFalse(postingList.nextInterval()); + + assertTrue(postingList.nextDocument(7)); + assertEquals(8, postingList.getDocId()); + + assertTrue(postingList.nextDocument(7)); + assertEquals(8, postingList.getDocId()); + + assertFalse(postingList.nextDocument(8)); + } +} |