File indexing completed on 2024-04-14 03:54:05

0001 /*
0002     This file is part of KNewStuff2.
0003     SPDX-FileCopyrightText: 2008 Jeremy Whiting <jpwhiting@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-or-later
0006 */
0007 
0008 // unit test for author
0009 
0010 #include <QString>
0011 #include <QTest>
0012 
0013 #include "core/author.h"
0014 
0015 const QString name = QStringLiteral("Name");
0016 const QString email = QStringLiteral("Email@nowhere.com");
0017 const QString jabber = QStringLiteral("something@kdetalk.net");
0018 const QString homepage = QStringLiteral("http://www.myhomepage.com");
0019 
0020 class testAuthor : public QObject
0021 {
0022     Q_OBJECT
0023 private Q_SLOTS:
0024     void testProperties();
0025     void testCopy();
0026     void testAssignment();
0027 };
0028 
0029 void testAuthor::testProperties()
0030 {
0031     KNSCore::Author author;
0032     author.setName(name);
0033     author.setEmail(email);
0034     author.setJabber(jabber);
0035     author.setHomepage(homepage);
0036     QCOMPARE(author.name(), name);
0037     QCOMPARE(author.email(), email);
0038     QCOMPARE(author.jabber(), jabber);
0039     QCOMPARE(author.homepage(), homepage);
0040 }
0041 
0042 void testAuthor::testCopy()
0043 {
0044     KNSCore::Author author;
0045     author.setName(name);
0046     author.setEmail(email);
0047     author.setJabber(jabber);
0048     author.setHomepage(homepage);
0049     KNSCore::Author author2(author);
0050     QCOMPARE(author.name(), author2.name());
0051     QCOMPARE(author.email(), author2.email());
0052     QCOMPARE(author.jabber(), author2.jabber());
0053     QCOMPARE(author.homepage(), author2.homepage());
0054 }
0055 
0056 void testAuthor::testAssignment()
0057 {
0058     KNSCore::Author author;
0059     KNSCore::Author author2;
0060     author.setName(name);
0061     author.setEmail(email);
0062     author.setJabber(jabber);
0063     author.setHomepage(homepage);
0064     author2 = author;
0065     QCOMPARE(author.name(), author2.name());
0066     QCOMPARE(author.email(), author2.email());
0067     QCOMPARE(author.jabber(), author2.jabber());
0068     QCOMPARE(author.homepage(), author2.homepage());
0069 }
0070 
0071 QTEST_GUILESS_MAIN(testAuthor)
0072 #include "knewstuffauthortest.moc"