diff --git a/autotests/unit/engine/phraseanditeratortest.cpp b/autotests/unit/engine/phraseanditeratortest.cpp index f571f1f5..4db1cf7f 100644 --- a/autotests/unit/engine/phraseanditeratortest.cpp +++ b/autotests/unit/engine/phraseanditeratortest.cpp @@ -1,114 +1,114 @@ /* This file is part of the KDE Baloo project. * Copyright (C) 2015 Vishesh Handa * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ #include "phraseanditerator.h" #include "vectorpositioninfoiterator.h" #include "positioninfo.h" #include using namespace Baloo; class PhraseAndIteratorTest : public QObject { Q_OBJECT private Q_SLOTS: void test(); void testNullIterators(); }; void PhraseAndIteratorTest::test() { // Term 1 - PositionInfo pi1; - pi1.docId = 2; - pi1.positions = {5, 9}; + PositionInfo pi2_1; // pi_ + pi2_1.docId = 2; + pi2_1.positions = {5, 9}; - PositionInfo pi2; - pi2.docId = 4; - pi2.positions = {4, 2}; + PositionInfo pi4_1; + pi4_1.docId = 4; + pi4_1.positions = {4, 2}; QVector vec1; - vec1 << pi1 << pi2; + vec1 << pi2_1 << pi4_1; // Term 2 - PositionInfo pi3; - pi3.docId = 2; - pi3.positions = {6, 7}; + PositionInfo pi2_2; + pi2_2.docId = 2; + pi2_2.positions = {6, 7}; - PositionInfo pi4; - pi4.docId = 4; - pi4.positions = {6, 2}; + PositionInfo pi4_2; + pi4_2.docId = 4; + pi4_2.positions = {6, 2}; - PositionInfo pi5; - pi5.docId = 7; - pi5.positions = {1, 4, 2}; + PositionInfo pi7_2; + pi7_2.docId = 7; + pi7_2.positions = {1, 4, 2}; QVector vec2; - vec2 << pi3 << pi4 << pi5; + vec2 << pi2_2 << pi4_2 << pi7_2; VectorPositionInfoIterator* it1 = new VectorPositionInfoIterator(vec1); VectorPositionInfoIterator* it2 = new VectorPositionInfoIterator(vec2); QVector vec = {it1, it2}; PhraseAndIterator it(vec); QCOMPARE(it.docId(), static_cast(0)); // The Query is "term1 term2". term1 must appear one position before term2 QVector result = {2}; for (quint64 val : result) { QCOMPARE(it.next(), static_cast(val)); QCOMPARE(it.docId(), static_cast(val)); } QCOMPARE(it.next(), static_cast(0)); QCOMPARE(it.docId(), static_cast(0)); } void PhraseAndIteratorTest::testNullIterators() { // Term 1 - PositionInfo pi1; - pi1.docId = 2; - pi1.positions = {5, 9}; + PositionInfo pi2_1; + pi2_1.docId = 2; + pi2_1.positions = {5, 9}; QVector vec1; - vec1 << pi1; + vec1 << pi2_1; // Term 2 - PositionInfo pi2; - pi2.docId = 2; - pi2.positions = {6, 7}; + PositionInfo pi2_2; + pi2_2.docId = 2; + pi2_2.positions = {6, 7}; QVector vec2; - vec2 << pi2; + vec2 << pi2_2; VectorPositionInfoIterator* it1 = new VectorPositionInfoIterator(vec1); VectorPositionInfoIterator* it2 = new VectorPositionInfoIterator(vec2); QVector vec = {it1, nullptr, it2}; PhraseAndIterator it(vec); QCOMPARE(it.docId(), static_cast(0)); QCOMPARE(it.next(), static_cast(0)); QCOMPARE(it.docId(), static_cast(0)); } QTEST_MAIN(PhraseAndIteratorTest) #include "phraseanditeratortest.moc"