Expose private functions in grid_raytrace for unit testing.

This commit is contained in:
King_DuckZ 2017-02-09 19:31:38 +00:00
parent 47aa9f2948
commit 413ff4e558
4 changed files with 11 additions and 0 deletions

View file

@ -30,7 +30,9 @@
#include <algorithm>
namespace curry {
#if !defined(BUILD_TESTING)
namespace {
#endif
float inv_length (const vec2f& parVec) {
return 1.0f / std::sqrt(parVec.x() * parVec.x() + parVec.y() * parVec.y());
}
@ -77,7 +79,9 @@ namespace curry {
//else
//return INFINITY;
}
#if !defined(BUILD_TESTING)
} //unnamed namespace
#endif
//see:
//http://stackoverflow.com/questions/24679963/precise-subpixel-line-drawing-algorithm-rasterization-algorithm

View file

@ -20,12 +20,17 @@
#pragma once
#include "vector.hpp"
#include "mycurry_toplevelConfig.h"
#include <functional>
namespace curry {
class WorldGrid;
class TileProperty;
#if defined(BUILD_TESTING)
float segment_intersection (const vec2f& parA, const vec2f& parDirA, const vec2f& parB, const vec2f& parDirB);
#endif
struct WorldTileProperty {
vec2us index;
const TileProperty* property;

View file

@ -20,3 +20,4 @@
#pragma once
#define RESOURCES_PATH "@MYCURRY_RESOURCES_PATH@/"
#cmakedefine BUILD_TESTING

View file

@ -17,6 +17,7 @@ target_include_directories(${PROJECT_NAME}
PRIVATE ${CMAKE_SOURCE_DIR}/src/gamelib
PRIVATE ${CMAKE_SOURCE_DIR}/lib/vectorwrapper/include
PRIVATE ${CMAKE_SOURCE_DIR}/lib/tree-2.81/src
PRIVATE ${CMAKE_BINARY_DIR}
)
add_test(