Changeset View
Changeset View
Standalone View
Standalone View
autotests/unit/engine/andpostingiteratortest.cpp
Show All 29 Lines | 29 | { | |||
---|---|---|---|---|---|
30 | Q_OBJECT | 30 | Q_OBJECT | ||
31 | private Q_SLOTS: | 31 | private Q_SLOTS: | ||
32 | void test(); | 32 | void test(); | ||
33 | void testNullIterators(); | 33 | void testNullIterators(); | ||
34 | }; | 34 | }; | ||
35 | 35 | | |||
36 | void AndPostingIteratorTest::test() | 36 | void AndPostingIteratorTest::test() | ||
37 | { | 37 | { | ||
38 | QVector<quint64> l1 = {1, 3, 5, 7}; | 38 | QVector<DocId> l1 = {1, 3, 5, 7}; | ||
39 | QVector<quint64> l2 = {3, 4, 5, 7, 9, 11}; | 39 | QVector<DocId> l2 = {3, 4, 5, 7, 9, 11}; | ||
40 | QVector<quint64> l3 = {1, 3, 7}; | 40 | QVector<DocId> l3 = {1, 3, 7}; | ||
41 | 41 | | |||
42 | VectorPostingIterator* it1 = new VectorPostingIterator(l1); | 42 | VectorPostingIterator* it1 = new VectorPostingIterator(l1); | ||
43 | VectorPostingIterator* it2 = new VectorPostingIterator(l2); | 43 | VectorPostingIterator* it2 = new VectorPostingIterator(l2); | ||
44 | VectorPostingIterator* it3 = new VectorPostingIterator(l3); | 44 | VectorPostingIterator* it3 = new VectorPostingIterator(l3); | ||
45 | 45 | | |||
46 | QVector<PostingIterator*> vec = {it1, it2, it3}; | 46 | QVector<PostingIterator*> vec = {it1, it2, it3}; | ||
47 | AndPostingIterator it(vec); | 47 | AndPostingIterator it(vec); | ||
48 | QCOMPARE(it.docId(), static_cast<quint64>(0)); | 48 | QCOMPARE(it.docId(), static_cast<DocId>(0)); | ||
49 | 49 | | |||
50 | QVector<quint64> result = {3, 7}; | 50 | QVector<DocId> result = {3, 7}; | ||
51 | for (quint64 val : result) { | 51 | for (DocId val : result) { | ||
52 | QCOMPARE(it.next(), static_cast<quint64>(val)); | 52 | QCOMPARE(it.next(), static_cast<DocId>(val)); | ||
53 | QCOMPARE(it.docId(), static_cast<quint64>(val)); | 53 | QCOMPARE(it.docId(), static_cast<DocId>(val)); | ||
54 | } | 54 | } | ||
55 | QCOMPARE(it.next(), static_cast<quint64>(0)); | 55 | QCOMPARE(it.next(), static_cast<DocId>(0)); | ||
56 | QCOMPARE(it.docId(), static_cast<quint64>(0)); | 56 | QCOMPARE(it.docId(), static_cast<DocId>(0)); | ||
57 | } | 57 | } | ||
58 | 58 | | |||
59 | void AndPostingIteratorTest::testNullIterators() | 59 | void AndPostingIteratorTest::testNullIterators() | ||
60 | { | 60 | { | ||
61 | QVector<quint64> l1 = {1, 3, 5, 7}; | 61 | QVector<DocId> l1 = {1, 3, 5, 7}; | ||
62 | QVector<quint64> l2 = {3, 4, 5, 7, 9, 11}; | 62 | QVector<DocId> l2 = {3, 4, 5, 7, 9, 11}; | ||
63 | 63 | | |||
64 | VectorPostingIterator* it1 = new VectorPostingIterator(l1); | 64 | VectorPostingIterator* it1 = new VectorPostingIterator(l1); | ||
65 | VectorPostingIterator* it2 = new VectorPostingIterator(l2); | 65 | VectorPostingIterator* it2 = new VectorPostingIterator(l2); | ||
66 | 66 | | |||
67 | QVector<PostingIterator*> vec = {it1, nullptr, it2}; | 67 | QVector<PostingIterator*> vec = {it1, nullptr, it2}; | ||
68 | 68 | | |||
69 | AndPostingIterator it(vec); | 69 | AndPostingIterator it(vec); | ||
70 | QCOMPARE(it.docId(), static_cast<quint64>(0)); | 70 | QCOMPARE(it.docId(), static_cast<DocId>(0)); | ||
71 | QCOMPARE(it.next(), static_cast<quint64>(0)); | 71 | QCOMPARE(it.next(), static_cast<DocId>(0)); | ||
72 | QCOMPARE(it.docId(), static_cast<quint64>(0)); | 72 | QCOMPARE(it.docId(), static_cast<DocId>(0)); | ||
73 | } | 73 | } | ||
74 | 74 | | |||
75 | 75 | | |||
76 | QTEST_MAIN(AndPostingIteratorTest) | 76 | QTEST_MAIN(AndPostingIteratorTest) | ||
77 | 77 | | |||
78 | #include "andpostingiteratortest.moc" | 78 | #include "andpostingiteratortest.moc" |