-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-Tests are run by running the project with the `--runTests` arg -Test files are only compiled into debug builds -Added test workflow to run on PRs -Created new helper macro to not run functions in editor -Wrote a few simple tests for the CellSpawner class
- Loading branch information
Showing
15 changed files
with
166 additions
and
20 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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Unit Tests | ||
|
||
on: | ||
pull_request: | ||
types: [opened, edited, reopened, synchronize] | ||
|
||
jobs: | ||
ci: | ||
name: Run Unit Tests | ||
runs-on: ubuntu-latest | ||
container: | ||
image: barichello/godot-ci:4.2.1 | ||
|
||
steps: | ||
- name: Check out Git repository | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Set up Python (for SCons) | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install scons | ||
run: | | ||
python -m pip install scons==4.0.0 | ||
- name: Build module | ||
run: | | ||
cd godot-cpp | ||
scons platform=linux target=template_debug | ||
cd .. | ||
scons platform=linux target=template_debug disable_exceptions=no | ||
- name: Run tests | ||
run: | | ||
set -e | ||
godot --headless -T |
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 |
---|---|---|
|
@@ -5,5 +5,6 @@ bin/*.exp | |
bin/*.lib | ||
.sconsign.dblite | ||
src/*.obj | ||
tests/*.obj | ||
.vscode/ | ||
compile_commands.json |
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
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,10 @@ | ||
#pragma once | ||
|
||
#ifdef DEBUG_ENABLED | ||
#define DONT_RUN_IN_EDITOR \ | ||
if (Engine::get_singleton()->is_editor_hint()) { \ | ||
return; \ | ||
} | ||
#else | ||
#define DONT_RUN_IN_EDITOR | ||
#endif |
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,36 @@ | ||
#include "TestHeader.hpp" | ||
|
||
#include "cell_spawner.hpp" | ||
|
||
#include <godot_cpp/classes/Object.hpp> | ||
|
||
namespace godot { | ||
|
||
TEST_CASE("Dummy") { | ||
CHECK(1 == 1); | ||
} | ||
|
||
TEST_CASE("Test CellSpawner") { | ||
CellSpawner CellSpawner{}; | ||
|
||
REQUIRE(CellSpawner.getMinForce() == 50.0); | ||
REQUIRE(CellSpawner.getMaxForce() == 150.0); | ||
|
||
SUBCASE("Test setting min force") { | ||
CellSpawner.setMinForce(40.0); | ||
CHECK(CellSpawner.getMinForce() == 40.0); | ||
|
||
CellSpawner.setMinForce(CellSpawner.getMaxForce() + 1); | ||
CHECK(CellSpawner.getMinForce() == CellSpawner.getMaxForce()); | ||
} | ||
|
||
SUBCASE("Test setting max force") { | ||
CellSpawner.setMaxForce(160.0); | ||
CHECK(CellSpawner.getMaxForce() == 160.0); | ||
|
||
CellSpawner.setMaxForce(CellSpawner.getMinForce() - 1); | ||
CHECK(CellSpawner.getMaxForce() == CellSpawner.getMinForce()); | ||
} | ||
} | ||
|
||
} //namespace godot |
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,5 @@ | ||
#pragma once | ||
|
||
#include "doctest.h" | ||
|
||
int doctest_run(const int, const char *const *); |
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,15 @@ | ||
// Can only be used in one test file. Do not copy!! | ||
#define DOCTEST_CONFIG_IMPLEMENT | ||
|
||
#include "TestHeader.hpp" | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
int doctest_run(const int argc, const char *const *argv) { | ||
doctest::Context context; | ||
context.applyCommandLine(argc, argv); | ||
int res = context.run(); | ||
|
||
return res; | ||
} |