1 /*
2     This file is part of KNewStuff2.
3     SPDX-FileCopyrightText: 2008 Jeremy Whiting <jpwhiting@kde.org>
4 
5     SPDX-License-Identifier: LGPL-2.1-or-later
6 */
7 
8 // unit test for author
9 
10 #include <QString>
11 #include <QTest>
12 
13 #include "core/author.h"
14 
15 const QString name = QStringLiteral("Name");
16 const QString email = QStringLiteral("Email@nowhere.com");
17 const QString jabber = QStringLiteral("something@kdetalk.net");
18 const QString homepage = QStringLiteral("http://www.myhomepage.com");
19 
20 class testAuthor : public QObject
21 {
22     Q_OBJECT
23 private Q_SLOTS:
24     void testProperties();
25     void testCopy();
26     void testAssignment();
27 };
28 
testProperties()29 void testAuthor::testProperties()
30 {
31     KNSCore::Author author;
32     author.setName(name);
33     author.setEmail(email);
34     author.setJabber(jabber);
35     author.setHomepage(homepage);
36     QCOMPARE(author.name(), name);
37     QCOMPARE(author.email(), email);
38     QCOMPARE(author.jabber(), jabber);
39     QCOMPARE(author.homepage(), homepage);
40 }
41 
testCopy()42 void testAuthor::testCopy()
43 {
44     KNSCore::Author author;
45     author.setName(name);
46     author.setEmail(email);
47     author.setJabber(jabber);
48     author.setHomepage(homepage);
49     KNSCore::Author author2(author);
50     QCOMPARE(author.name(), author2.name());
51     QCOMPARE(author.email(), author2.email());
52     QCOMPARE(author.jabber(), author2.jabber());
53     QCOMPARE(author.homepage(), author2.homepage());
54 }
55 
testAssignment()56 void testAuthor::testAssignment()
57 {
58     KNSCore::Author author;
59     KNSCore::Author author2;
60     author.setName(name);
61     author.setEmail(email);
62     author.setJabber(jabber);
63     author.setHomepage(homepage);
64     author2 = author;
65     QCOMPARE(author.name(), author2.name());
66     QCOMPARE(author.email(), author2.email());
67     QCOMPARE(author.jabber(), author2.jabber());
68     QCOMPARE(author.homepage(), author2.homepage());
69 }
70 
71 QTEST_GUILESS_MAIN(testAuthor)
72 #include "knewstuffauthortest.moc"
73