Commit 7bb41e89 authored by Shlomi Fish's avatar Shlomi Fish

Add an assert and a test for bz405187

Per @aacid 's request, and he is naturally right.
parent 56b4426d
......@@ -7,6 +7,12 @@ ecm_add_test(
LINK_LIBRARIES Qt5::Test
NAME_PREFIX "kpat-"
)
ecm_add_test(
freecell_solver.cpp
TEST_NAME FcSolveTest
LINK_LIBRARIES Qt5::Test
NAME_PREFIX "kpat-"
)
ecm_add_test(
"../dealer.cpp"
"../dealerinfo.cpp"
......
/* Copyright (c) 2019 Shlomi Fish
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include <QProcess>
#include <QTest>
class TestSolver: public QObject
{
Q_OBJECT
private slots:
void runSolver();
};
void TestSolver::runSolver()
{
QProcess kpat;
const char *const deal = "830910836";
kpat.start("../kpat", QStringList() << "--start" << deal << "--end" << deal << "--solve" << "3");
QCOMPARE(kpat.waitForFinished(), true);
QCOMPARE(kpat.exitStatus(), QProcess::NormalExit);
QCOMPARE(kpat.exitCode(), 0);
}
QTEST_MAIN(TestSolver)
#include "freecell_solver.moc"
......@@ -126,6 +126,11 @@ SolverInterface::ExitStatus FcSolveSolver::patsolve( int _max_positions )
}
}
}
const long reached_iters = freecell_solver_user_get_num_times_long(solver_instance);
Q_ASSERT(reached_iters <= MAX_ITERS_LIMIT);
#if 0
fprintf(stderr, "iters = %ld\n", reached_iters);
#endif
switch (solver_ret)
{
......
......@@ -288,7 +288,11 @@ int FreecellSolver::get_possible_moves(int *a, int *numout)
static const char * freecell_solver_cmd_line_args[CMD_LINE_ARGS_NUM] =
{
#if 0
"--load-config", "video-editing"
#else
"--load-config", "slick-rock"
#endif
};
int FreecellSolver::get_cmd_line_arg_count()
......
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