Changeset View
Changeset View
Standalone View
Standalone View
autotests/unit/engine/orpostingiteratortest.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 OrPostingIteratorTest::test() | 36 | void OrPostingIteratorTest::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 | OrPostingIterator it(vec); | 47 | OrPostingIterator it(vec); | ||
48 | QCOMPARE(it.docId(), static_cast<quint64>(0)); | 48 | QCOMPARE(it.docId(), static_cast<DocId>(0)); | ||
49 | 49 | | |||
50 | QVector<quint64> result = {1, 3, 4, 5, 7, 9, 11}; | 50 | QVector<DocId> result = {1, 3, 4, 5, 7, 9, 11}; | ||
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 OrPostingIteratorTest::testNullIterators() | 59 | void OrPostingIteratorTest::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 | QVector<quint64> l3 = {1, 3, 7}; | 63 | QVector<DocId> l3 = {1, 3, 7}; | ||
64 | 64 | | |||
65 | VectorPostingIterator* it1 = new VectorPostingIterator(l1); | 65 | VectorPostingIterator* it1 = new VectorPostingIterator(l1); | ||
66 | VectorPostingIterator* it2 = new VectorPostingIterator(l2); | 66 | VectorPostingIterator* it2 = new VectorPostingIterator(l2); | ||
67 | VectorPostingIterator* it3 = new VectorPostingIterator(l3); | 67 | VectorPostingIterator* it3 = new VectorPostingIterator(l3); | ||
68 | 68 | | |||
69 | QVector<PostingIterator*> vec = {it1, nullptr, it2, nullptr, it3}; | 69 | QVector<PostingIterator*> vec = {it1, nullptr, it2, nullptr, it3}; | ||
70 | OrPostingIterator it(vec); | 70 | OrPostingIterator it(vec); | ||
71 | QCOMPARE(it.docId(), static_cast<quint64>(0)); | 71 | QCOMPARE(it.docId(), static_cast<DocId>(0)); | ||
72 | 72 | | |||
73 | QVector<quint64> result = {1, 3, 4, 5, 7, 9, 11}; | 73 | QVector<DocId> result = {1, 3, 4, 5, 7, 9, 11}; | ||
74 | for (quint64 val : result) { | 74 | for (DocId val : result) { | ||
75 | QCOMPARE(it.next(), static_cast<quint64>(val)); | 75 | QCOMPARE(it.next(), static_cast<DocId>(val)); | ||
76 | QCOMPARE(it.docId(), static_cast<quint64>(val)); | 76 | QCOMPARE(it.docId(), static_cast<DocId>(val)); | ||
77 | } | 77 | } | ||
78 | QCOMPARE(it.next(), static_cast<quint64>(0)); | 78 | QCOMPARE(it.next(), static_cast<DocId>(0)); | ||
79 | QCOMPARE(it.docId(), static_cast<quint64>(0)); | 79 | QCOMPARE(it.docId(), static_cast<DocId>(0)); | ||
80 | } | 80 | } | ||
81 | 81 | | |||
82 | 82 | | |||
83 | QTEST_MAIN(OrPostingIteratorTest) | 83 | QTEST_MAIN(OrPostingIteratorTest) | ||
84 | 84 | | |||
85 | #include "orpostingiteratortest.moc" | 85 | #include "orpostingiteratortest.moc" |