Skip to content

Commit

Permalink
adding test for attribute type name functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mtao committed Dec 15, 2024
1 parent 8a5669d commit 09d6105
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
4 changes: 3 additions & 1 deletion components/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ include(add_component_test)
# wmtk::component_utils
add_subdirectory(utils)

if(WILDMESHING_TOOLKIT_TOPLEVEL_PROJECT)
option(WMTK_ENABLE_COMPONENT_TESTS "Enable unit tests for components" ${WILDMESHING_TOOLKIT_TOPLEVEL_PROJECT})

if(WMTK_ENABLE_COMPONENT_TESTS)
add_subdirectory(tests)
endif()

Expand Down
2 changes: 1 addition & 1 deletion components/cmake/add_component_test.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function(add_component_test COMPONENT_TARGET_NAME ...)

if(NOT WILDMESHING_TOOLKIT_TOPLEVEL_PROJECT)
if(NOT WMTK_ENABLE_COMPONENT_TESTS)
return()
endif()
list(REMOVE_AT ARGV 0)
Expand Down
2 changes: 2 additions & 0 deletions components/multimesh/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
set(COMPONENT_NAME multimesh)
add_subdirectory("src/wmtk/components/${COMPONENT_NAME}")
if(WMTK_ENABLE_COMPONENT_TESTS)
add_subdirectory("tests")
endif()
2 changes: 2 additions & 0 deletions tests/attributes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ set(TEST_SOURCES
old_wmtk_attributecollection.cpp

transaction_stack.cpp

attribute_type.cpp
)
target_sources(wmtk_tests PRIVATE ${TEST_SOURCES})

Expand Down
18 changes: 18 additions & 0 deletions tests/attributes/attribute_type.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <numeric>

#include <catch2/catch_test_macros.hpp>
#include <wmtk/attribute/AttributeType.hpp>


using namespace wmtk::attribute;

TEST_CASE("test_attribute_type_names", "[attributes]")
{
using AT = AttributeType;
CHECK(attribute_type_name(AT::Char) == "Char");
CHECK(attribute_type_name(AT::Double) == "Double");
CHECK(attribute_type_name(AT::Int64) == "Int64");
CHECK(attribute_type_name(AT::Rational) == "Rational");

}

0 comments on commit 09d6105

Please sign in to comment.