Commit 77eff09a authored by Laurent Montel's avatar Laurent Montel 😁

Add some autotest

parent df4d3a9d
macro(add_autocreatescriptswidget_test _source _additionalsource)
set( _test ${_source} ${_additionalsource})
get_filename_component( _name ${_source} NAME_WE )
add_executable( ${_name} ${_test} )
add_test( ${_name} ${_name} )
ecm_mark_as_test(sievescriptdebugger-${_name})
target_link_libraries( ${_name} KF5::KSieveUi Qt5::Test)
endmacro()
add_autocreatescriptswidget_test(lineeditvalidatortest.cpp "")
/*
Copyright (C) 2017 Laurent Montel <montel@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "lineeditvalidatortest.h"
#include "../lineeditvalidator.h"
#include <QTest>
QTEST_MAIN(LineEditValidatorTest)
LineEditValidatorTest::LineEditValidatorTest(QObject *parent)
: QObject(parent)
{
}
LineEditValidatorTest::~LineEditValidatorTest()
{
}
void LineEditValidatorTest::shouldHaveDefaultValue()
{
KSieveUi::LineEditValidator lineedit;
QVERIFY(lineedit.text().isEmpty());
}
void LineEditValidatorTest::shouldAssignRegularExpression_data()
{
QTest::addColumn<QString>("regularExpression");
QTest::addColumn<bool>("success");
QTest::newRow("Empty") << QString() << true;
QTest::newRow("error") << QStringLiteral("\\u2029") << false;
}
void LineEditValidatorTest::shouldAssignRegularExpression()
{
QFETCH(QString, regularExpression);
QFETCH(bool, success);
KSieveUi::LineEditValidator lineedit;
QCOMPARE(lineedit.setRegularExpressionPattern(regularExpression), success);
}
/*
Copyright (C) 2017 Laurent Montel <montel@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef LINEEDITVALIDATORTEST_H
#define LINEEDITVALIDATORTEST_H
#include <QObject>
class LineEditValidatorTest : public QObject
{
Q_OBJECT
public:
explicit LineEditValidatorTest(QObject *parent = nullptr);
~LineEditValidatorTest();
private Q_SLOTS:
void shouldHaveDefaultValue();
void shouldAssignRegularExpression_data();
void shouldAssignRegularExpression();
};
#endif // LINEEDITVALIDATORTEST_H
......@@ -21,9 +21,10 @@
#define LINEEDITVALIDATOR_H
#include <QLineEdit>
#include "ksieveui_private_export.h"
class QRegularExpressionValidator;
namespace KSieveUi {
class LineEditValidator : public QLineEdit
class KSIEVEUI_TESTS_EXPORT LineEditValidator : public QLineEdit
{
Q_OBJECT
public:
......
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