Skip to content

Commit

Permalink
Enable Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sithlord48 committed Oct 17, 2021
1 parent 59b4650 commit c50ccd6
Show file tree
Hide file tree
Showing 8 changed files with 585 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
, extraCmakeConfig: "-DQT_DEFAULT_MAJOR_VERSION=5"
, packageName: ff7tk-continuous-Qt5-linux
, ff7tkInstallPrefix: /usr
, ff7tkTestExport: "export QT_QPA_PLATFORM=minimal"
, releasePackage: "ff7tk-continuous-Qt5-linux.tar.xz"
}
- {
Expand All @@ -36,6 +37,7 @@ jobs:
, extraCmakeConfig: "-DQT_DEFAULT_MAJOR_VERSION=6"
, packageName: ff7tk-continuous-Qt6-linux
, ff7tkInstallPrefix: /usr
, ff7tkTestExport: "export QT_QPA_PLATFORM=minimal"
, linuxDeployQtPath: "export PATH=$PATH:/opt/Qt/6.2.0/gcc_64/libexec"
, releasePackage: "ff7tk-continuous-Qt6-linux.tar.xz"
}
Expand Down Expand Up @@ -147,6 +149,11 @@ jobs:
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INSTALL_PREFIX=${{matrix.config.ff7tkInstallPrefix}} -DWIDGET_GALLERY=ON -DQML_GALLERY=ON -DDOCS=ON ${{matrix.config.extraCmakeConfig}}
cmake --build build --config ${{env.BUILD_TYPE}} -j8
- name: RunUnit Tests
run: |
${{ matrix.config.ff7tkTestExport}}
ctest --test-dir build/unittests --repeat until-pass:5 --output-on-failure
- name: Install(Linux)
if: runner.os == 'Linux'
run: |
Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
option(WIDGET_GALLERY "Build the widget based gallery" OFF)
option(QML_GALLERY "Build the qml based gallery" OFF)
option(DOCS "Build and Install Documents (Requires Doxygen)" OFF)
option(ENABLE_TESTING "Build and run UnitTests" ON)


add_subdirectory(src)
add_subdirectory(lang)
Expand All @@ -68,6 +70,10 @@ if(DOCS)
add_subdirectory(docs)
endif()

if(ENABLE_TESTING)
add_subdirectory(unittests)
endif()

#pkgconfig

configure_file(ff7tk.pc.in ff7tk.pc @ONLY)
Expand Down
14 changes: 14 additions & 0 deletions unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
enable_testing()

find_package(Qt${QT_DEFAULT_MAJOR_VERSION} REQUIRED NO_MODULE COMPONENTS
Test
)

function (MAKE_TEST NAME FILE LIB)
add_executable( ${NAME} ${FILE} )
target_link_libraries( ${NAME} ${LIB} Qt::Test)
add_test(NAME ${NAME} COMMAND $<TARGET_FILE:${NAME}>)
set_tests_properties(${NAME} PROPERTIES DEPENDS ${LIB})
endfunction()

add_subdirectory(data)
2 changes: 2 additions & 0 deletions unittests/data/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
MAKE_TEST(FF7Text_Tests FF7Text_test.cpp ff7tk)
MAKE_TEST(FF7Save_Tests FF7Save_test.cpp ff7tk)
31 changes: 31 additions & 0 deletions unittests/data/FF7Save_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <QtTest>

#include "FF7Save_test.h"

void FF7SaveTests::initTestCase()
{
ff7save = new FF7Save();
}

void FF7SaveTests::test_setSlotPsxRawData()
{
ff7save->setFormat(FF7SaveInfo::FORMAT::PSX);
ff7save->newGame(0);
QVERIFY(ff7save->setSlotPsxRawData(0, _slotData));
}

void FF7SaveTests::test_readPsxDesc()
{
QString desc = QStringLiteral("FF7/SAVE15/99:28");
ff7save->setPsxDesc(desc, 0);
QCOMPARE(ff7save->psxDesc(0), desc);
}

void FF7SaveTests::test_writePsxDesc()
{
QString desc = QStringLiteral("VVVVVVVVVVVVVVVV");
ff7save->setPsxDesc(desc, 0);
QCOMPARE(ff7save->psxDesc(0), desc);
}

QTEST_MAIN(FF7SaveTests)
16 changes: 16 additions & 0 deletions unittests/data/FF7Save_test.h

Large diffs are not rendered by default.

273 changes: 273 additions & 0 deletions unittests/data/FF7Text_test.cpp

Large diffs are not rendered by default.

236 changes: 236 additions & 0 deletions unittests/data/FF7Text_test.h

Large diffs are not rendered by default.

0 comments on commit c50ccd6

Please sign in to comment.