Initial commit

This commit is contained in:
2026-07-27 13:51:19 +08:00
commit 7bec56ca51
5408 changed files with 1126933 additions and 0 deletions
@@ -0,0 +1,29 @@
#include <gtest/gtest.h>
#include <canopen_motor_node/unit_converter.h>
#include <canopen_motor_node/handle_layer.h>
#include <functional>
using namespace canopen;
double * mapVariable(const std::string &, double *p) {
return p;
}
TEST(TestMuparser, CheckNorm){
double input = 0;
UnitConverter uc("norm(in,-1000,1000)", std::bind(HandleLayer::assignVariable, std::placeholders::_1, &input, "in"));
input = 0; EXPECT_EQ(0, uc.evaluate());
input = 10; EXPECT_EQ(10, uc.evaluate());
input = -10; EXPECT_EQ(-10, uc.evaluate());
input = 1000; EXPECT_EQ(-1000, uc.evaluate());
input = 1001; EXPECT_EQ(-999, uc.evaluate());
input = 2000; EXPECT_EQ(0, uc.evaluate());
input = 2001; EXPECT_EQ(1, uc.evaluate());
input = -1000; EXPECT_EQ(-1000, uc.evaluate());
input = 999; EXPECT_EQ(999, uc.evaluate());
}
int main(int argc, char **argv){
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}