Skip to content

Commit

Permalink
added VAOFactory Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jmacey committed Sep 29, 2023
1 parent 2baa3ca commit 29c7fde
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ if(NOT DEFINED PYNGL_ONLY)
${CMAKE_SOURCE_DIR}/tests/MessageTests.cpp
${CMAKE_SOURCE_DIR}/tests/NGLStreamTest.cpp
${CMAKE_SOURCE_DIR}/tests/TextureTests.cpp
${CMAKE_SOURCE_DIR}/tests/VAOFactoryTests.cpp

)
add_compile_definitions(GLM_ENABLE_EXPERIMENTAL)
Expand Down
6 changes: 4 additions & 2 deletions include/ngl/VAOFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ class NGL_DLLEXPORT VAOFactory
//----------------------------------------------------------------------------------------------------------------------
/// @brief debug function to list all creators
//----------------------------------------------------------------------------------------------------------------------
static void listCreators();
static void listCreators() noexcept;

private:
static size_t getNumCreators() noexcept {return m_vaoCreators.size();}

private:
//----------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------
static std::unordered_map< std::string, std::function< std::unique_ptr< AbstractVAO >(GLenum _mode) > > m_vaoCreators;
Expand Down
6 changes: 3 additions & 3 deletions src/VAOFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ void VAOFactory::unregisterVAOCreator(std::string_view _type)
std::unique_ptr< AbstractVAO > VAOFactory::createVAO(std::string_view _type, GLenum _mode)
{

auto it = m_vaoCreators.find(_type.data());
if(it != m_vaoCreators.end())

if(auto it = m_vaoCreators.find(_type.data()); it != m_vaoCreators.end())
{
// call the creation callback to construct this derived type
return it->second(_mode);
}
return nullptr;
}

void VAOFactory::listCreators()
void VAOFactory::listCreators() noexcept
{
NGLMessage::addMessage("******************************\n", Colours::WHITE, TimeFormat::NONE);
NGLMessage::addMessage("VAOFactory Creators List ", Colours::WHITE, TimeFormat::NONE);
Expand Down
2 changes: 1 addition & 1 deletion tests/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ int main(int argc, char **argv)
if(useOpenGL == false)
{
std::cerr << "excluding tests\n";
::testing::GTEST_FLAG(filter) = "-ShaderLib.*:VAOPrimitives.*:NGLInit*";
::testing::GTEST_FLAG(filter) = "-ShaderLib.*:VAOPrimitives.*:NGLInit*:VAOFactory*";
}
// testing::internal::CaptureStdout();
testing::internal::CaptureStderr();
Expand Down

0 comments on commit 29c7fde

Please sign in to comment.