Commit 4cbeb884 authored by Volker Krause's avatar Volker Krause
Browse files

Add basic unit test for result validator

Doesn't do much yet, but will be useful as the validator gets extended.
parent 9eee800f
...@@ -25,6 +25,7 @@ ecm_add_test(barcodedecodertest.cpp LINK_LIBRARIES Qt5::Test KPim::Itinerary Qt5 ...@@ -25,6 +25,7 @@ ecm_add_test(barcodedecodertest.cpp LINK_LIBRARIES Qt5::Test KPim::Itinerary Qt5
ecm_add_test(pkpassextractortest.cpp LINK_LIBRARIES Qt5::Test KPim::Itinerary KPim::PkPass) ecm_add_test(pkpassextractortest.cpp LINK_LIBRARIES Qt5::Test KPim::Itinerary KPim::PkPass)
ecm_add_test(extractorutiltest.cpp LINK_LIBRARIES Qt5::Test KPim::Itinerary) ecm_add_test(extractorutiltest.cpp LINK_LIBRARIES Qt5::Test KPim::Itinerary)
ecm_add_test(postprocessortest.cpp LINK_LIBRARIES Qt5::Test KPim::Itinerary) ecm_add_test(postprocessortest.cpp LINK_LIBRARIES Qt5::Test KPim::Itinerary)
ecm_add_test(extractorvalidatortest.cpp LINK_LIBRARIES Qt5::Test KPim::Itinerary)
if (TARGET KF5::CalendarCore) if (TARGET KF5::CalendarCore)
ecm_add_test(calendarhandlertest.cpp LINK_LIBRARIES Qt5::Test KPim::Itinerary) ecm_add_test(calendarhandlertest.cpp LINK_LIBRARIES Qt5::Test KPim::Itinerary)
ecm_add_test(extractortest.cpp LINK_LIBRARIES Qt5::Test KPim::Itinerary KPim::PkPass) ecm_add_test(extractortest.cpp LINK_LIBRARIES Qt5::Test KPim::Itinerary KPim::PkPass)
......
/*
Copyright (C) 2020 Volker Krause <vkrause@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <extractorvalidator.h>
#include <KItinerary/JsonLdDocument>
#include <QDebug>
#include <QFile>
#include <QJsonArray>
#include <QJsonDocument>
#include <QTest>
using namespace KItinerary;
class ExtractorValidatorTest : public QObject
{
Q_OBJECT
private:
QByteArray readFile(const char *fn) const
{
QFile f(QString::fromUtf8(fn));
f.open(QFile::ReadOnly);
return f.readAll();
}
private Q_SLOTS:
void testValidate()
{
ExtractorValidator v;
auto input = JsonLdDocument::fromJson(QJsonDocument::fromJson(readFile(SOURCE_DIR "/mergedata/cancellation.lhs.json")).array());
QCOMPARE(input.size(), 1);
QVERIFY(v.isValidElement(input.at(0)));
input = JsonLdDocument::fromJson(QJsonDocument::fromJson(readFile(SOURCE_DIR "/mergedata/cancellation.rhs.json")).array());
QCOMPARE(input.size(), 1);
QEXPECT_FAIL("", "not implemented yet", Continue);
QVERIFY(v.isValidElement(input.at(0)));
// TODO test type filtering
}
};
QTEST_GUILESS_MAIN(ExtractorValidatorTest)
#include "extractorvalidatortest.moc"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment