aboutsummaryrefslogtreecommitdiffstats
path: root/predicate-search/src/test/java/com/yahoo/search/predicate/index/ZeroConstraintPostingListTest.java
blob: c218e9e547482dcb8727d529e78f95b52d0f7e91 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright Yahoo. 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.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

/**
 * @author <a href="mailto:magnarn@yahoo-inc.com">Magnar Nedland</a>
 */
public class ZeroConstraintPostingListTest {

    @Test
    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));
    }
}