scenario_simulator_v2 C++ API
Functions | Variables
test_polynomial_solver.cpp File Reference
#include <gtest/gtest.h>
#include <geometry/solver/polynomial_solver.hpp>
#include <geometry/spline/hermite_curve.hpp>
#include <scenario_simulator_exception/exception.hpp>
Include dependency graph for test_polynomial_solver.cpp:

Functions

bool checkValueWithTolerance (double value, double expected, double tolerance=solver_tolerance)
 
 TEST (PolynomialSolverTest, LinearFunction)
 
 TEST (PolynomialSolverTest, SolveLinearEquation)
 
 TEST (PolynomialSolverTest, QuadraticFunction)
 
 TEST (PolynomialSolverTest, SolveQuadraticEquation)
 
 TEST (PolynomialSolverTest, CubicFunction)
 
 TEST (PolynomialSolverTest, SolveSpecificCubicEquation)
 
 TEST (PolynomialSolverTest, SolveSpecificCubicEquationWithMinMax)
 
 TEST (PolynomialSolverTest, SolveCubicEquation)
 
int main (int argc, char **argv)
 

Variables

constexpr double solver_tolerance = math::geometry::PolynomialSolver::tolerance
 

Function Documentation

◆ checkValueWithTolerance()

bool checkValueWithTolerance ( double  value,
double  expected,
double  tolerance = solver_tolerance 
)

◆ main()

int main ( int  argc,
char **  argv 
)

◆ TEST() [1/8]

TEST ( PolynomialSolverTest  ,
CubicFunction   
)
Note
Testcase for ax^3+bx^2+cx+d

◆ TEST() [2/8]

TEST ( PolynomialSolverTest  ,
LinearFunction   
)
Note
Testcase for ax+b

◆ TEST() [3/8]

TEST ( PolynomialSolverTest  ,
QuadraticFunction   
)
Note
Testcase for ax^2+bx+c

◆ TEST() [4/8]

TEST ( PolynomialSolverTest  ,
SolveCubicEquation   
)
Note
Testcase for ax^3+bx^2+cx+d = 0 Coverage verification of each coefficient for the cubic equation ax^3 + bx^2 + cx + d = 0 in the range [-10, 10] in increments of 1
Note
If the ax^3+bx^2+cx+d=0 (a=0,b=0,c=0,d=0), any x value is a solution, so throwing a common::SimulationError error is expected.
Other cases, solver must be able to obtain solutions.

◆ TEST() [5/8]

TEST ( PolynomialSolverTest  ,
SolveLinearEquation   
)
Note
Testcase for ax+b = 0 Coverage verification of each coefficient for the cubic equation ax^2 + bx + c = 0 in the range [-20, 20] in increments of 0.1
Note
If the ax+b=0 (a=0,b=0), any x value is a solution, so throwing a common::SimulationError error is expected.
Other cases, solver must be able to obtain solutions.

◆ TEST() [6/8]

TEST ( PolynomialSolverTest  ,
SolveQuadraticEquation   
)
Note
Testcase for ax^2+bx+c = 0 Coverage verification of each coefficient for the cubic equation ax^2 + bx + c = 0 in the range [-20, 20] in increments of 1
Note
If the ax^2+bx+c=0 (a=0,b=0,c=0), any x value is a solution, so throwing a common::SimulationError error is expected.
Other cases, solver must be able to obtain solutions.

◆ TEST() [7/8]

TEST ( PolynomialSolverTest  ,
SolveSpecificCubicEquation   
)
Note
Testcase for ax^3+bx^2+cx+d = 0
Note
solve x^3 - 2x^2 - 11x + 12 = 0 (solutions should be -3, 1, 4)

◆ TEST() [8/8]

TEST ( PolynomialSolverTest  ,
SolveSpecificCubicEquationWithMinMax   
)
Note
Testcase for ax^3+bx^2+cx+d = 0
Note
solve x^3 - 2x^2 - 11x + 12 = 0 (solutions should be 1) range of the solution should be [min_value, max_value].
I used EXPECT_TRUE(checkValueWithTolerance(solutions[1], 1)) in 1 = max_value, SolveSpecificCubicEquation testcase, but in this test case, The solution x obtained satisfies std::abs(x-max_value) <= solver_tolerance, so the value of max_value (in this case, double 1.0 value) must be assigned.

Variable Documentation

◆ solver_tolerance

constexpr double solver_tolerance = math::geometry::PolynomialSolver::tolerance
constexpr