File indexing completed on 2024-04-28 03:51:39

0001 /*
0002     This file is part of the KDE Baloo project.
0003     SPDX-FileCopyrightText: 2015 Vishesh Handa <vhanda@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-or-later
0006 */
0007 
0008 #include "documenttimedb.h"
0009 #include "singledbtest.h"
0010 
0011 using namespace Baloo;
0012 
0013 class DocumentTimeDBTest : public SingleDBTest
0014 {
0015     Q_OBJECT
0016 private Q_SLOTS:
0017     void test();
0018     void testAllowZeroTime();
0019 };
0020 
0021 void DocumentTimeDBTest::test()
0022 {
0023     DocumentTimeDB db(DocumentTimeDB::create(m_txn), m_txn);
0024 
0025     DocumentTimeDB::TimeInfo info;
0026     info.mTime = 5;
0027     info.cTime = 6;
0028 
0029     db.put(1, info);
0030     QCOMPARE(db.get(1), info);
0031 
0032     db.del(1);
0033     QCOMPARE(db.get(1), DocumentTimeDB::TimeInfo());
0034 }
0035 
0036 void DocumentTimeDBTest::testAllowZeroTime()
0037 {
0038     DocumentTimeDB db(DocumentTimeDB::create(m_txn), m_txn);
0039 
0040     // we must be able to handle zero time, aka 1970...
0041     DocumentTimeDB::TimeInfo info;
0042     info.mTime = 0;
0043     info.cTime = 0;
0044 
0045     db.put(1, info);
0046     QCOMPARE(db.get(1), info);
0047 
0048     db.del(1);
0049     QCOMPARE(db.get(1), DocumentTimeDB::TimeInfo());
0050 }
0051 
0052 QTEST_MAIN(DocumentTimeDBTest)
0053 
0054 #include "documenttimedbtest.moc"