rotgen/test/unit/map/cwise.cpp
Jules Pénuchot e151e136d6 Resolve "[API-#2] Pseudo-privatization of rotgen entity member functions"
Closes #18

Co-authored-by: Jules Pénuchot <jules@penuchot.com>

See merge request oss/rotgen!50
2025-12-17 20:48:00 +01:00

48 lines
1.7 KiB
C++

//==================================================================================================
/*
ROTGEN - Runtime Overlay for Eigen
Copyright : CODE RECKONS
SPDX-License-Identifier: BSL-1.0
*/
//==================================================================================================
#include <rotgen/rotgen.hpp>
#include "unit/common/cwise.hpp"
#include "unit/common/references.hpp"
#include "unit/tests.hpp"
TTS_CASE_TPL("Test dynamic map cwise operations", rotgen::tests::types)
<typename T, typename O>(tts::type<tts::types<T, O>>)
{
auto const cases = rotgen::tests::generate_matrix_references();
for (auto const& [rows, cols, fn] : cases)
{
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> base(rows,
cols);
rotgen::tests::prepare(rows, cols, fn, base);
rotgen::map<rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value>>
input(base.data(), rows, cols);
rotgen::tests::check_cwise_functions(input);
}
};
TTS_CASE_TPL("Test static map cwise operations", rotgen::tests::types)
<typename T, typename O>(tts::type<tts::types<T, O>>)
{
auto const cases = rotgen::tests::generate_static_matrix_references();
auto process = []<typename D>(D const& desc) {
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> base(D::rows,
D::cols);
rotgen::tests::prepare(rows(base), cols(base), desc.init_fn, base);
rotgen::map<rotgen::matrix<T, D::rows, D::cols, O::value>> input(
base.data());
rotgen::tests::check_cwise_functions(input);
};
std::apply([&](auto const&... d) { (process(d), ...); }, cases);
};