14 #include <gtest/gtest.h>
16 #include "../../include/ecl/geometry/cubic_spline.hpp"
38 TEST(CubicSplinesTests,derivativeHeuristic) {
41 x_set << 0.688792, 1.15454, 1.67894;
42 y_set << -0.75, -1.2, -1.30;
43 double ydot_0 = -0.5/x_set[0];
44 double ydot_f = 1.04/3.72;
46 CubicSpline cubic = CubicSpline::DerivativeHeuristic(x_set, y_set, ydot_0, ydot_f);
53 EXPECT_EQ(0.688792, domain[0]);
54 EXPECT_EQ(1.15454, domain[1]);
55 EXPECT_EQ(1.67894, domain[2]);
59 EXPECT_GT(-2.07,p1.coefficients()[0]); EXPECT_LT(-2.09,p1.coefficients()[0]);
60 EXPECT_GT(5.97,p1.coefficients()[1]); EXPECT_LT(5.95,p1.coefficients()[1]);
61 EXPECT_GT(-7.84,p1.coefficients()[2]); EXPECT_LT(-7.86,p1.coefficients()[2]);
62 EXPECT_GT(2.91,p1.coefficients()[3]); EXPECT_LT(2.89,p1.coefficients()[3]);
64 EXPECT_GT(-0.21,p2.coefficients()[0]); EXPECT_LT(-0.23,p2.coefficients()[0]);
65 EXPECT_GT(-0.71,p2.coefficients()[1]); EXPECT_LT(-0.73,p2.coefficients()[1]);
66 EXPECT_GT(-0.45,p2.coefficients()[2]); EXPECT_LT(-0.47,p2.coefficients()[2]);
67 EXPECT_GT(0.31,p2.coefficients()[3]); EXPECT_LT(0.29,p2.coefficients()[3]);
89 TEST(CubicSplinesTests,continuousHeuristic) {
92 x_set << 0.688792, 1.15454, 1.67894;
93 y_set << -0.75, -1.2, -1.30;
94 double ydot_0 = -0.5/x_set[0];
95 double ydot_f = 1.04/3.72;
96 CubicSpline cubic = CubicSpline::ContinuousDerivatives(x_set, y_set, ydot_0, ydot_f);
100 EXPECT_GT(-1.57,p1.coefficients()[0]); EXPECT_LT(-1.59,p1.coefficients()[0]);
101 EXPECT_GT(4.10,p1.coefficients()[1]); EXPECT_LT(4.08,p1.coefficients()[1]);
102 EXPECT_GT(-5.53,p1.coefficients()[2]); EXPECT_LT(-5.55,p1.coefficients()[2]);
103 EXPECT_GT(2.00,p1.coefficients()[3]); EXPECT_LT(1.98,p1.coefficients()[3]);
105 EXPECT_GT(2.13,p2.coefficients()[0]); EXPECT_LT(2.11,p2.coefficients()[0]);
106 EXPECT_GT(-5.51,p2.coefficients()[1]); EXPECT_LT(-5.53,p2.coefficients()[1]);
107 EXPECT_GT(2.79,p2.coefficients()[2]); EXPECT_LT(2.77,p2.coefficients()[2]);
108 EXPECT_GT(-0.41,p2.coefficients()[3]); EXPECT_LT(-0.43,p2.coefficients()[3]);
129 TEST(CubicSplinesTests,naturalSpline) {
132 x_set << 0.688792, 1.15454, 1.67894;
133 y_set << -0.75, -1.2, -1.30;
135 CubicSpline cubic = CubicSpline::Natural(x_set, y_set);
139 EXPECT_GT(-0.22,p1.coefficients()[0]); EXPECT_LT(-0.24,p1.coefficients()[0]);
140 EXPECT_GT(0.06,p1.coefficients()[1]); EXPECT_LT(0.04,p1.coefficients()[1]);
141 EXPECT_GT(-1.73,p1.coefficients()[2]); EXPECT_LT(-1.75,p1.coefficients()[2]);
142 EXPECT_GT(0.85,p1.coefficients()[3]); EXPECT_LT(0.83,p1.coefficients()[3]);
144 EXPECT_GT(2.22,p2.coefficients()[0]); EXPECT_LT(2.20,p2.coefficients()[0]);
145 EXPECT_GT(-6.29,p2.coefficients()[1]); EXPECT_LT(-6.31,p2.coefficients()[1]);
146 EXPECT_GT(3.77,p2.coefficients()[2]); EXPECT_LT(3.75,p2.coefficients()[2]);
147 EXPECT_GT(-0.74,p2.coefficients()[3]); EXPECT_LT(-0.76,p2.coefficients()[3]);
172 int main(
int argc,
char **argv) {
174 testing::InitGoogleTest(&argc,argv);
175 return RUN_ALL_TESTS();