File indexing completed on 2024-12-08 09:34:34

0001 /*
0002     This file is part of KDE.
0003 
0004     SPDX-FileCopyrightText: 2010 Martin Sandsmark <martin.sandsmark@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007 */
0008 
0009 #include <QTest>
0010 #include <personparser.h>
0011 
0012 using namespace Attica;
0013 
0014 class PersonTest : public QObject
0015 {
0016     Q_OBJECT
0017 
0018 private Q_SLOTS:
0019     void testParsing();
0020 };
0021 
0022 void PersonTest::testParsing()
0023 {
0024     Person::Parser parser;
0025     QString validData(
0026         QLatin1String("<?xml version=\"1.0\"?>"
0027                       "<ocs><person>"
0028                       "<personid>10</personid>"
0029                       "<firstname>Ola</firstname>"
0030                       "<lastname>Nordmann</lastname>"
0031                       "<homepage>http://kde.org/</homepage>"
0032                       "<avatarpic>http://techbase.kde.org/skins/oxygen/top-kde.png</avatarpic>"
0033                       "<avatarpicfound>1</avatarpicfound>"
0034                       "<birthday>2010-06-21</birthday>"
0035                       "<city>Oslo</city>"
0036                       "<country>Norway</country>"
0037                       "<latitude>59.56</latitude>"
0038                       "<longitude>10.41</longitude>"
0039                       "</person></ocs>"));
0040     Person person = parser.parse(validData);
0041     QVERIFY(person.isValid());
0042 
0043     QString invalidData = QLatin1String("<ocs><braaaaaaaaaaawrlawrf></braaaaaaaaaaawrlawrf></ocs>");
0044     person = parser.parse(invalidData);
0045     QVERIFY(!person.isValid());
0046 }
0047 
0048 QTEST_MAIN(PersonTest)
0049 
0050 #include "persontest.moc"