From 1e5e24a03647ca8c9fb9241130b11195fef7d3a2 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Fri, 18 Dec 2015 11:37:02 +0100 Subject: [PATCH] The tests seems to work under boost 1.59 but test explorer window is broken in 1.60. also changed ResourceManagerTest.cpp --- {src => include}/Tests/EventFixture.h | 0 {src => include}/Tests/OctTreeTestGameClass.h | 0 .../Tests/OctTreeTestHardCodedTestWorld.h | 0 src/Tests/CMakeLists.txt | 1 + src/Tests/ConfigFileTest.cpp | 73 +++++++++---------- src/Tests/ResourceManagerTest.cpp | 24 +----- 6 files changed, 38 insertions(+), 60 deletions(-) rename {src => include}/Tests/EventFixture.h (100%) rename {src => include}/Tests/OctTreeTestGameClass.h (100%) rename {src => include}/Tests/OctTreeTestHardCodedTestWorld.h (100%) diff --git a/src/Tests/EventFixture.h b/include/Tests/EventFixture.h similarity index 100% rename from src/Tests/EventFixture.h rename to include/Tests/EventFixture.h diff --git a/src/Tests/OctTreeTestGameClass.h b/include/Tests/OctTreeTestGameClass.h similarity index 100% rename from src/Tests/OctTreeTestGameClass.h rename to include/Tests/OctTreeTestGameClass.h diff --git a/src/Tests/OctTreeTestHardCodedTestWorld.h b/include/Tests/OctTreeTestHardCodedTestWorld.h similarity index 100% rename from src/Tests/OctTreeTestHardCodedTestWorld.h rename to include/Tests/OctTreeTestHardCodedTestWorld.h diff --git a/src/Tests/CMakeLists.txt b/src/Tests/CMakeLists.txt index 697dea29..f4dc710e 100644 --- a/src/Tests/CMakeLists.txt +++ b/src/Tests/CMakeLists.txt @@ -12,6 +12,7 @@ include_directories( ) file(GLOB SOURCE_FILES + "${INCLUDE_PATH}/Tests/*.h" "*.cpp" ) diff --git a/src/Tests/ConfigFileTest.cpp b/src/Tests/ConfigFileTest.cpp index bbe57de2..28be5589 100644 --- a/src/Tests/ConfigFileTest.cpp +++ b/src/Tests/ConfigFileTest.cpp @@ -16,53 +16,50 @@ BOOST_AUTO_TEST_SUITE(confTest) BOOST_AUTO_TEST_CASE(configFileTest) { - ////note: this ConfigFileclass currently has memleaks! + //note: this ConfigFileclass currently has memleaks! - //ResourceManager::RegisterType("ConfigFile"); - //auto m_Config = ResourceManager::Load("ConfigTest.ini"); + ResourceManager::RegisterType("ConfigFile"); + auto m_Config = ResourceManager::Load("ConfigTest.ini"); - ////bägge måste vara av samma typ, T typen är string - ////http://www.boost.org/doc/libs/1_42_0/doc/html/boost_propertytree/tutorial.html - ////"Note that we construct the path to the value by separating the individual keys with dots" + //bägge måste vara av samma typ, T typen är string + //http://www.boost.org/doc/libs/1_42_0/doc/html/boost_propertytree/tutorial.html + //"Note that we construct the path to the value by separating the individual keys with dots" - ////get from tree tests - //auto getSomething = m_Config->Get("Test.Test1", 0); - //BOOST_CHECK(getSomething == 423); + //get from tree tests + auto getSomething = m_Config->Get("Test.Test1", 0); + BOOST_CHECK(getSomething == 423); - //auto getSomething2 = m_Config->Get("fsdfdsfd.T", std::string("")); - //BOOST_CHECK(getSomething2 == "\"gfdjakflsdl!\""); + auto getSomething2 = m_Config->Get("fsdfdsfd.T", std::string("")); + BOOST_CHECK(getSomething2 == "\"gfdjakflsdl!\""); - ////set/get tests - //m_Config->Set("Test.4321", 123); - //auto getSomething3 = m_Config->Get("Test.4321", 0); - //BOOST_CHECK(getSomething3 == 123); + //set/get tests + m_Config->Set("Test.4321", 123); + auto getSomething3 = m_Config->Get("Test.4321", 0); + BOOST_CHECK(getSomething3 == 123); - //m_Config->Set("3_2_1_0_5", "t454j54hj5k32"); - //auto getSomething4 = m_Config->Get("3_2_1_0_5", std::string("")); - //BOOST_CHECK(getSomething4 == "t454j54hj5k32"); + m_Config->Set("3_2_1_0_5", "t454j54hj5k32"); + auto getSomething4 = m_Config->Get("3_2_1_0_5", std::string("")); + BOOST_CHECK(getSomething4 == "t454j54hj5k32"); - ////***check so outputwindow says: EE: Failed to find "DefaultConfigTestNotExists.ini"! Relying on hardcoded default values! - //auto m_Config2 = ResourceManager::Load("ConfigTestNotExists.ini"); + //***check so outputwindow says: EE: Failed to find "DefaultConfigTestNotExists.ini"! Relying on hardcoded default values! + auto m_Config2 = ResourceManager::Load("ConfigTestNotExists.ini"); - ////set value/savetodisk/load/checkvalue... - //m_Config->SaveToDisk(); - //m_Config->Set("Test.4321", 145); - //m_Config->SaveToDisk(); - //auto m_Config3 = ResourceManager::Load("ConfigTest.ini"); - //auto getSomething5 = m_Config->Get("Test.4321", 0); - //BOOST_CHECK(getSomething5 == 145); - // - ////***check so outputwindow says: EE: Failed to parse "DefaultConfigTestFailed.ini" - ////***check so outputwindow says: EE: Failed to parse "ConfigTestFailed.ini": - //auto m_Config4 = ResourceManager::Load("ConfigTestFailed.ini"); + //set value/savetodisk/load/checkvalue... + m_Config->SaveToDisk(); + m_Config->Set("Test.4321", 145); + m_Config->SaveToDisk(); + auto m_Config3 = ResourceManager::Load("ConfigTest.ini"); + auto getSomething5 = m_Config->Get("Test.4321", 0); + BOOST_CHECK(getSomething5 == 145); + + //***check so outputwindow says: EE: Failed to parse "DefaultConfigTestFailed.ini" + //***check so outputwindow says: EE: Failed to parse "ConfigTestFailed.ini": + auto m_Config4 = ResourceManager::Load("ConfigTestFailed.ini"); - ////test to try to fix memleaks - failed, probably something else - ////ResourceManager::Release(std::string("ConfigFile"), std::string("ConfigTest.ini")); - ////ResourceManager::Release(std::string("ConfigFile"), std::string("ConfigTestNotExists.ini")); - ////ResourceManager::Release(std::string("ConfigFile"), std::string("ConfigTest.ini")); - ////ResourceManager::Release(std::string("ConfigFile"), std::string("ConfigTestFailed.ini")); - ////reload,onchildreload unimplemented - //_CrtDumpMemoryLeaks(); + //reload,onchildreload unimplemented + + //NOTE:still massive amount of memoryleaks from this method + _CrtDumpMemoryLeaks(); } BOOST_AUTO_TEST_SUITE_END() diff --git a/src/Tests/ResourceManagerTest.cpp b/src/Tests/ResourceManagerTest.cpp index e05d8563..a3edb7b8 100644 --- a/src/Tests/ResourceManagerTest.cpp +++ b/src/Tests/ResourceManagerTest.cpp @@ -1,25 +1,15 @@ #include - #include "Core/World.h" +//private->public hack doesnt work, tons of link errors +//so there is currently no good way to test this class //#define private public #include "Core/ResourceManager.h" - #include "Core/ConfigFile.h" - #include "Rendering/Renderer.h" #include "Core/EntityXMLFile.h" #include "Engine\Rendering\Texture.h" -//#include "Core/EventBroker.h" -//#include "Core/InputManager.h" -//#include "GUI/Frame.h" -//#include "Rendering/RenderQueueFactory.h" -//#include "Core/EKeyDown.h" -//#include "Core/SystemPipeline.h" -//#include "RaptorCopterSystem.h" - - BOOST_AUTO_TEST_SUITE(resourceManagerTests) BOOST_AUTO_TEST_CASE(resourceManagerTest) @@ -28,10 +18,6 @@ BOOST_AUTO_TEST_CASE(resourceManagerTest) //private static metoder/variabler - //ugly private->public hack doesnt work, tons of link errors. hence cant test it properly - //its not my job to implement testfunctions for unittests in the class either - - //craptests ahead: ResourceManager::RegisterType("ConfigFile"); BOOST_CHECK(!ResourceManager::IsResourceLoaded("ConfigFile", "Config.ini")); auto m_Config = ResourceManager::Load("Config.ini"); @@ -45,12 +31,6 @@ BOOST_AUTO_TEST_CASE(resourceManagerTest) BOOST_CHECK(!ResourceManager::IsResourceLoaded("Model", "Models/Core/ScreenQuad.obj")); //there is no error feedback to check if you try to release the wrong resources - hence that cant be tested either - - //registertype (bind with function) - //m_CompilerTypenameToResourceType = global... - //m_FactoryFunctions = global... - //BOOST_CHECK(ResourceManager::m_CompilerTypenameToResourceType.size() != 0); - //BOOST_CHECK(ResourceManager::m_FactoryFunctions.size() != 0); } BOOST_AUTO_TEST_SUITE_END()