diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d381c729..d176bd8c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,10 +16,20 @@ include(Source/CMake/Properties.cmake) include(Source/CMake/FindPackageOrBuild.cmake) include(Source/CMake/HelperMethods.cmake) + +set(BUILD_TESTS OFF CACHE BOOL "If true, build targets for running unit tests will be included in the output.") +if (BUILD_TESTS) + # Enables testing for this directory and below. See also the add_test + # command. Note that ctest expects to find a test file in the build + # directory root. Therefore, this command should be in the source + # directory root. + enable_testing() +endif() + add_subdirectory(Source) # Options set(SCRIPT_API "None" CACHE STRING "Which scripting API/language to use, if any. If no scripting API is chosen only native C++ bsf core will be built. If a scripting API is chosen, then a separate scripting layer on top of the core will be included in the build as well.") set_property(CACHE SCRIPT_API PROPERTY STRINGS "None" "C#") -set(SCRIPT_BINDING_GENERATION OFF CACHE BOOL "If true, script binding generation will be supported through a specialized build target. Enable this if you plan on modifying the scripting API. Requires the SBGen tool dependency. Only relevant if you have selected a SCRIPT_API other than \"None\".") \ No newline at end of file +set(SCRIPT_BINDING_GENERATION OFF CACHE BOOL "If true, script binding generation will be supported through a specialized build target. Enable this if you plan on modifying the scripting API. Requires the SBGen tool dependency. Only relevant if you have selected a SCRIPT_API other than \"None\".") diff --git a/Source/CMake/HelperMethods.cmake b/Source/CMake/HelperMethods.cmake index 662b7b5c9..f56b951ec 100644 --- a/Source/CMake/HelperMethods.cmake +++ b/Source/CMake/HelperMethods.cmake @@ -192,6 +192,38 @@ MACRO(end_find_package FOLDER_NAME MAIN_LIB_NAME) set(${FOLDER_NAME}_INCLUDE_DIRS ${${FOLDER_NAME}_INCLUDE_DIR}) ENDMACRO() +# the purpose of bs_add_test is to allow for the local library path to be found by the tester. +# It's necessary to pass the environment variables because ctest will usually run with a clean environment. +# It was implemented to work for linux, as of July 2019 not tested on windows. +MACRO(bs_add_test) + cmake_parse_arguments( + PARSED_ARGS # prefix of output variables + "" # list of names of the boolean arguments (only defined ones will be true) + "NAME" # list of names of mono-valued arguments + "" # multivalue args + ${ARGN} # arguments of the function to parse, here we take the all original ones + ) + + add_test(${ARGV}) + + if(NOT PARSED_ARGS_NAME) + message(FATAL_ERROR "You must provide a name for bs_add_test (bs_add_test(NAME name)") + endif(NOT PARSED_ARGS_NAME) + + IF(CMAKE_BUILD_TYPE MATCHES Debug) + # windows + set_tests_properties( ${PARSED_ARGS_NAME} PROPERTIES ENVIRONMENT "PATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG};$ENV{PATH}" ) + # linux + set_tests_properties( ${PARSED_ARGS_NAME} PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG};" ) + elseif (CMAKE_BUILD_TYPE MATCHES Release) + # windows + set_tests_properties( ${PARSED_ARGS_NAME} PROPERTIES ENVIRONMENT "PATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE};$ENV{PATH}" ) + # linux + set_tests_properties( ${PARSED_ARGS_NAME} PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE};" ) + endif() + +ENDMACRO() + function(install_dependency_binary FILE_PATH CONFIG) if(NOT EXISTS ${FILE_PATH}) return() diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 4a85efb9d..a6ce41afc 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -31,8 +31,6 @@ set_property(CACHE RENDERER_MODULE PROPERTY STRINGS RenderBeast Null) set(INCLUDE_ALL_IN_WORKFLOW OFF CACHE BOOL "If true, all libraries (even those not selected) will be included in the generated workflow (e.g. Visual Studio solution). This is useful when working on engine internals with a need for easy access to all parts of it. Only relevant for workflow generators like Visual Studio or XCode.") -set(BUILD_TESTS OFF CACHE BOOL "If true, build targets for running unit tests will be included in the output.") - set(BUILD_BSL OFF CACHE BOOL "If true, build lexer & parser for BSL. Requires flex & bison dependencies.") set(BUILD_ALL_RENDER_API OFF CACHE BOOL "If true, all supported render backends will be built, regardless of choice in RENDER_API_MODULE. Choice in RENDER_API_MODULE will still be used as the default.") @@ -208,8 +206,6 @@ add_subdirectory(Plugins/bsfSL) ## Tests if(BUILD_TESTS) - enable_testing() - add_executable(UtilityTest Foundation/bsfUtility/Private/UnitTests/BsUtilityTest.cpp Foundation/bsfUtility/Private/UnitTests/BsUtilityTestSuite.cpp @@ -228,8 +224,8 @@ if(BUILD_TESTS) set_property(TARGET UtilityTest PROPERTY FOLDER Tests) set_property(TARGET CoreTest PROPERTY FOLDER Tests) - add_test(NAME UtilityTests COMMAND $) - add_test(NAME CoreTests COMMAND $) + bs_add_test(NAME UtilityTests COMMAND $) + bs_add_test(NAME CoreTests COMMAND $) endif() ## Builtin resource preprocessing diff --git a/Source/Foundation/CMakeLists.txt b/Source/Foundation/CMakeLists.txt index 03ae58aa1..bd1a368d2 100644 --- a/Source/Foundation/CMakeLists.txt +++ b/Source/Foundation/CMakeLists.txt @@ -82,6 +82,7 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "A elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") target_compile_options(bsf PUBLIC -fno-exceptions + -msse4.1 $<$:-fno-rtti>) else() # TODO_OTHER_COMPILERS_GO_HERE diff --git a/Source/Foundation/bsfCore/Private/UnitTests/BsCoreTest.cpp b/Source/Foundation/bsfCore/Private/UnitTests/BsCoreTest.cpp index 180a86516..7b4ccfcd2 100644 --- a/Source/Foundation/bsfCore/Private/UnitTests/BsCoreTest.cpp +++ b/Source/Foundation/bsfCore/Private/UnitTests/BsCoreTest.cpp @@ -35,7 +35,7 @@ namespace bs void CoreTestSuite::testAnimCurveIntegration() { - static constexpr float EPSILON = 0.0001f; + static constexpr float EPSILON = 0.001f; // Construct some curves TAnimationCurve curveConstant( @@ -113,7 +113,7 @@ namespace bs void CoreTestSuite::testLookupTable() { - static constexpr float EPSILON = 0.0001f; + static constexpr float EPSILON = 0.001f; TAnimationCurve curve ({ @@ -155,4 +155,4 @@ int main() tests->run(testOutput); return 0; -} \ No newline at end of file +} diff --git a/Source/Foundation/bsfUtility/CMakeSources.cmake b/Source/Foundation/bsfUtility/CMakeSources.cmake index c833d3cad..1d9633b17 100644 --- a/Source/Foundation/bsfUtility/CMakeSources.cmake +++ b/Source/Foundation/bsfUtility/CMakeSources.cmake @@ -41,6 +41,7 @@ set(BS_UTILITY_SRC_IMAGE ) set(BS_UTILITY_SRC_UTILITY + "bsfUtility/Utility/BsBitStream.cpp" "bsfUtility/Utility/BsDynLib.cpp" "bsfUtility/Utility/BsDynLibManager.cpp" "bsfUtility/Utility/BsMessageHandler.cpp" diff --git a/Source/Foundation/bsfUtility/Private/UnitTests/BsFileSystemTestSuite.cpp b/Source/Foundation/bsfUtility/Private/UnitTests/BsFileSystemTestSuite.cpp index d0367e8f4..e3bd74cef 100644 --- a/Source/Foundation/bsfUtility/Private/UnitTests/BsFileSystemTestSuite.cpp +++ b/Source/Foundation/bsfUtility/Private/UnitTests/BsFileSystemTestSuite.cpp @@ -57,7 +57,7 @@ namespace bs FileSystem::remove(mTestDirectory, true); if (FileSystem::exists(mTestDirectory)) { - LOGERR("FileSystemTestSuite failed to delete '" + mTestDirectory.toString() + BS_LOG(Error, FileSystem, "FileSystemTestSuite failed to delete '" + mTestDirectory.toString() + "', you should remove it manually."); } } diff --git a/Source/Foundation/bsfUtility/Private/UnitTests/BsUtilityTest.cpp b/Source/Foundation/bsfUtility/Private/UnitTests/BsUtilityTest.cpp index 0959378c9..75017d43e 100644 --- a/Source/Foundation/bsfUtility/Private/UnitTests/BsUtilityTest.cpp +++ b/Source/Foundation/bsfUtility/Private/UnitTests/BsUtilityTest.cpp @@ -3,14 +3,48 @@ #include "Testing/BsConsoleTestOutput.h" #include "Private/UnitTests/BsUtilityTestSuite.h" +#include "BsApplication.h" +#include "BsEngineConfig.h" + using namespace bs; + +START_UP_DESC testStartupDesc() +{ + START_UP_DESC desc; + + // Set up default plugins + desc.renderAPI = BS_RENDER_API_MODULE; + // desc.renderAPI = "NullRenderAPI" + desc.renderer = BS_RENDERER_MODULE; + // desc.renderer = "NullRenderer"; + desc.audio = BS_AUDIO_MODULE; + desc.physics = BS_PHYSICS_MODULE; + + desc.importers.push_back("bsfFreeImgImporter"); + desc.importers.push_back("bsfFBXImporter"); + desc.importers.push_back("bsfFontImporter"); + desc.importers.push_back("bsfSL"); + + VideoMode mode; + desc.primaryWindowDesc.videoMode = mode; + desc.primaryWindowDesc.fullscreen = false; + desc.primaryWindowDesc.title = "test"; + return desc; +} + int main() { + + auto desc = testStartupDesc(); + bs::Application::startUp(desc); + SPtr tests = UtilityTestSuite::create(); ConsoleTestOutput testOutput; tests->run(testOutput); + bs::Application::shutDown(); + return 0; -} \ No newline at end of file +} diff --git a/Source/Foundation/bsfUtility/Private/UnitTests/BsUtilityTestSuite.cpp b/Source/Foundation/bsfUtility/Private/UnitTests/BsUtilityTestSuite.cpp index b3191dee9..54e913529 100644 --- a/Source/Foundation/bsfUtility/Private/UnitTests/BsUtilityTestSuite.cpp +++ b/Source/Foundation/bsfUtility/Private/UnitTests/BsUtilityTestSuite.cpp @@ -466,85 +466,90 @@ namespace bs BS_TEST_ASSERT(v3[3].a == 10); BS_TEST_ASSERT(v3[3].b == 0); } + + bool approxNear(float a, float b, float EPS = 0.001f) { + bool result = std::abs(a - b) < EPS; + return result; + } void UtilityTestSuite::testComplex() { Complex c(10.0, 4.0); - BS_TEST_ASSERT(c.real() == 10.0); - BS_TEST_ASSERT(c.imag() == 4.0); + BS_TEST_ASSERT(approxNear(c.real(), 10.0)); + BS_TEST_ASSERT(approxNear(c.imag(), 4.0)); Complex c2(15.0, 5.0); - BS_TEST_ASSERT(c2.real() == 15.0); - BS_TEST_ASSERT(c2.imag() == 5.0); + BS_TEST_ASSERT(approxNear(c2.real(), 15.0)); + BS_TEST_ASSERT(approxNear(c2.imag(), 5.0)); Complex c3 = c + c2; - BS_TEST_ASSERT(c3.real() == 25.0); - BS_TEST_ASSERT(c3.imag() == 9.0); + BS_TEST_ASSERT(approxNear(c3.real(), 25.0)); + BS_TEST_ASSERT(approxNear(c3.imag(), 9.0)); Complex c4 = c - c2; - BS_TEST_ASSERT(c4.real() == -5.0); - BS_TEST_ASSERT(c4.imag() == -1.0); + BS_TEST_ASSERT(approxNear(c4.real(), -5.0)); + BS_TEST_ASSERT(approxNear(c4.imag(), -1.0)); Complex c5 = c * c2; - BS_TEST_ASSERT(c5.real() == 130.0); - BS_TEST_ASSERT(c5.imag() == 110.0); + BS_TEST_ASSERT(approxNear(c5.real(), 130.0)); + BS_TEST_ASSERT(approxNear(c5.imag(), 110.0)); Complex c6 = c / c2; - BS_TEST_ASSERT(c6.real() == 0.680000007f); - BS_TEST_ASSERT(c6.imag() == 0.0399999991f); + BS_TEST_ASSERT(approxNear(c6.real(), 0.680000007f)); + BS_TEST_ASSERT(approxNear(c6.imag(), 0.0399999991f)); - BS_TEST_ASSERT(Complex::abs(c) == 10.7703295f); - BS_TEST_ASSERT(Complex::arg(c) == 0.380506366f); - BS_TEST_ASSERT(Complex::norm(c) == 116); + BS_TEST_ASSERT(approxNear(Complex::abs(c), 10.7703295f)); + BS_TEST_ASSERT(approxNear(Complex::arg(c), 0.380506366f)); + BS_TEST_ASSERT(approxNear(Complex::norm(c), 116)); Complex c7 = Complex::conj(c); - BS_TEST_ASSERT(c7.real() == 10); - BS_TEST_ASSERT(c7.imag() == -4); + BS_TEST_ASSERT(approxNear(c7.real(), 10)); + BS_TEST_ASSERT(approxNear(c7.imag(), -4)); c7 = 0; c7 = Complex::polar(2.0, 0.5); - BS_TEST_ASSERT(c7.real() == 1.75516510f); - BS_TEST_ASSERT(c7.imag() == 0.958851099f); + BS_TEST_ASSERT(approxNear(c7.real(), 1.75516510f)); + BS_TEST_ASSERT(approxNear(c7.imag(), 0.958851099f)); c7 = 0; c7 = Complex::cos(c); - BS_TEST_ASSERT(c7.real() == -22.9135609f); - BS_TEST_ASSERT(c7.imag() == 14.8462915f); + BS_TEST_ASSERT(approxNear(c7.real(), -22.9135609f)); + BS_TEST_ASSERT(approxNear(c7.imag(), 14.8462915f)); c7 = 0; c7 = Complex::cosh(c); - BS_TEST_ASSERT(c7.real() == -7198.72949f); - BS_TEST_ASSERT(c7.imag() == -8334.84180f); + BS_TEST_ASSERT(approxNear(c7.real(), -7198.72949f)); + BS_TEST_ASSERT(approxNear(c7.imag(), -8334.84180f)); c7 = 0; c7 = Complex::exp(c); - BS_TEST_ASSERT(c7.real() == -14397.4580f); - BS_TEST_ASSERT(c7.imag() == -16669.6836f); + BS_TEST_ASSERT(approxNear(c7.real(), -14397.4580f)); + BS_TEST_ASSERT(approxNear(c7.imag(), -16669.6836f)); c7 = 0; c7 = Complex::log(c); - BS_TEST_ASSERT(c7.real() == 2.37679505f); - BS_TEST_ASSERT(c7.imag() == 0.380506366f); + BS_TEST_ASSERT(approxNear(c7.real(), 2.37679505f)); + BS_TEST_ASSERT(approxNear(c7.imag(), 0.380506366f)); c7 = 0; c7 = Complex::pow(c, 2.0); - BS_TEST_ASSERT(c7.real() == 84.0000000f); - BS_TEST_ASSERT(c7.imag() == 79.9999924f); + BS_TEST_ASSERT(approxNear(c7.real(), 84.0000000f)); + BS_TEST_ASSERT(approxNear(c7.imag(), 79.9999924f)); c7 = 0; c7 = Complex::sin(c); - BS_TEST_ASSERT(c7.real() == -14.8562555f); - BS_TEST_ASSERT(c7.imag() == -22.8981915f); + BS_TEST_ASSERT(approxNear(c7.real(), -14.8562555f)); + BS_TEST_ASSERT(approxNear(c7.imag(), -22.8981915f)); c7 = 0; c7 = Complex::sinh(c); - BS_TEST_ASSERT(c7.real() == -7198.72900f); - BS_TEST_ASSERT(c7.imag() == -8334.84277f); + BS_TEST_ASSERT(approxNear(c7.real(), -7198.72900f)); + BS_TEST_ASSERT(approxNear(c7.imag(), -8334.84277f)); c7 = 0; c7 = Complex::sqrt(c); - BS_TEST_ASSERT(c7.real() == 3.22260213f); - BS_TEST_ASSERT(c7.imag() == 0.620616496f); + BS_TEST_ASSERT(approxNear(c7.real(), 3.22260213f)); + BS_TEST_ASSERT(approxNear(c7.imag(), 0.620616496f)); c7 = 0; } diff --git a/Source/Foundation/bsfUtility/Testing/BsTestSuite.cpp b/Source/Foundation/bsfUtility/Testing/BsTestSuite.cpp index 03516634d..1bfe7a606 100644 --- a/Source/Foundation/bsfUtility/Testing/BsTestSuite.cpp +++ b/Source/Foundation/bsfUtility/Testing/BsTestSuite.cpp @@ -18,7 +18,7 @@ namespace bs for (auto& testEntry : mTests) { mActiveTestName = testEntry.name; - + std::cout << mActiveTestName << std::endl; (this->*(testEntry.test))(); } diff --git a/Source/Foundation/bsfUtility/Utility/BsBitStream.cpp b/Source/Foundation/bsfUtility/Utility/BsBitStream.cpp new file mode 100644 index 000000000..61da4c48f --- /dev/null +++ b/Source/Foundation/bsfUtility/Utility/BsBitStream.cpp @@ -0,0 +1,8 @@ +#include "./BsBitstream.h" + +namespace bs +{ + uint32_t Bitstream::BYTES_PER_QUANT = sizeof(QuantType); + uint32_t Bitstream::BITS_PER_QUANT = BYTES_PER_QUANT * 8; + uint32_t Bitstream::BITS_PER_QUANT_LOG2 = Bitwise::bitsLog2(BITS_PER_QUANT); +} // namespace bs diff --git a/Source/Foundation/bsfUtility/Utility/BsBitstream.h b/Source/Foundation/bsfUtility/Utility/BsBitstream.h index 342b2c462..fd61a751f 100644 --- a/Source/Foundation/bsfUtility/Utility/BsBitstream.h +++ b/Source/Foundation/bsfUtility/Utility/BsBitstream.h @@ -327,9 +327,9 @@ namespace bs QuantType* data() const { return mData; } private: - static constexpr uint32_t BYTES_PER_QUANT = sizeof(QuantType); - static constexpr uint32_t BITS_PER_QUANT = BYTES_PER_QUANT * 8; - static constexpr uint32_t BITS_PER_QUANT_LOG2 = Bitwise::bitsLog2(BITS_PER_QUANT); + static uint32_t BYTES_PER_QUANT; + static uint32_t BITS_PER_QUANT; + static uint32_t BITS_PER_QUANT_LOG2; /** Checks if the internal memory buffer needs to grow in order to accomodate @p numBits bits. */ void reallocIfNeeded(uint32_t numBits); diff --git a/Source/Foundation/bsfUtility/Utility/BsOctree.h b/Source/Foundation/bsfUtility/Utility/BsOctree.h index bf78fec14..f5bba1c2f 100644 --- a/Source/Foundation/bsfUtility/Utility/BsOctree.h +++ b/Source/Foundation/bsfUtility/Utility/BsOctree.h @@ -380,16 +380,16 @@ namespace bs public: /** Initializes the iterator, starting with the root octree node. */ NodeIterator(const Octree& tree) - :mCurrentNode(HNode(&tree.mRoot, tree.mRootBounds)), mStackAlloc(), mNodeStack(&mStackAlloc) + :mCurrentNode(HNode(&tree.mRoot, tree.mRootBounds)) { - mNodeStack.push_back(mCurrentNode); + mNodeStack.add(mCurrentNode); } /** Initializes the iterator using a specific node and its bounds. */ NodeIterator(const Node* node, const NodeBounds& bounds) - :mCurrentNode(HNode(node, bounds)), mStackAlloc(), mNodeStack(&mStackAlloc) + :mCurrentNode(HNode(node, bounds)) { - mNodeStack.push_back(mCurrentNode); + mNodeStack.add(mCurrentNode); } /** @@ -423,13 +423,12 @@ namespace bs Node* childNode = mCurrentNode.getNode()->getChild(child); NodeBounds childBounds = mCurrentNode.getBounds().getChild(child); - mNodeStack.emplace_back(childNode, childBounds); + mNodeStack.add({childNode, childBounds}); } private: HNode mCurrentNode; - StaticAlloc mStackAlloc; - StaticVector mNodeStack; + SmallVector mNodeStack; }; /** Iterator that iterates over all elements in a single node. */ diff --git a/Source/Foundation/bsfUtility/Utility/BsQuadtree.h b/Source/Foundation/bsfUtility/Utility/BsQuadtree.h index ecb667397..823e803ca 100644 --- a/Source/Foundation/bsfUtility/Utility/BsQuadtree.h +++ b/Source/Foundation/bsfUtility/Utility/BsQuadtree.h @@ -372,16 +372,16 @@ namespace bs public: /** Initializes the iterator, starting with the root quadtree node. */ NodeIterator(const Quadtree& tree) - :mCurrentNode(HNode(&tree.mRoot, tree.mRootBounds)), mStackAlloc(), mNodeStack(&mStackAlloc) + :mCurrentNode(HNode(&tree.mRoot, tree.mRootBounds)) { - mNodeStack.push_back(mCurrentNode); + mNodeStack.add(mCurrentNode); } /** Initializes the iterator using a specific node and its bounds. */ NodeIterator(const Node* node, const NodeBounds& bounds) - :mCurrentNode(HNode(node, bounds)), mStackAlloc(), mNodeStack(&mStackAlloc) + :mCurrentNode(HNode(node, bounds)) { - mNodeStack.push_back(mCurrentNode); + mNodeStack.add(mCurrentNode); } /** @@ -415,13 +415,12 @@ namespace bs Node* childNode = mCurrentNode.getNode()->getChild(child); NodeBounds childBounds = mCurrentNode.getBounds().getChild(child); - mNodeStack.emplace_back(childNode, childBounds); + mNodeStack.add({childNode, childBounds}); } private: HNode mCurrentNode; - StaticAlloc mStackAlloc; - StaticVector mNodeStack; + SmallVector mNodeStack; }; /** Iterator that iterates over all elements in a single node. */ diff --git a/Source/Plugins/bsfRenderBeast/BsRenderBeastTest.cpp b/Source/Plugins/bsfRenderBeast/BsRenderBeastTest.cpp new file mode 100644 index 000000000..073049045 --- /dev/null +++ b/Source/Plugins/bsfRenderBeast/BsRenderBeastTest.cpp @@ -0,0 +1,50 @@ +//************************************ bs::framework - Copyright 2018 Marko Pintera **************************************// +//*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********// +#include "Testing/BsConsoleTestOutput.h" +#include "BsRenderBeastTestSuite.h" + +#include "BsApplication.h" +#include "BsEngineConfig.h" + +using namespace bs; + + +START_UP_DESC testStartupDesc() +{ + START_UP_DESC desc; + + // Set up default plugins + desc.renderAPI = BS_RENDER_API_MODULE; + // desc.renderAPI = "NullRenderAPI" + desc.renderer = BS_RENDERER_MODULE; + // desc.renderer = "NullRenderer"; + desc.audio = BS_AUDIO_MODULE; + desc.physics = BS_PHYSICS_MODULE; + + desc.importers.push_back("bsfFreeImgImporter"); + desc.importers.push_back("bsfFBXImporter"); + desc.importers.push_back("bsfFontImporter"); + desc.importers.push_back("bsfSL"); + + VideoMode mode; + desc.primaryWindowDesc.videoMode = mode; + desc.primaryWindowDesc.fullscreen = false; + desc.primaryWindowDesc.title = "test"; + return desc; +} + +int main() +{ + + auto desc = testStartupDesc(); + bs::Application::startUp(desc); + + SPtr tests = RenderBeastTestSuite::create(); + + ConsoleTestOutput testOutput; + tests->run(testOutput); + + bs::Application::shutDown(); + + return 0; +} diff --git a/Source/Plugins/bsfRenderBeast/BsRenderBeastTestSuite.cpp b/Source/Plugins/bsfRenderBeast/BsRenderBeastTestSuite.cpp index 855e1addc..17ce1247c 100644 --- a/Source/Plugins/bsfRenderBeast/BsRenderBeastTestSuite.cpp +++ b/Source/Plugins/bsfRenderBeast/BsRenderBeastTestSuite.cpp @@ -2,18 +2,10 @@ //*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********// #include "Testing/BsTestSuite.h" #include "Utility/BsTextureRowAllocator.h" +#include "BsRenderBeastTestSuite.h" namespace bs { - /** Runs unit tests for systems specific to the RenderBeast plugin. */ - class RenderBeastTestSuite : public TestSuite - { - public: - RenderBeastTestSuite(); - - private: - void testTextureRowAllocator(); - }; RenderBeastTestSuite::RenderBeastTestSuite() { diff --git a/Source/Plugins/bsfRenderBeast/BsRenderBeastTestSuite.h b/Source/Plugins/bsfRenderBeast/BsRenderBeastTestSuite.h new file mode 100644 index 000000000..1a732b97c --- /dev/null +++ b/Source/Plugins/bsfRenderBeast/BsRenderBeastTestSuite.h @@ -0,0 +1,20 @@ +//************************************ bs::framework - Copyright 2018 Marko Pintera **************************************// +//*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********// +#pragma once + +#include "Testing/BsTestSuite.h" + +namespace bs +{ + +/** Runs unit tests for systems specific to the RenderBeast plugin. */ +class RenderBeastTestSuite : public TestSuite +{ +public: + RenderBeastTestSuite(); + +private: + void testTextureRowAllocator(); +}; + +} // namespace bs diff --git a/Source/Plugins/bsfRenderBeast/CMakeLists.txt b/Source/Plugins/bsfRenderBeast/CMakeLists.txt index eae287833..32c859971 100644 --- a/Source/Plugins/bsfRenderBeast/CMakeLists.txt +++ b/Source/Plugins/bsfRenderBeast/CMakeLists.txt @@ -25,4 +25,15 @@ if(RENDERER_MODULE MATCHES "RenderBeast") install_bsf_target(bsfRenderBeast) endif() +if (BUILD_TESTS) + + add_executable(bsfRenderBeastTest + BsRenderBeastTest.cpp) + target_include_directories(bsfRenderBeastTest PRIVATE "./") + target_link_libraries(bsfRenderBeastTest bsf bsfRenderBeast) + + set_property(TARGET bsfRenderBeastTest PROPERTY FOLDER Tests) + bs_add_test(NAME RenderBeastTests COMMAND $) +endif() + conditional_cotire(bsfRenderBeast)