Merge pull request #147 from grahamboree/unit_testing
Unit testing framework.
This commit is contained in:
commit
8563b84a8d
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,6 +11,7 @@
|
||||
|
||||
## Linux exes have no extension
|
||||
RecastDemo/Bin/RecastDemo
|
||||
RecastDemo/Bin/Tests
|
||||
|
||||
# Build directory
|
||||
RecastDemo/Build
|
||||
|
@ -42,3 +42,4 @@ before_script:
|
||||
# Run make in the directory containing generated makefiles, on the configuration specified by the environment variable.
|
||||
script:
|
||||
- make -C RecastDemo/Build/gmake config=$CONFIGURATION
|
||||
- RecastDemo/Bin/Tests
|
||||
|
@ -64,6 +64,12 @@ RecastDemo uses [premake5](http://premake.github.io/) to build platform specific
|
||||
- Run `"premake5" vs2015` from the `RecastDemo` folder
|
||||
- Open the solution, build, and run.
|
||||
|
||||
### Running Unit tests
|
||||
|
||||
- Follow the instructions to build RecastDemo above. Premake should generate another build target called "Tests".
|
||||
- Build the "Tests" project. This will generate an executable named "Tests" in `RecastDemo/Bin/`
|
||||
- Run the "Tests" executable. It will execute all the unit tests, indicate those that failed, and display a count of those that succeeded.
|
||||
|
||||
## Integrating with your own project
|
||||
|
||||
It is recommended to add the source directories `DebugUtils`, `Detour`, `DetourCrowd`, `DetourTileCache`, and `Recast` into your own project depending on which parts of the project you need. For example your level building tool could include DebugUtils, Recast, and Detour, and your game runtime could just include Detour.
|
||||
|
@ -213,7 +213,7 @@ int main(int /*argc*/, char** /*argv*/)
|
||||
showLevels = false;
|
||||
showSample = false;
|
||||
showTestCases = true;
|
||||
scanDirectory("Tests", ".txt", files);
|
||||
scanDirectory("TestCases", ".txt", files);
|
||||
}
|
||||
else if (event.key.keysym.sym == SDLK_TAB)
|
||||
{
|
||||
@ -802,7 +802,7 @@ int main(int /*argc*/, char** /*argv*/)
|
||||
if (testToLoad != -1)
|
||||
{
|
||||
char path[256];
|
||||
strcpy(path, "Tests/");
|
||||
strcpy(path, "TestCases/");
|
||||
strcat(path, files.files[testToLoad]);
|
||||
test = new TestCase;
|
||||
if (test)
|
||||
|
@ -172,3 +172,76 @@ project "RecastDemo"
|
||||
"Cocoa.framework",
|
||||
}
|
||||
|
||||
project "Tests"
|
||||
language "C++"
|
||||
kind "ConsoleApp"
|
||||
|
||||
-- Catch requires RTTI and exceptions
|
||||
exceptionhandling "On"
|
||||
rtti "On"
|
||||
|
||||
includedirs {
|
||||
"../DebugUtils/Include",
|
||||
"../Detour/Include",
|
||||
"../DetourCrowd/Include",
|
||||
"../DetourTileCache/Include",
|
||||
"../Recast/Include",
|
||||
"../Recast/Source",
|
||||
"../Tests/Recast",
|
||||
"../Tests",
|
||||
}
|
||||
files {
|
||||
"../Tests/*.h",
|
||||
"../Tests/*.hpp",
|
||||
"../Tests/*.cpp",
|
||||
"../Tests/Recast/*.h",
|
||||
"../Tests/Recast/*.cpp",
|
||||
}
|
||||
|
||||
-- project dependencies
|
||||
links {
|
||||
"DebugUtils",
|
||||
"Detour",
|
||||
"DetourCrowd",
|
||||
"DetourTileCache",
|
||||
"Recast",
|
||||
}
|
||||
|
||||
-- distribute executable in RecastDemo/Bin directory
|
||||
targetdir "Bin"
|
||||
|
||||
-- linux library cflags and libs
|
||||
configuration { "linux", "gmake" }
|
||||
buildoptions {
|
||||
"`pkg-config --cflags sdl2`",
|
||||
"`pkg-config --cflags gl`",
|
||||
"`pkg-config --cflags glu`"
|
||||
}
|
||||
linkoptions {
|
||||
"`pkg-config --libs sdl2`",
|
||||
"`pkg-config --libs gl`",
|
||||
"`pkg-config --libs glu`"
|
||||
}
|
||||
|
||||
-- windows library cflags and libs
|
||||
configuration { "windows" }
|
||||
includedirs { "../RecastDemo/Contrib/SDL/include" }
|
||||
libdirs { "../RecastDemo/Contrib/SDL/lib/x86" }
|
||||
debugdir "../RecastDemo/Bin/"
|
||||
links {
|
||||
"glu32",
|
||||
"opengl32",
|
||||
"SDL2",
|
||||
"SDL2main",
|
||||
}
|
||||
|
||||
-- mac includes and libs
|
||||
configuration { "macosx" }
|
||||
kind "ConsoleApp"
|
||||
includedirs { "/Library/Frameworks/SDL2.framework/Headers" }
|
||||
buildoptions { "-Wunused-value -Wshadow -Wreorder -Wsign-compare -Wall" }
|
||||
links {
|
||||
"OpenGL.framework",
|
||||
"SDL2.framework",
|
||||
"Cocoa.framework",
|
||||
}
|
||||
|
14
Tests/Recast/Tests_Recast.cpp
Normal file
14
Tests/Recast/Tests_Recast.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
#include "catch.hpp"
|
||||
|
||||
#include "Recast.h"
|
||||
|
||||
TEST_CASE("rcVdot")
|
||||
{
|
||||
SECTION("Dot normalized vector with itself")
|
||||
{
|
||||
float v1[] = { 1, 0, 0 };
|
||||
float result = rcVdot(v1, v1);
|
||||
REQUIRE(result == Approx(1));
|
||||
}
|
||||
}
|
||||
|
10203
Tests/catch.hpp
Normal file
10203
Tests/catch.hpp
Normal file
File diff suppressed because it is too large
Load Diff
2
Tests/main.cpp
Normal file
2
Tests/main.cpp
Normal file
@ -0,0 +1,2 @@
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include "catch.hpp"
|
@ -20,7 +20,7 @@ install:
|
||||
- ps: Start-FileDownload 'https://www.libsdl.org/release/SDL2-devel-2.0.4-VC.zip' 'RecastDemo/Contrib/SDL.zip'
|
||||
|
||||
# Extract it, put it in the right place, and rename it.
|
||||
- cd RecastDemo/Contrib && 7z x SDL.zip && ren SDL2-2.0.4 SDL && cd ../..
|
||||
- cd RecastDemo\Contrib && 7z x SDL.zip && ren SDL2-2.0.4 SDL && cd ..\..
|
||||
|
||||
# Generate solution files using premake.
|
||||
- cd RecastDemo && "../premake5.exe" %TOOLSET% && cd ..
|
||||
@ -31,3 +31,6 @@ configuration:
|
||||
|
||||
build:
|
||||
project: RecastDemo/Build/$(TOOLSET)/recastnavigation.sln
|
||||
|
||||
after_test:
|
||||
- RecastDemo\Bin\Tests.exe
|
||||
|
Loading…
x
Reference in New Issue
Block a user