File indexing completed on 2024-12-01 06:41:44

0001 /*
0002     This file is part of KDE.
0003 
0004     SPDX-FileCopyrightText: 2018 Ralf Habacker <ralf.habacker@freenet.de>
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 <configparser.h>
0011 
0012 using namespace Attica;
0013 
0014 class ConfigTest : public QObject
0015 {
0016     Q_OBJECT
0017 
0018 private Q_SLOTS:
0019     void testParsing();
0020 };
0021 
0022 void ConfigTest::testParsing()
0023 {
0024     Config::Parser parser;
0025     QString validData(
0026         QLatin1String("<?xml version=\"1.0\"?>"
0027                       "<ocs><data>"
0028                       "<version>1.7</version>"
0029                       "<website>store.kde.org</website>"
0030                       "<host>api.kde-look.org</host>"
0031                       "<contact>contact@opendesktop.org</contact>"
0032                       "<ssl>true</ssl>"
0033                       "</data></ocs>"));
0034     Config config = parser.parse(validData);
0035     QVERIFY(config.isValid());
0036 
0037     QString invalidData = QLatin1String("<ocs><braaaaaaaaaaawrlawrf></braaaaaaaaaaawrlawrf></ocs>");
0038     config = parser.parse(invalidData);
0039     QVERIFY(!config.isValid());
0040 }
0041 
0042 QTEST_GUILESS_MAIN(ConfigTest)
0043 
0044 #include "configtest.moc"