Changeset View
Changeset View
Standalone View
Standalone View
autotests/unit/engine/mtimedbtest.cpp
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | 55 | void testIter() { | |||
---|---|---|---|---|---|
57 | 57 | | |||
58 | db.put(5, 1); | 58 | db.put(5, 1); | ||
59 | db.put(6, 2); | 59 | db.put(6, 2); | ||
60 | db.put(6, 3); | 60 | db.put(6, 3); | ||
61 | db.put(7, 4); | 61 | db.put(7, 4); | ||
62 | db.put(8, 5); | 62 | db.put(8, 5); | ||
63 | db.put(9, 6); | 63 | db.put(9, 6); | ||
64 | 64 | | |||
65 | PostingIterator* it = db.iter(6, MTimeDB::GreaterEqual); | 65 | PostingIterator* it = db.iterRange(6, std::numeric_limits<quint32>::max()); | ||
66 | QVERIFY(it); | 66 | QVERIFY(it); | ||
67 | 67 | | |||
68 | QVector<quint64> result = {2, 3, 4, 5, 6}; | 68 | QVector<quint64> result = {2, 3, 4, 5, 6}; | ||
69 | for (quint64 val : result) { | 69 | for (quint64 val : result) { | ||
70 | QCOMPARE(it->next(), static_cast<quint64>(val)); | 70 | QCOMPARE(it->next(), static_cast<quint64>(val)); | ||
71 | QCOMPARE(it->docId(), static_cast<quint64>(val)); | 71 | QCOMPARE(it->docId(), static_cast<quint64>(val)); | ||
72 | } | 72 | } | ||
73 | 73 | | |||
74 | it = db.iter(10, MTimeDB::LessEqual); | 74 | it = db.iterRange(0, 10); | ||
75 | QVERIFY(it); | 75 | QVERIFY(it); | ||
76 | 76 | | |||
77 | result = {1, 2, 3, 4, 5, 6}; | 77 | result = {1, 2, 3, 4, 5, 6}; | ||
78 | for (quint64 val : result) { | 78 | for (quint64 val : result) { | ||
79 | QCOMPARE(it->next(), static_cast<quint64>(val)); | 79 | QCOMPARE(it->next(), static_cast<quint64>(val)); | ||
80 | QCOMPARE(it->docId(), static_cast<quint64>(val)); | 80 | QCOMPARE(it->docId(), static_cast<quint64>(val)); | ||
81 | } | 81 | } | ||
82 | 82 | | |||
83 | it = db.iter(7, MTimeDB::LessEqual); | 83 | it = db.iterRange(0, 7); | ||
84 | QVERIFY(it); | 84 | QVERIFY(it); | ||
85 | 85 | | |||
86 | result = {1, 2, 3, 4}; | 86 | result = {1, 2, 3, 4}; | ||
87 | for (quint64 val : result) { | 87 | for (quint64 val : result) { | ||
88 | QCOMPARE(it->next(), static_cast<quint64>(val)); | 88 | QCOMPARE(it->next(), static_cast<quint64>(val)); | ||
89 | QCOMPARE(it->docId(), static_cast<quint64>(val)); | 89 | QCOMPARE(it->docId(), static_cast<quint64>(val)); | ||
90 | } | 90 | } | ||
91 | 91 | | |||
92 | it = db.iter(6, MTimeDB::LessEqual); | 92 | it = db.iterRange(0, 6); | ||
93 | QVERIFY(it); | 93 | QVERIFY(it); | ||
94 | 94 | | |||
95 | result = {1, 2, 3}; | 95 | result = {1, 2, 3}; | ||
96 | for (quint64 val : result) { | 96 | for (quint64 val : result) { | ||
97 | QCOMPARE(it->next(), static_cast<quint64>(val)); | 97 | QCOMPARE(it->next(), static_cast<quint64>(val)); | ||
98 | QCOMPARE(it->docId(), static_cast<quint64>(val)); | 98 | QCOMPARE(it->docId(), static_cast<quint64>(val)); | ||
99 | } | 99 | } | ||
100 | } | 100 | } | ||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | 144 | { | |||
145 | QVector<quint64> result = {1, 2, 3, 4}; | 145 | QVector<quint64> result = {1, 2, 3, 4}; | ||
146 | for (quint64 val : result) { | 146 | for (quint64 val : result) { | ||
147 | QCOMPARE(it->next(), static_cast<quint64>(val)); | 147 | QCOMPARE(it->next(), static_cast<quint64>(val)); | ||
148 | QCOMPARE(it->docId(), static_cast<quint64>(val)); | 148 | QCOMPARE(it->docId(), static_cast<quint64>(val)); | ||
149 | } | 149 | } | ||
150 | } | 150 | } | ||
151 | 151 | | |||
152 | { | 152 | { | ||
153 | it = db.iter(6, MTimeDB::GreaterEqual); | 153 | it = db.iterRange(6, std::numeric_limits<quint32>::max()); | ||
154 | QVERIFY(it); | 154 | QVERIFY(it); | ||
155 | 155 | | |||
156 | QVector<quint64> result = {2, 3, 4}; | 156 | QVector<quint64> result = {2, 3, 4}; | ||
157 | for (quint64 val : result) { | 157 | for (quint64 val : result) { | ||
158 | QCOMPARE(it->next(), static_cast<quint64>(val)); | 158 | QCOMPARE(it->next(), static_cast<quint64>(val)); | ||
159 | QCOMPARE(it->docId(), static_cast<quint64>(val)); | 159 | QCOMPARE(it->docId(), static_cast<quint64>(val)); | ||
160 | } | 160 | } | ||
161 | } | 161 | } | ||
Show All 9 Lines | 164 | void testBeginOfEpoch() { | |||
171 | 171 | | |||
172 | QCOMPARE(db.get(0), QVector<quint64>({1, 2, 3})); | 172 | QCOMPARE(db.get(0), QVector<quint64>({1, 2, 3})); | ||
173 | db.del(99, 2); | 173 | db.del(99, 2); | ||
174 | QCOMPARE(db.get(0), QVector<quint64>({1, 2, 3})); | 174 | QCOMPARE(db.get(0), QVector<quint64>({1, 2, 3})); | ||
175 | QCOMPARE(db.get(1), QVector<quint64>({4})); | 175 | QCOMPARE(db.get(1), QVector<quint64>({4})); | ||
176 | db.del(0, 2); | 176 | db.del(0, 2); | ||
177 | QCOMPARE(db.get(0), QVector<quint64>({1, 3})); | 177 | QCOMPARE(db.get(0), QVector<quint64>({1, 3})); | ||
178 | 178 | | |||
179 | PostingIterator* it = db.iter(0, MTimeDB::LessEqual); | 179 | PostingIterator* it = db.iterRange(0, 0); | ||
180 | QVector<quint64> result; | 180 | QVector<quint64> result; | ||
181 | while (it->next()) { | 181 | while (it->next()) { | ||
182 | result.append(it->docId()); | 182 | result.append(it->docId()); | ||
183 | } | 183 | } | ||
184 | QCOMPARE(result, QVector<quint64>({1, 3})); | 184 | QCOMPARE(result, QVector<quint64>({1, 3})); | ||
185 | 185 | | |||
186 | it = db.iter(1, MTimeDB::GreaterEqual); | 186 | it = db.iterRange(1, std::numeric_limits<quint32>::max()); | ||
187 | QVERIFY(it->next()); | 187 | QVERIFY(it->next()); | ||
188 | QCOMPARE(it->docId(), 4); | 188 | QCOMPARE(it->docId(), 4); | ||
189 | } | 189 | } | ||
190 | }; | 190 | }; | ||
191 | 191 | | |||
192 | QTEST_MAIN(MTimeDBTest) | 192 | QTEST_MAIN(MTimeDBTest) | ||
193 | 193 | | |||
194 | #include "mtimedbtest.moc" | 194 | #include "mtimedbtest.moc" |