File indexing completed on 2024-11-24 04:44:20

0001 /*
0002   SPDX-FileCopyrightText: 2015-2024 Laurent Montel <montel@kde.org>
0003 
0004   SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "deleteitemsattributetest.h"
0008 #include "../deleteditemsattribute.h"
0009 #include <QTest>
0010 
0011 DeleteItemsAttributeTest::DeleteItemsAttributeTest(QObject *parent)
0012     : QObject(parent)
0013 {
0014 }
0015 
0016 DeleteItemsAttributeTest::~DeleteItemsAttributeTest() = default;
0017 
0018 void DeleteItemsAttributeTest::shouldHaveDefaultValue()
0019 {
0020     DeletedItemsAttribute attr;
0021     QVERIFY(attr.deletedItemOffsets().isEmpty());
0022     QCOMPARE(attr.offsetCount(), 0);
0023 }
0024 
0025 void DeleteItemsAttributeTest::shouldAssignValue()
0026 {
0027     DeletedItemsAttribute attr;
0028     QSet<quint64> lst;
0029     lst.insert(15);
0030     attr.addDeletedItemOffset(15);
0031     lst.insert(154);
0032     attr.addDeletedItemOffset(154);
0033     lst.insert(225);
0034     attr.addDeletedItemOffset(225);
0035     QVERIFY(!attr.deletedItemOffsets().isEmpty());
0036     QCOMPARE(attr.offsetCount(), 3);
0037     QCOMPARE(lst, attr.deletedItemOffsets());
0038 }
0039 
0040 void DeleteItemsAttributeTest::shouldDeserializeValue()
0041 {
0042     DeletedItemsAttribute attr;
0043     attr.addDeletedItemOffset(15);
0044     attr.addDeletedItemOffset(154);
0045     attr.addDeletedItemOffset(225);
0046     const QByteArray ba = attr.serialized();
0047     DeletedItemsAttribute result;
0048     result.deserialize(ba);
0049     QVERIFY(result == attr);
0050 }
0051 
0052 void DeleteItemsAttributeTest::shouldCloneAttribute()
0053 {
0054     DeletedItemsAttribute attr;
0055     attr.addDeletedItemOffset(15);
0056     attr.addDeletedItemOffset(154);
0057     attr.addDeletedItemOffset(225);
0058     DeletedItemsAttribute *result = attr.clone();
0059     QVERIFY(*result == attr);
0060     delete result;
0061 }
0062 
0063 void DeleteItemsAttributeTest::shouldHaveTypeName()
0064 {
0065     DeletedItemsAttribute attr;
0066     QCOMPARE(attr.type(), QByteArray("DeletedMboxItems"));
0067 }
0068 
0069 QTEST_MAIN(DeleteItemsAttributeTest)
0070 
0071 #include "moc_deleteitemsattributetest.cpp"