-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from TheIndra55/tests
Add tests
- Loading branch information
Showing
10 changed files
with
155 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,36 @@ name: Build | |
on: [push, pull_request] | ||
|
||
jobs: | ||
test: | ||
runs-on: windows-latest | ||
|
||
steps: | ||
# setup | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
|
||
- uses: microsoft/[email protected] | ||
- uses: ilammy/msvc-dev-cmd@v1 | ||
|
||
- name: Download premake5 | ||
run: | | ||
curl.exe -o premake5.zip -L https://github.com/premake/premake-core/releases/download/v5.0.0-beta2/premake-5.0.0-beta2-windows.zip | ||
tar -xf premake5.zip | ||
- name: Generate project files | ||
run: .\premake5 vs2022 --with-tests | ||
|
||
# tests | ||
- name: Build tests | ||
run: MSBuild TRAE-menu-hook.sln /t:Tests /p:Configuration=Release /p:Platform=TR7 | ||
|
||
- name: Test | ||
run: .\bin\TR7\Release\Tests.exe | ||
|
||
build: | ||
runs-on: windows-latest | ||
needs: test | ||
|
||
steps: | ||
# setup | ||
|
@@ -29,16 +57,23 @@ jobs: | |
run: .\premake5 vs2022 | ||
|
||
# compile | ||
- name: Build Legend | ||
run: MSBuild /p:Configuration=Release /p:Platform=TR7 | ||
|
||
- name: Build Anniversary | ||
run: MSBuild /p:Configuration=Release /p:Platform=TRAE | ||
|
||
- name: Build Underworld | ||
run: MSBuild /p:Configuration=Release /p:Platform=TR8 | ||
|
||
- name: Build Legend | ||
run: MSBuild /p:Configuration=Release /p:Platform=TR7 | ||
|
||
# upload | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: Legend | ||
path: | | ||
bin/TR7/Release/TR7-Menu-Hook.asi | ||
bin/TR7/Release/TR7-Menu-Hook.pdb | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: Anniversary | ||
|
@@ -52,10 +87,3 @@ jobs: | |
path: | | ||
bin/TR8/Release/TR8-Menu-Hook.asi | ||
bin/TR8/Release/TR8-Menu-Hook.pdb | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: Legend | ||
path: | | ||
bin/TR7/Release/TR7-Menu-Hook.asi | ||
bin/TR7/Release/TR7-Menu-Hook.pdb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include <catch_amalgamated.hpp> | ||
|
||
#include "util/Helpers.h" | ||
|
||
TEST_CASE("can convert string to int") | ||
{ | ||
SECTION("read numbers") | ||
{ | ||
auto value = Helpers::StringToInt("1024"); | ||
|
||
REQUIRE(value == 1024); | ||
} | ||
|
||
SECTION("read units") | ||
{ | ||
auto value1 = Helpers::StringToInt("256K"); | ||
auto value2 = Helpers::StringToInt("256M"); | ||
|
||
REQUIRE(value1 == 0x40000); | ||
REQUIRE(value2 == 0x10000000); | ||
} | ||
|
||
SECTION("returns a default") | ||
{ | ||
auto value = Helpers::StringToInt("lara", 42); | ||
|
||
REQUIRE(value == 42); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include <catch_amalgamated.hpp> | ||
|
||
#include "Hook.h" | ||
|
||
class TestModule : public Module | ||
{ | ||
public: | ||
int GetValue() const noexcept { return 42; } | ||
}; | ||
|
||
TEST_CASE("can register and get modules") | ||
{ | ||
auto& hook = Hook::GetInstance(); | ||
hook.RegisterModule<TestModule>(); | ||
|
||
auto test = hook.GetModule<TestModule>(); | ||
|
||
REQUIRE_FALSE(test == nullptr); | ||
|
||
auto value = test->GetValue(); | ||
|
||
REQUIRE(value == 42); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
files { | ||
"vendor/minhook/src/**", | ||
"vendor/patterns/*.cpp", | ||
"vendor/imgui/*.cpp", | ||
"vendor/imgui/backends/imgui_impl_win32.cpp", | ||
"vendor/imgui/backends/imgui_impl_dx9.cpp" | ||
} | ||
|
||
includedirs { | ||
"vendor/minhook/include", | ||
"vendor/patterns", | ||
"vendor/imgui", | ||
"vendor/imgui/backends" | ||
} |