File indexing completed on 2024-04-14 03:51:21

0001 /*
0002     This file is part of the KContacts framework.
0003     SPDX-FileCopyrightText: 2007 Tobias Koenig <tokoe@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #include "secrecytest.h"
0009 #include "kcontacts/secrecy.h"
0010 #include "vcardtool_p.h"
0011 #include <QTest>
0012 
0013 QTEST_MAIN(SecrecyTest)
0014 
0015 void SecrecyTest::emptyTest()
0016 {
0017     KContacts::Secrecy secrecy;
0018 
0019     QVERIFY(secrecy.type() == KContacts::Secrecy::Invalid);
0020 }
0021 
0022 void SecrecyTest::storeTest()
0023 {
0024     KContacts::Secrecy secrecy;
0025 
0026     secrecy.setType(KContacts::Secrecy::Private);
0027 
0028     QVERIFY(secrecy.type() == KContacts::Secrecy::Private);
0029 }
0030 
0031 void SecrecyTest::equalsTest()
0032 {
0033     KContacts::Secrecy secrecy1;
0034     KContacts::Secrecy secrecy2;
0035 
0036     secrecy1.setType(KContacts::Secrecy::Confidential);
0037     secrecy2.setType(KContacts::Secrecy::Confidential);
0038 
0039     QVERIFY(secrecy1 == secrecy2);
0040 }
0041 
0042 void SecrecyTest::differsTest()
0043 {
0044     KContacts::Secrecy secrecy1(KContacts::Secrecy::Private);
0045     KContacts::Secrecy secrecy2(KContacts::Secrecy::Confidential);
0046 
0047     QVERIFY(secrecy1 != secrecy2);
0048 }
0049 
0050 void SecrecyTest::assignmentTest()
0051 {
0052     KContacts::Secrecy secrecy1;
0053     KContacts::Secrecy secrecy2;
0054 
0055     secrecy1.setType(KContacts::Secrecy::Confidential);
0056     secrecy1 = secrecy2;
0057 
0058     QVERIFY(secrecy1 == secrecy2);
0059 }
0060 
0061 void SecrecyTest::serializeTest()
0062 {
0063     KContacts::Secrecy secrecy1;
0064     KContacts::Secrecy secrecy2;
0065 
0066     secrecy1.setType(KContacts::Secrecy::Confidential);
0067 
0068     QByteArray data;
0069     QDataStream s(&data, QIODevice::WriteOnly);
0070     s << secrecy1;
0071 
0072     QDataStream t(&data, QIODevice::ReadOnly);
0073     t >> secrecy2;
0074 
0075     QVERIFY(secrecy1 == secrecy2);
0076 }
0077 
0078 #include "moc_secrecytest.cpp"