fix: tests

This commit is contained in:
parker
2025-07-28 17:18:10 +01:00
parent 34da64bbb2
commit 93fe708646
5 changed files with 53 additions and 43 deletions

View File

@@ -81,36 +81,36 @@ target_include_directories(${AppExec} PUBLIC src)
add_subdirectory(src/OpDefs)
# tests
# Include(FetchContent)
Include(FetchContent)
# FetchContent_Declare(
# Catch2
# GIT_REPOSITORY https://github.com/catchorg/Catch2.git
# GIT_TAG v3.8.1 # or a later release
# )
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.8.1 # or a later release
)
# FetchContent_MakeAvailable(Catch2)
FetchContent_MakeAvailable(Catch2)
# add_executable(${TestExec}
# ${ENGINE_SOURCES}
# tests/main-tests.cpp
# tests/OperatorTests.cpp
# tests/NetworkTests.cpp
# )
# target_link_libraries(${TestExec} PRIVATE Catch2::Catch2WithMain Eigen3::Eigen Qt6::Core TBB::tbb Boost::filesystem Boost::system)
# target_compile_definitions(${TestExec} PRIVATE UNIT_TEST)
# target_include_directories(${TestExec} PUBLIC
# src
# ${BOOST_INCLUDE_DIRS}
# )
add_executable(${TestExec}
${ENGINE_SOURCES}
tests/main-tests.cpp
tests/OperatorTests.cpp
tests/NetworkTests.cpp
)
target_link_libraries(${TestExec} PRIVATE Catch2::Catch2WithMain Eigen3::Eigen Qt6::Core TBB::tbb Boost::filesystem Boost::system)
target_compile_definitions(${TestExec} PRIVATE UNIT_TEST)
target_include_directories(${TestExec} PUBLIC
src
${BOOST_INCLUDE_DIRS}
)
# # benchmarks
# add_executable(${BenchExec}
# ${ENGINE_SOURCES}
# benchmarks
add_executable(${BenchExec}
${ENGINE_SOURCES}
# tests/Benchmarks.cpp
# )
# target_link_libraries(${BenchExec} PRIVATE Catch2::Catch2WithMain Eigen3::Eigen Qt6::Core TBB::tbb Boost::filesystem Boost::system)
# target_compile_definitions(${BenchExec} PRIVATE UNIT_TEST)
# target_include_directories(${BenchExec} PUBLIC src)
tests/Benchmarks.cpp
)
target_link_libraries(${BenchExec} PRIVATE Catch2::Catch2WithMain Eigen3::Eigen Qt6::Core TBB::tbb Boost::filesystem Boost::system)
target_compile_definitions(${BenchExec} PRIVATE UNIT_TEST)
target_include_directories(${BenchExec} PUBLIC src)

View File

@@ -4,12 +4,12 @@ namespace enzo::prm
{
enum class Type
{
STRING,
FLOAT,
INT,
};
// enum class Type
// {
// STRING,
// FLOAT,
// INT,
// };
// class Type

View File

@@ -31,6 +31,16 @@ namespace enzo
using Vector3 = Eigen::Vector3d;
using Vector4 = Eigen::Vector4d;
}
namespace prm
{
enum class Type
{
STRING,
FLOAT,
INT,
TOGGLE
};
}
namespace nt
{
using OpId = uint64_t;

View File

@@ -26,7 +26,7 @@ struct OperatorTableInit
OperatorTableInit() { enzo::op::OperatorTable::initPlugins(); }
};
static OperatorTableInit _operatorTableInit;
auto testOpCtor = enzo::op::OperatorTable::getOpConstructor("house");
auto testOpInfo = enzo::op::OperatorTable::getOpInfo("house").value();
TEST_CASE_METHOD(NMReset, "Network Manager")
{
@@ -34,7 +34,7 @@ TEST_CASE_METHOD(NMReset, "Network Manager")
auto& nm = nt::nm();
nt::OpId startOp = nm.addOperator(testOpCtor);
nt::OpId startOp = nm.addOperator(testOpInfo);
nt::OpId prevOp = startOp;
std::vector<nt::OpId> prevOps;
@@ -42,7 +42,7 @@ TEST_CASE_METHOD(NMReset, "Network Manager")
{
for(int i=0; i<4; ++i)
{
nt::OpId newOp = nm.addOperator(testOpCtor);
nt::OpId newOp = nm.addOperator(testOpInfo);
prevOps.push_back(newOp);
nt::connectOperators(newOp, i, prevOp, 0);
}
@@ -52,7 +52,7 @@ TEST_CASE_METHOD(NMReset, "Network Manager")
for(int i=0; i<size(prevOpsBuffer); ++i)
{
prevOps.clear();
nt::OpId newOp = nm.addOperator(testOpCtor);
nt::OpId newOp = nm.addOperator(testOpInfo);
prevOps.push_back(newOp);
nt::connectOperators(newOp, 0, prevOpsBuffer[i], 0);

View File

@@ -26,14 +26,14 @@ struct OperatorTableInit
OperatorTableInit() { enzo::op::OperatorTable::initPlugins(); }
};
static OperatorTableInit _operatorTableInit;
auto testOpCtor = enzo::op::OperatorTable::getOpConstructor("house");
auto testOpInfo = enzo::op::OperatorTable::getOpInfo("house").value();
TEST_CASE_METHOD(NMReset, "network fixture separation start")
{
using namespace enzo;
auto& nm = nt::nm();
nt::OpId newOpId = nm.addOperator(testOpCtor);
nt::OpId newOpId = nm.addOperator(testOpInfo);
REQUIRE(newOpId==1);
REQUIRE(nm.isValidOp(1));
@@ -53,8 +53,8 @@ TEST_CASE_METHOD(NMReset, "network")
using namespace enzo;
auto& nm = nt::nm();
nt::OpId newOpId = nm.addOperator(testOpCtor);
nt::OpId newOpId2 = nm.addOperator(testOpCtor);
nt::OpId newOpId = nm.addOperator(testOpInfo);
nt::OpId newOpId2 = nm.addOperator(testOpInfo);
REQUIRE(nm.isValidOp(newOpId));
if(nm.isValidOp(newOpId))
@@ -78,13 +78,13 @@ TEST_CASE_METHOD(NMReset, "reset")
using namespace enzo;
auto& nm = nt::nm();
nt::OpId newOpId = nm.addOperator(testOpCtor);
nt::OpId newOpId = nm.addOperator(testOpInfo);
nm._reset();
REQUIRE_FALSE(nm.isValidOp(newOpId));
nt::OpId newOpId2 = nm.addOperator(testOpCtor);
nt::OpId newOpId2 = nm.addOperator(testOpInfo);
REQUIRE(nm.isValidOp(newOpId2));