Commit 4aae2492 authored by Frederik Schwarzer's avatar Frederik Schwarzer

Litte unit testing is better than no unit testing.

parent 74c69ce1
......@@ -27,3 +27,5 @@ install(TARGETS kshisen ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES kshisen.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR})
install(FILES kshisenui.rc DESTINATION ${KDE_INSTALL_KXMLGUI5DIR}/kshisen)
add_subdirectory(tests)
enable_testing()
#set(CMAKE_AUTOMOC ON)
#set(CMAKE_INCLUDE_CURRENT_DIR ON)
find_package(Qt5Test REQUIRED)
add_executable(movetest movetest.cpp ../move.cpp)
add_test(movetest movetest)
target_link_libraries(movetest Qt5::Test)
#include "movetest.h"
void MoveTest::initTestCase()
{
qDebug("called before everything else");
m_tile1 = KShisen::TilePos(1, 2);
m_tile2 = KShisen::TilePos(3, 4);
}
void MoveTest::swap()
{
auto move = KShisen::Move(m_tile1, m_tile2, 12, 34);
move.swapTiles();
QCOMPARE(move.tile1(), 34);
QCOMPARE(move.tile2(), 12);
}
void MoveTest::cleanupTestCase()
{
qDebug("called after myFirstTest and mySecondTest");
}
QTEST_MAIN(MoveTest)
#include "movetest.moc"
#include <QtTest>
#include "../move.h"
#include "../types.h"
class MoveTest: public QObject
{
Q_OBJECT
private slots:
void initTestCase();
void swap();
void cleanupTestCase();
private:
KShisen::TilePos m_tile1;
KShisen::TilePos m_tile2;
};
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