diff --git a/poincare/test/function_solver.cpp b/poincare/test/function_solver.cpp index 5baabae04..4dee3c65f 100644 --- a/poincare/test/function_solver.cpp +++ b/poincare/test/function_solver.cpp @@ -71,12 +71,26 @@ QUIZ_CASE(poincare_function_extremum) { Coordinate2D(NAN, NAN)}; assert_points_of_interest_are(PointOfInterestType::Maximum, numberOfMaxima, maxima, "cos(a)", nullptr, "a", -1.0, 0.1, 500.0); } + { + constexpr int numberOfMaxima = 3; + Coordinate2D maxima[numberOfMaxima] = { + Coordinate2D(360.0, 1.0), + Coordinate2D(0.0, 1.0), + Coordinate2D(NAN, NAN)}; + assert_points_of_interest_are(PointOfInterestType::Maximum, numberOfMaxima, maxima, "cos(a)", nullptr, "a", 500.0, -0.1, -1.0); + } { constexpr int numberOfMinima = 1; Coordinate2D minima[numberOfMinima] = { Coordinate2D(180.0, -1.0)}; assert_points_of_interest_are(PointOfInterestType::Minimum, numberOfMinima, minima, "cos(a)", nullptr, "a", 0.0, 0.1, 300.0); } + { + constexpr int numberOfMinima = 1; + Coordinate2D minima[numberOfMinima] = { + Coordinate2D(180.0, -1.0)}; + assert_points_of_interest_are(PointOfInterestType::Minimum, numberOfMinima, minima, "cos(a)", nullptr, "a", 300.0, -0.1, 0.0); + } } { { @@ -85,12 +99,24 @@ QUIZ_CASE(poincare_function_extremum) { Coordinate2D(NAN, NAN)}; assert_points_of_interest_are(PointOfInterestType::Maximum, numberOfMaxima, maxima, "a^2", nullptr, "a", -1.0, 0.1, 100.0); } + { + constexpr int numberOfMaxima = 1; + Coordinate2D maxima[numberOfMaxima] = { + Coordinate2D(NAN, NAN)}; + assert_points_of_interest_are(PointOfInterestType::Maximum, numberOfMaxima, maxima, "a^2", nullptr, "a", 100.0, -0.1, -1.0); + } { constexpr int numberOfMinima = 1; Coordinate2D minima[numberOfMinima] = { Coordinate2D(0.0, 0.0)}; assert_points_of_interest_are(PointOfInterestType::Minimum, numberOfMinima, minima, "a^2", nullptr, "a", -1.0, 0.1, 100.0); } + { + constexpr int numberOfMinima = 1; + Coordinate2D minima[numberOfMinima] = { + Coordinate2D(0.0, 0.0)}; + assert_points_of_interest_are(PointOfInterestType::Minimum, numberOfMinima, minima, "a^2", nullptr, "a", 100.0, -0.1, -1.0); + } } { { @@ -99,12 +125,24 @@ QUIZ_CASE(poincare_function_extremum) { Coordinate2D(NAN, 3.0)}; assert_points_of_interest_are(PointOfInterestType::Maximum, numberOfMaxima, maxima, "3", nullptr, "a", -1.0, 0.1, 100.0); } + { + constexpr int numberOfMaxima = 1; + Coordinate2D maxima[numberOfMaxima] = { + Coordinate2D(NAN, 3.0)}; + assert_points_of_interest_are(PointOfInterestType::Maximum, numberOfMaxima, maxima, "3", nullptr, "a", 100.0, -0.1, -1.0); + } { constexpr int numberOfMinima = 1; Coordinate2D minima[numberOfMinima] = { Coordinate2D(NAN, 3.0)}; assert_points_of_interest_are(PointOfInterestType::Minimum, numberOfMinima, minima, "3", nullptr, "a", -1.0, 0.1, 100.0); } + { + constexpr int numberOfMinima = 1; + Coordinate2D minima[numberOfMinima] = { + Coordinate2D(NAN, 3.0)}; + assert_points_of_interest_are(PointOfInterestType::Minimum, numberOfMinima, minima, "3", nullptr, "a", 100.0, -0.1, -1.0); + } } { { @@ -113,12 +151,24 @@ QUIZ_CASE(poincare_function_extremum) { Coordinate2D(NAN, 0.0)}; assert_points_of_interest_are(PointOfInterestType::Maximum, numberOfMaxima, maxima, "0", nullptr, "a", -1.0, 0.1, 100.0); } + { + constexpr int numberOfMaxima = 1; + Coordinate2D maxima[numberOfMaxima] = { + Coordinate2D(NAN, 0.0)}; + assert_points_of_interest_are(PointOfInterestType::Maximum, numberOfMaxima, maxima, "0", nullptr, "a", 100.0, -0.1, -1.0); + } { constexpr int numberOfMinima = 1; Coordinate2D minima[numberOfMinima] = { Coordinate2D(NAN, 0.0)}; assert_points_of_interest_are(PointOfInterestType::Minimum, numberOfMinima, minima, "0", nullptr, "a", -1.0, 0.1, 100.0); } + { + constexpr int numberOfMinima = 1; + Coordinate2D minima[numberOfMinima] = { + Coordinate2D(NAN, 0.0)}; + assert_points_of_interest_are(PointOfInterestType::Minimum, numberOfMinima, minima, "0", nullptr, "a", 100.0, -0.1, -1.0); + } } } @@ -131,12 +181,26 @@ QUIZ_CASE(poincare_function_root) { Coordinate2D(450.0, 0.0)}; assert_points_of_interest_are(PointOfInterestType::Root, numberOfRoots, roots, "cos(a)", nullptr, "a", 0.0, 0.1, 500.0); } + { + constexpr int numberOfRoots = 3; + Coordinate2D roots[numberOfRoots] = { + Coordinate2D(450.0, 0.0), + Coordinate2D(270.0, 0.0), + Coordinate2D(90.0, 0.0)}; + assert_points_of_interest_are(PointOfInterestType::Root, numberOfRoots, roots, "cos(a)", nullptr, "a", 500.0, -0.1, 0.0); + } { constexpr int numberOfRoots = 1; Coordinate2D roots[numberOfRoots] = { Coordinate2D(0.0, 0.0)}; assert_points_of_interest_are(PointOfInterestType::Root, numberOfRoots, roots, "a^2", nullptr, "a", -1.0, 0.1, 100.0); } + { + constexpr int numberOfRoots = 1; + Coordinate2D roots[numberOfRoots] = { + Coordinate2D(0.0, 0.0)}; + assert_points_of_interest_are(PointOfInterestType::Root, numberOfRoots, roots, "a^2", nullptr, "a", 100.0, -0.1, -1.0); + } { constexpr int numberOfRoots = 2; Coordinate2D roots[numberOfRoots] = { @@ -144,18 +208,37 @@ QUIZ_CASE(poincare_function_root) { Coordinate2D(2.0, 0.0)}; assert_points_of_interest_are(PointOfInterestType::Root, numberOfRoots, roots, "a^2-4", nullptr, "a", -5.0, 0.1, 100.0); } + { + constexpr int numberOfRoots = 2; + Coordinate2D roots[numberOfRoots] = { + Coordinate2D(2.0, 0.0), + Coordinate2D(-2.0, 0.0)}; + assert_points_of_interest_are(PointOfInterestType::Root, numberOfRoots, roots, "a^2-4", nullptr, "a", 100.0, -0.1, -5.0); + } { constexpr int numberOfRoots = 1; Coordinate2D roots[numberOfRoots] = { Coordinate2D(NAN, 0.0)}; assert_points_of_interest_are(PointOfInterestType::Root, numberOfRoots, roots, "3", nullptr, "a", -1.0, 0.1, 100.0); } + { + constexpr int numberOfRoots = 1; + Coordinate2D roots[numberOfRoots] = { + Coordinate2D(NAN, 0.0)}; + assert_points_of_interest_are(PointOfInterestType::Root, numberOfRoots, roots, "3", nullptr, "a", 100.0, -0.1, -1.0); + } { constexpr int numberOfRoots = 1; Coordinate2D roots[numberOfRoots] = { Coordinate2D(-0.9, 0.0)}; assert_points_of_interest_are(PointOfInterestType::Root, numberOfRoots, roots, "0", nullptr, "a", -1.0, 0.1, 100.0); } + { + constexpr int numberOfRoots = 1; + Coordinate2D roots[numberOfRoots] = { + Coordinate2D(99.8, 0.0)}; + assert_points_of_interest_are(PointOfInterestType::Root, numberOfRoots, roots, "0", nullptr, "a", 100.0, -0.1, -1.0); + } } QUIZ_CASE(poincare_function_intersection) { @@ -165,6 +248,12 @@ QUIZ_CASE(poincare_function_intersection) { Coordinate2D(NAN, NAN)}; assert_points_of_interest_are(PointOfInterestType::Intersection, numberOfIntersections, intersections, "cos(a)", "2", "a", -1.0, 0.1, 500.0); } + { + constexpr int numberOfIntersections = 1; + Coordinate2D intersections[numberOfIntersections] = { + Coordinate2D(NAN, NAN)}; + assert_points_of_interest_are(PointOfInterestType::Intersection, numberOfIntersections, intersections, "cos(a)", "2", "a", 500.0, -0.1, -1.0); + } { constexpr int numberOfIntersections = 2; Coordinate2D intersections[numberOfIntersections] = { @@ -172,6 +261,13 @@ QUIZ_CASE(poincare_function_intersection) { Coordinate2D(360.0, 1.0)}; assert_points_of_interest_are(PointOfInterestType::Intersection, numberOfIntersections, intersections, "cos(a)", "1", "a", -1.0, 0.1, 500.0); } + { + constexpr int numberOfIntersections = 2; + Coordinate2D intersections[numberOfIntersections] = { + Coordinate2D(360.0, 1.0), + Coordinate2D(0.0, 1.0)}; + assert_points_of_interest_are(PointOfInterestType::Intersection, numberOfIntersections, intersections, "cos(a)", "1", "a", 500.0, -0.1, -1.0); + } { constexpr int numberOfIntersections = 3; Coordinate2D intersections[numberOfIntersections] = { @@ -180,4 +276,12 @@ QUIZ_CASE(poincare_function_intersection) { Coordinate2D(450.0, 0.0)}; assert_points_of_interest_are(PointOfInterestType::Intersection, numberOfIntersections, intersections, "cos(a)", "0", "a", -1.0, 0.1, 500.0); } + { + constexpr int numberOfIntersections = 3; + Coordinate2D intersections[numberOfIntersections] = { + Coordinate2D(450.0, 0.0), + Coordinate2D(270.0, 0.0), + Coordinate2D(90.0, 0.0)}; + assert_points_of_interest_are(PointOfInterestType::Intersection, numberOfIntersections, intersections, "cos(a)", "0", "a", 500.0, -0.1, -1.0); + } }