Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Unittesting #60

Merged
merged 8 commits into from
Oct 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 29 additions & 28 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,30 @@ jobs:
name: "Linux-Qt5-amd64"
, os: ubuntu-18.04
, QT_VERSION: 5.15.2, QT_INST_DIR: /opt, QTDIR: /opt/Qt/5.15.2/gcc_64
, install_depends: "sudo apt-get update > /dev/null && sudo apt-get install -qqq doxygen > /dev/null"
, install_depends: "sudo apt-get update > /dev/null && sudo apt-get install -qqq doxygen graphviz > /dev/null"
, 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"
}
- {
name: "Linux-Qt6-amd64"
, os: ubuntu-latest
, QT_VERSION: 6.2.0, QT_INST_DIR: /opt, QTDIR: /opt/Qt/6.2.0/gcc_64, QT_MODULES: qt5compat
, install_depends: "sudo apt-get update > /dev/null && sudo apt-get install -qqq doxygen > /dev/null"
, install_depends: "sudo apt-get update > /dev/null && sudo apt-get install -qqq doxygen graphviz > /dev/null"
, 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"
}
- {
name: "MacOS-Qt5-amd64"
, os: macos-latest
, QT_VERSION: 5.15.2, QT_INST_DIR: /Users/runner, QTDIR: /Users/runner/Qt/5.15.2/clang_64
, install_depends: "brew install doxygen"
, install_depends: "brew install doxygen graphviz"
, extraCmakeConfig: "-DQT_DEFAULT_MAJOR_VERSION=5"
, packageName: ff7tk-continuous-Qt5-macos
, ff7tkInstallPrefix: ff7tk-continuous-Qt5-macos
Expand All @@ -53,7 +55,7 @@ jobs:
name: "MacOS-Qt6-amd64"
, os: macos-latest
, QT_VERSION: 6.2.0, QT_INST_DIR: /Users/runner, QTDIR: /Users/runner/Qt/6.2.0/clang_64, QT_MODULES: qt5compat
, install_depends: "brew install doxygen"
, install_depends: "brew install doxygen graphviz"
, extraCmakeConfig: "-DQT_DEFAULT_MAJOR_VERSION=6"
, packageName: ff7tk-continuous-Qt6-macos
, ff7tkInstallPrefix: ff7tk-continuous-Qt6-macos
Expand All @@ -63,7 +65,7 @@ jobs:
name: "Windows-Qt5-x64", WIN_ARCH: "x64"
, os: windows-latest
, QT_VERSION: 5.15.2, QT_INST_DIR: "C:/", QTDIR: "C:/Qt/5.15.2/msvc2019_64", QT_ARCH: win64_msvc2019_64
, install_depends: "choco install ninja doxygen.install"
, install_depends: "choco install ninja doxygen.install graphviz"
, extraCmakeConfig: "-DZLIB_ROOT=C:/zlib -G Ninja -DQT_DEFAULT_MAJOR_VERSION=5"
, packageName: "ff7tk-continuous-Qt5-win64"
, ff7tkInstallPrefix: ff7tk-continuous-Qt5-win64
Expand All @@ -73,7 +75,7 @@ jobs:
name: "Windows-Qt6-x64", WIN_ARCH: "x64"
, os: windows-latest
, QT_VERSION: 6.2.0, QT_INST_DIR: "C:/", QTDIR: "C:/Qt/6.2.0/msvc2019_64", QT_ARCH: win64_msvc2019_64, QT_MODULES: qt5compat
, install_depends: "choco install ninja doxygen.install"
, install_depends: "choco install ninja doxygen.install graphviz"
, extraCmakeConfig: "-DZLIB_ROOT=C:/zlib -G Ninja -DQT_DEFAULT_MAJOR_VERSION=6"
, packageName: "ff7tk-continuous-Qt6-win64"
, ff7tkInstallPrefix: ff7tk-continuous-Qt6-win64
Expand All @@ -83,7 +85,7 @@ jobs:
name: "Windows-Qt5-x86"
, os: windows-latest, WIN_ARCH: "amd64_x86"
, QT_VERSION: 5.15.2, QT_INST_DIR: "C:/", QTDIR: "C:/Qt/5.15.2/msvc2019", QT_ARCH: win32_msvc2019
, install_depends: "choco install ninja doxygen.install"
, install_depends: "choco install ninja doxygen.install graphviz"
, extraCmakeConfig: "-DZLIB_ROOT=C:/zlib -G Ninja -DQT_DEFAULT_MAJOR_VERSION=5"
, packageName: "ff7tk-continuous-Qt5-win32"
, ff7tkInstallPrefix: ff7tk-continuous-Qt5-win32
Expand All @@ -100,6 +102,14 @@ jobs:
path: ${{matrix.config.QT_INST_DIR}}/Qt
key: ${{ runner.os }}${{ matrix.config.WIN_ARCH }}-qt-${{ matrix.config.QT_VERSION }}

- name: Cache Zlib
id: cache-zlib
if: runner.os == 'Windows'
uses: actions/cache@v2
with:
path: C:/zlib
key: ${{ runner.os }}${{ matrix.config.WIN_ARCH }}-zlib

- name: Env Script (Windows)
uses: ilammy/msvc-dev-cmd@v1
if: runner.os == 'Windows'
Expand All @@ -119,20 +129,6 @@ jobs:
modules: ${{ matrix.config.QT_MODULES }}
cached: ${{ steps.cache-qt.outputs.cache-hit }}

- name: Cache Zlib
id: cache-zlib
if: runner.os == 'Windows'
uses: actions/cache@v2
with:
path: C:/zlib
key: ${{ runner.os }}${{ matrix.config.WIN_ARCH }}-zlib

- name: Env Script (Windows)
uses: ilammy/msvc-dev-cmd@v1
if: runner.os == 'Windows'
with:
arch: ${{ matrix.config.WIN_ARCH }}

- name: Install Zlib (Windows)
if: (runner.os == 'Windows') && (steps.cache-zlib.outputs.cache-hit != 'true')
run: |
Expand All @@ -147,6 +143,15 @@ 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: Prepare for Unittesting (windows)
if: runner.os == 'Windows'
run: copy "C:\zlib\bin\zlib.dll" D:\a\ff7tk\ff7tk\build\src\utils
sithlord48 marked this conversation as resolved.
Show resolved Hide resolved

- name: Run UnitTests
run: |
${{ matrix.config.ff7tkTestExport }}
ctest --test-dir build/unittests --output-on-failure

- name: Install(Linux)
if: runner.os == 'Linux'
run: |
Expand All @@ -165,16 +170,12 @@ jobs:
mv COPYING.TXT ${{matrix.config.packageName}}/
rm -rf ff7tk/usr/bin

- name: Setup linuxdeploy
if: runner.os == 'Linux'
run: |
wget -qc "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage"
wget -qc "https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage"
chmod a+x linuxdeploy*.AppImage

- name: Deployment (Linux)
if: runner.os == 'Linux'
run: |
wget -qc "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage"
wget -qc "https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage"
chmod a+x linuxdeploy*.AppImage
rm -rf ff7tk/usr/share/applications ff7tk/usr/share/pixmaps
export VERSION=continuous
${{matrix.config.linuxDeployQtPath}}
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
8 changes: 8 additions & 0 deletions lang/ff7tk_de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7662,6 +7662,14 @@ Die km / h beschleunigt berechnet werden während des Spielens </translation>
<source>Pause</source>
<translation>Pause</translation>
</message>
<message>
<source>Auto</source>
<translation>Auto</translation>
</message>
<message>
<source>Fixed</source>
<translation>Fest</translation>
</message>
</context>
<context>
<name>PhsListWidget</name>
Expand Down
8 changes: 8 additions & 0 deletions lang/ff7tk_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7667,6 +7667,14 @@ The km/h speeds are calculated while playing </translation>
<source>Pause</source>
<translation>Pause</translation>
</message>
<message>
<source>Auto</source>
<translation>Auto</translation>
</message>
<message>
<source>Fixed</source>
<translation>Fixed</translation>
</message>
</context>
<context>
<name>PhsListWidget</name>
Expand Down
8 changes: 8 additions & 0 deletions lang/ff7tk_es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7662,6 +7662,14 @@ Los km/h son calculados mientras se juega </translation>
<source>Pause</source>
<translation>Pausa</translation>
</message>
<message>
<source>Auto</source>
<translation>Auto</translation>
</message>
<message>
<source>Fixed</source>
<translation>Fijar</translation>
</message>
</context>
<context>
<name>PhsListWidget</name>
Expand Down
9 changes: 9 additions & 0 deletions lang/ff7tk_fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7662,6 +7662,15 @@ Les vitesses en km/h sont calculés pendant le jeu </translation>
<source>Pause</source>
<translation>Pause</translation>
</message>
<message>
<source>Auto</source>
<translatorcomment>Fixe</translatorcomment>
<translation type="unfinished">Auto</translation>
</message>
<message>
<source>Fixed</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PhsListWidget</name>
Expand Down
8 changes: 8 additions & 0 deletions lang/ff7tk_ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7662,6 +7662,14 @@ The km/h speeds are calculated while playing </source>
<source>Pause</source>
<translation>ポーズ</translation>
</message>
<message>
<source>Auto</source>
<translation>オート</translation>
</message>
<message>
<source>Fixed</source>
<translation>こてい</translation>
</message>
</context>
<context>
<name>PhsListWidget</name>
Expand Down
8 changes: 8 additions & 0 deletions lang/ff7tk_pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7646,6 +7646,14 @@ The km/h speeds are calculated while playing </source>
<source>Slow</source>
<translation>Wolny</translation>
</message>
<message>
<source>Auto</source>
<translation type="unfinished">Automatyczny</translation>
</message>
<message>
<source>Fixed</source>
<translation type="unfinished">Nieruchomy</translation>
</message>
</context>
<context>
<name>PhsListWidget</name>
Expand Down
8 changes: 8 additions & 0 deletions lang/ff7tk_re.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7662,6 +7662,14 @@ The km/h speeds are calculated while playing </translation>
<source>Custom Controller Mapping (PSX Only)</source>
<translation>Custom Controller Mapping (PSX Only)</translation>
</message>
<message>
<source>Auto</source>
<translation>Auto</translation>
</message>
<message>
<source>Fixed</source>
<translation>Fixed</translation>
</message>
</context>
<context>
<name>PhsListWidget</name>
Expand Down
2 changes: 1 addition & 1 deletion src/data/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ if(WIN32 AND CMAKE_COMPILER_IS_GNUCC)
#Prevent ms padding on packed structures on gcc compiler
add_compile_options(-mno-ms-bitfields)
elseif(APPLE)
add_compile_options(-stdlib-libc++)
target_compile_options(ff7tk PRIVATE -stdlib=libc++)
set_target_properties(ff7tk PROPERTIES
BUILD_WITH_INSTALL_RPATH TRUE
INSTALL_RPATH "@loader_path/../Frameworks @loader_path @executable_path @executable_path/../Frameworks"
Expand Down
46 changes: 19 additions & 27 deletions src/data/FF7Save.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,13 @@ FF7SaveInfo::FORMAT FF7Save::fileDataFormat(QFile &file)
auto file_size = file.size();
/*~~~~~~~~~~~~~~~~~~~~~~~~~~Set File Type Vars ~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
//decide the file type
if ((file_size == FF7SaveInfo::instance()->fileSize(FF7SaveInfo::FORMAT::PC)) && (file.peek(25).startsWith(FF7SaveInfo::instance()->fileIdentifier(FF7SaveInfo::FORMAT::PC))))
if ((file_size == FF7SaveInfo::instance()->fileSize(FF7SaveInfo::FORMAT::PC)) && (file.peek(25).startsWith(FF7SaveInfo::instance()->fileIdentifier(FF7SaveInfo::FORMAT::PC))) && file.fileName().endsWith(QStringLiteral("ff7")))
return FF7SaveInfo::FORMAT::PC;

if ((file_size == FF7SaveInfo::instance()->fileSize(FF7SaveInfo::FORMAT::SWITCH)) && (file.peek(25).startsWith(FF7SaveInfo::instance()->fileIdentifier(FF7SaveInfo::FORMAT::SWITCH))))
if ((file_size == FF7SaveInfo::instance()->fileSize(FF7SaveInfo::FORMAT::SWITCH)) && (file.peek(25).startsWith(FF7SaveInfo::instance()->fileIdentifier(FF7SaveInfo::FORMAT::SWITCH))) && file.fileName().startsWith(QStringLiteral("ff7")))
return FF7SaveInfo::FORMAT::SWITCH;
else if ((file_size == FF7SaveInfo::instance()->fileSize(FF7SaveInfo::FORMAT::VMC)) && (file.peek(25).startsWith(FF7SaveInfo::instance()->fileIdentifier(FF7SaveInfo::FORMAT::VMC))))
if ((file_size == FF7SaveInfo::instance()->fileSize(FF7SaveInfo::FORMAT::VMC)) && (file.peek(25).startsWith(FF7SaveInfo::instance()->fileIdentifier(FF7SaveInfo::FORMAT::VMC))))
return FF7SaveInfo::FORMAT::VMC;
else if (((FF7SaveInfo::instance()->fileSize(FF7SaveInfo::FORMAT::PS3) - FF7SaveInfo::instance()->fileHeaderSize(FF7SaveInfo::FORMAT::PS3)) % FF7SaveInfo::instance()->fileSize(FF7SaveInfo::FORMAT::PSX) == 0) && (file.peek(25)).startsWith(FF7SaveInfo::instance()->fileIdentifier(FF7SaveInfo::FORMAT::PS3)))
if (((FF7SaveInfo::instance()->fileSize(FF7SaveInfo::FORMAT::PS3) - FF7SaveInfo::instance()->fileHeaderSize(FF7SaveInfo::FORMAT::PS3)) % FF7SaveInfo::instance()->fileSize(FF7SaveInfo::FORMAT::PSX) == 0) && (file.peek(25)).startsWith(FF7SaveInfo::instance()->fileIdentifier(FF7SaveInfo::FORMAT::PS3)))
{
char psvType = file.peek(0x40).at(FF7SaveInfo::instance()->extraPSVOffsets(FF7SaveInfo::PSVINFO::SAVETYPE));
if (psvType == 0x14) {
Expand All @@ -68,20 +67,19 @@ FF7SaveInfo::FORMAT FF7Save::fileDataFormat(QFile &file)
return FF7SaveInfo::FORMAT::UNKNOWN;
}
}
else if ((file_size == FF7SaveInfo::instance()->fileSize(FF7SaveInfo::FORMAT::PSP)) && (file.peek(25)).startsWith(FF7SaveInfo::instance()->fileIdentifier(FF7SaveInfo::FORMAT::PSP)))
if ((file_size == FF7SaveInfo::instance()->fileSize(FF7SaveInfo::FORMAT::PSP)) && (file.peek(25)).startsWith(FF7SaveInfo::instance()->fileIdentifier(FF7SaveInfo::FORMAT::PSP)))
return FF7SaveInfo::FORMAT::PSP;
else if ((file_size == FF7SaveInfo::instance()->fileSize(FF7SaveInfo::FORMAT::VGS)) && (file.peek(25)).startsWith(FF7SaveInfo::instance()->fileIdentifier(FF7SaveInfo::FORMAT::VGS)))
if ((file_size == FF7SaveInfo::instance()->fileSize(FF7SaveInfo::FORMAT::VGS)) && (file.peek(25)).startsWith(FF7SaveInfo::instance()->fileIdentifier(FF7SaveInfo::FORMAT::VGS)))
return FF7SaveInfo::FORMAT::VGS;
else if ((file_size == FF7SaveInfo::instance()->fileSize(FF7SaveInfo::FORMAT::DEX)) && (file.peek(25)).startsWith(FF7SaveInfo::instance()->fileIdentifier(FF7SaveInfo::FORMAT::DEX)))
if ((file_size == FF7SaveInfo::instance()->fileSize(FF7SaveInfo::FORMAT::DEX)) && (file.peek(25)).startsWith(FF7SaveInfo::instance()->fileIdentifier(FF7SaveInfo::FORMAT::DEX)))
return FF7SaveInfo::FORMAT::DEX;
else if (file_size % FF7SaveInfo::instance()->fileSize(FF7SaveInfo::FORMAT::PSX) == 0)
if (file_size % FF7SaveInfo::instance()->fileSize(FF7SaveInfo::FORMAT::PSX) == 0)
return FF7SaveInfo::FORMAT::PSX;
else if ((file_size - FF7SaveInfo::instance()->fileHeaderSize(FF7SaveInfo::FORMAT::PGE)) % FF7SaveInfo::instance()->fileSize(FF7SaveInfo::FORMAT::PSX) == 0)
if ((file_size - FF7SaveInfo::instance()->fileHeaderSize(FF7SaveInfo::FORMAT::PGE)) % FF7SaveInfo::instance()->fileSize(FF7SaveInfo::FORMAT::PSX) == 0)
return FF7SaveInfo::FORMAT::PGE;
else if ((file_size - FF7SaveInfo::instance()->fileHeaderSize(FF7SaveInfo::FORMAT::PDA)) % FF7SaveInfo::instance()->fileSize(FF7SaveInfo::FORMAT::PSX) == 0)
if ((file_size - FF7SaveInfo::instance()->fileHeaderSize(FF7SaveInfo::FORMAT::PDA)) % FF7SaveInfo::instance()->fileSize(FF7SaveInfo::FORMAT::PSX) == 0)
return FF7SaveInfo::FORMAT::PDA;
else
return FF7SaveInfo::FORMAT::UNKNOWN;
return FF7SaveInfo::FORMAT::UNKNOWN;
}

bool FF7Save::loadFile(const QString &fileName)
Expand Down Expand Up @@ -419,7 +417,7 @@ bool FF7Save::exportVMCFormat(const QString &fileName, FF7SaveInfo::FORMAT expor

bool FF7Save::exportSlot(const QString &fileName, FF7SaveInfo::FORMAT exportFormat, int s)
{
if (fileName.isEmpty() || FF7SaveInfo::instance()->isTypeSSS(exportFormat))
if (fileName.isEmpty() || !FF7SaveInfo::instance()->isTypeSSS(exportFormat))
myst6re marked this conversation as resolved.
Show resolved Hide resolved
return false;

int blocks = psx_block_size(s);
Expand Down Expand Up @@ -1163,19 +1161,7 @@ QString FF7Save::psxDesc(int s)

void FF7Save::setPsxDesc(QString newDesc, int s)
{
newDesc = newDesc.normalized(QString::NormalizationForm_KD);
QByteArray temp = newDesc.toLatin1();
QByteArray newArray("\xFE\xFF", 2);
for( int i = 0; i < temp.size(); i++) {
quint16 newChar = 0x0000;
if(temp.at(i) == 0x00)
return;
newChar = (quint8(temp.at(i) - 0x20));
newArray.append('\xFF');
newArray.append(char(newChar));
}
newDesc = QString::fromUtf16(reinterpret_cast<ushort*>(newArray.data()),newArray.size() -1);
temp = QTextCodec::codecForName("Shift-JIS")->fromUnicode(newDesc);
QByteArray temp = QTextCodec::codecForName("Shift-JIS")->fromUnicode(newDesc);

QByteArray codedText;
codedText.fill('\x00', 64);
Expand Down Expand Up @@ -1262,6 +1248,12 @@ int FF7Save::lenSlotFooter(void)
{
return FF7SaveInfo::instance()->slotFooterSize(fileFormat); //Return slot footer length
}

int FF7Save::lenSlot()
{
return lenSlotHeader() + lenCoreSave() + lenSlotFooter();
}

int FF7Save::numberOfSlots(void)
{
return FF7SaveInfo::instance()->slotCount(fileFormat); //Return number of slots in the file_footer_dex
Expand Down
2 changes: 1 addition & 1 deletion src/data/FF7Save.h
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ class FF7TK_EXPORT FF7Save: public QObject
*/
inline int unknown_zmax()
{
return 46; //Number of "z" vars.
return 47; //Number of "z" vars.
}

/**
Expand Down
5 changes: 2 additions & 3 deletions src/data/FF7Text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ QByteArray FF7TEXT::toFF7(const QString &string)
for (i = 0 ; i <= 0xff ; ++i) {
if (!QString::compare(comp, character(quint8(i), 0))) {
ff7str.append(char(i));
goto end;
break;
}
}
if (d->in_ja) {
Expand All @@ -147,12 +147,11 @@ QByteArray FF7TEXT::toFF7(const QString &string)
case 6: ff7str.append('\xFE'); break;
}
ff7str.append(char(i));
goto end;
break;
}
}
}
}
end:;
}
return ff7str;
}
Expand Down
Loading