11 #include "gmock/gmock.h" 12 #include "gtest/gtest.h" 15 #include <unordered_map> 18 TEST(Utilities, strintToVec3) {
19 std::vector<std::string> strings = {
"[1.1, 2.2, 3.3]",
20 " [ 1.1 , 2.2 ,3.3 ] ",
21 "[1.1,2.2 ,3.3]",
"[1.1, 2.2, 3.3]"};
28 for (
auto& str : strings) {
38 EXPECT_EQ(0.1
f, coerce<float>(0.5
f, 0.
f, 0.1
f));
39 EXPECT_EQ(-0.1
f, coerce<float>(-0.5
f, -0.1
f, 0.1
f));
40 EXPECT_EQ(0.5
f, coerce<float>(0.5
f, -1.
f, 1.
f));
44 EXPECT_EQ(1, sgn<int>(10));
45 EXPECT_EQ(-1, sgn<int>(-10));
46 EXPECT_EQ(0, sgn<int>(0));
48 EXPECT_EQ(1, sgn<double>(13.23));
49 EXPECT_EQ(-1, sgn<double>(-.23));
50 EXPECT_EQ(0, sgn<double>(0.));
54 std::unordered_map<std::string, int> s;
61 std::map<std::string, int> s;
71 TEST(Utilities, colorPrint) {
bool fpEqual(T a, T b, T tol)
typename Eigen::Matrix< T, 3, 1 > Vec3
TEST(Utilities, strintToVec3)
T coerce(T in, T min, T max)
bool almostEqual(const Eigen::MatrixBase< T > &a, const Eigen::MatrixBase< T > &b, T2 tol)
Utility functions for math.
void printf_color(PrintColor color, const char *fmt,...)
bool uMapContains(const std::unordered_map< T1, T2 > &set, T1 key)
bool mapContains(const std::map< T1, T2 > &set, T1 key)
T mapToRange(T x, T inputMin, T inputMax, T outputMin, T outputMax)
MX f(const MX &x, const MX &u)