blob: 5184b921aea892fd2adf3f1d5ffe711759f87bda [file]
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file LICENSE.rst or https://cmake.org/licensing for details. */
#include "RegexExplorerTest.h"
#include <QCheckBox>
#include <QComboBox>
#include <QLineEdit>
#include <QPlainTextEdit>
#include <QString>
#include <QtTest>
#include "RegexExplorer.h"
void RegexExplorerTest::regexExplorer()
{
RegexExplorer explorer(nullptr);
// Each edit below goes through one of the dialog's signal connections.
explorer.inputText->setPlainText("xaby");
QCOMPARE(explorer.match0->toPlainText(), QString());
explorer.regularExpression->setText("(a)(b)");
QCOMPARE(explorer.match0->toPlainText(), QString("ab"));
QCOMPARE(explorer.matchN->toPlainText(), QString("a"));
explorer.matchNumber->setCurrentIndex(1);
QCOMPARE(explorer.matchN->toPlainText(), QString("b"));
explorer.inputText->setPlainText("ab ab");
explorer.matchAll->setChecked(true);
QCOMPARE(explorer.match0->toPlainText(), QString("ab;ab"));
explorer.matchAll->setChecked(false);
QCOMPARE(explorer.match0->toPlainText(), QString("ab"));
explorer.inputText->setPlainText("no match");
QCOMPARE(explorer.match0->toPlainText(), QString());
QCOMPARE(explorer.matchN->toPlainText(), QString());
}
QTEST_MAIN(RegexExplorerTest)