File indexing completed on 2024-05-19 07:53:18
0001 /* Copyright (c) 2019 Shlomi Fish 0002 * 0003 * Permission is hereby granted, free of charge, to any person 0004 * obtaining a copy of this software and associated documentation 0005 * files (the "Software"), to deal in the Software without 0006 * restriction, including without limitation the rights to use, 0007 * copy, modify, merge, publish, distribute, sublicense, and/or sell 0008 * copies of the Software, and to permit persons to whom the 0009 * Software is furnished to do so, subject to the following 0010 * conditions: 0011 * 0012 * The above copyright notice and this permission notice shall be 0013 * included in all copies or substantial portions of the Software. 0014 * 0015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 0016 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 0017 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 0018 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 0019 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 0020 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 0021 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 0022 * OTHER DEALINGS IN THE SOFTWARE. 0023 */ 0024 #include <QProcess> 0025 #include <QRegularExpression> 0026 #include <QTest> 0027 0028 class TestSolver: public QObject 0029 { 0030 Q_OBJECT 0031 private Q_SLOTS: 0032 void runSolver(); 0033 }; 0034 0035 void TestSolver::runSolver() 0036 { 0037 QProcess kpat; 0038 kpat.start(QStringLiteral("../bin/kpat"), QStringList() << QStringLiteral("--start") << "1" << QStringLiteral("--end") << "3" << QStringLiteral("--solve") << QStringLiteral("Golf")); 0039 QCOMPARE(kpat.waitForFinished(), true); 0040 QCOMPARE(kpat.exitStatus(), QProcess::NormalExit); 0041 QCOMPARE(kpat.exitCode(), 0); 0042 auto bytes = kpat.readAllStandardOutput(); 0043 QCOMPARE(QRegularExpression("\\n2 won \\(").match(QString(bytes)).hasMatch(), true); 0044 } 0045 0046 QTEST_MAIN(TestSolver) 0047 #include "golf_solver_wins.moc"