diff --git a/apps/graph/test/caching.cpp b/apps/graph/test/caching.cpp index bef20e35d..5448699fc 100644 --- a/apps/graph/test/caching.cpp +++ b/apps/graph/test/caching.cpp @@ -10,7 +10,7 @@ namespace Graph { bool floatEquals(float a, float b, float tolerance = 1.f/static_cast(Ion::Display::Height)) { /* The default value for the tolerance is chosen so that the error introduced * by caching would not typically be visible on screen. */ - return a == b || std::abs(a - b) <= tolerance * std::abs(a + b) / 2.f || (std::isnan(a) && std::isnan(b)); + return (std::isnan(a) && std::isnan(b)) || IsApproximatelyEqual(a, b, tolerance, 0.); } void assert_check_cartesian_cache_against_function(ContinuousFunction * function, ContinuousFunctionCache * cache, Context * context, float tMin) { diff --git a/apps/graph/test/helper.h b/apps/graph/test/helper.h index 69fe91edb..727022bf6 100644 --- a/apps/graph/test/helper.h +++ b/apps/graph/test/helper.h @@ -2,6 +2,7 @@ #define APPS_GRAPH_TEST_HELPER_H #include "../app.h" +#include "../../poincare/test/helper.h" using namespace Poincare; using namespace Shared; @@ -12,10 +13,6 @@ constexpr ContinuousFunction::PlotType Cartesian = ContinuousFunction::PlotType: constexpr ContinuousFunction::PlotType Polar = ContinuousFunction::PlotType::Polar; constexpr ContinuousFunction::PlotType Parametric = ContinuousFunction::PlotType::Parametric; -constexpr Preferences::AngleUnit Radian = Preferences::AngleUnit::Radian; -constexpr Preferences::AngleUnit Degree = Preferences::AngleUnit::Degree; -constexpr Preferences::AngleUnit Gradian = Preferences::AngleUnit::Gradian; - ContinuousFunction * addFunction(const char * definition, ContinuousFunction::PlotType type, ContinuousFunctionStore * store, Context * context); } diff --git a/apps/graph/test/ranges.cpp b/apps/graph/test/ranges.cpp index 85c6605df..5056fd343 100644 --- a/apps/graph/test/ranges.cpp +++ b/apps/graph/test/ranges.cpp @@ -8,6 +8,9 @@ namespace Graph { class AdHocGraphController : public InteractiveCurveViewRangeDelegate { public: + /* These margins are obtained from instance methods of the various derived + * class of SimpleInteractiveCurveViewController. As we cannot create an + * instance of this class here, we define those directly. */ static constexpr float k_topMargin = 0.068f; static constexpr float k_bottomMargin = 0.132948f; static constexpr float k_leftMargin = 0.04f; @@ -30,7 +33,7 @@ private: }; bool float_equal(float a, float b, float tolerance = 10.f * FLT_EPSILON) { - return std::fabs(a - b) <= tolerance * std::fabs(a + b); + return IsApproximatelyEqual(a, b, tolerance, 0.); } template diff --git a/poincare/test/zoom.cpp b/poincare/test/zoom.cpp index 66d34c463..2f43edfb7 100644 --- a/poincare/test/zoom.cpp +++ b/poincare/test/zoom.cpp @@ -7,7 +7,7 @@ using namespace Poincare; // When adding the graph window margins, this ratio gives an orthonormal window constexpr float NormalRatio = 0.442358822; -constexpr float StandardTolerance = 10.f * FLT_EPSILON; +constexpr float StandardTolerance = 50.f * FLT_EPSILON; class ParametersPack { public: @@ -35,7 +35,7 @@ float evaluate_expression(float x, Context * context, const void * auxiliary) { bool float_equal(float a, float b, float tolerance = StandardTolerance) { assert(std::isfinite(tolerance)); return !(std::isnan(a) || std::isnan(b)) - && std::fabs(a - b) <= tolerance * std::fabs(a + b); + && IsApproximatelyEqual(a, b, tolerance, 0.); } bool range1D_matches(float min, float max, float targetMin, float targetMax, float tolerance = StandardTolerance) {