File indexing completed on 2024-04-28 05:52:32

0001 /*
0002     This file is part of the Okteta Core library, made within the KDE community.
0003 
0004     SPDX-FileCopyrightText: 2007 Friedrich W. H. Kossebau <kossebau@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007 */
0008 
0009 #include "bookmarktest.hpp"
0010 
0011 // test object
0012 #include <bookmark.hpp>
0013 // Qt
0014 #include <QTest>
0015 
0016 using namespace Okteta;
0017 
0018 static constexpr int Offset1 = 7;
0019 static constexpr int Offset2 = 23;
0020 
0021 void BookmarkTest::testSimpleConstructor()
0022 {
0023     Bookmark bookmark;
0024 
0025     QVERIFY(!bookmark.isValid());
0026 }
0027 
0028 void BookmarkTest::testConstructor()
0029 {
0030     Bookmark bookmark(Offset1);
0031 
0032     QVERIFY(bookmark.isValid());
0033     QCOMPARE(bookmark.offset(), Offset1);
0034 }
0035 
0036 void BookmarkTest::testCompare()
0037 {
0038     Bookmark bookmark1(Offset1);
0039     Bookmark bookmark2(Offset1);
0040     Bookmark bookmark3(Offset2);
0041 
0042     QVERIFY(bookmark1 == bookmark2);
0043     QVERIFY(!(bookmark1 == bookmark3));
0044 }
0045 
0046 void BookmarkTest::testMove()
0047 {
0048     Bookmark bookmark(Offset1);
0049     bookmark.move(Offset2);
0050 
0051     QVERIFY(bookmark.isValid());
0052     QCOMPARE(bookmark.offset(), Offset1 + Offset2);
0053 }
0054 
0055 QTEST_GUILESS_MAIN(BookmarkTest)
0056 
0057 #include "moc_bookmarktest.cpp"