From c53257383c97ac29b5b4f9f733eda939c142e1bc Mon Sep 17 00:00:00 2001 From: Magnus Jacobsson Date: Wed, 17 Aug 2022 14:57:43 +0200 Subject: [PATCH] tests: SvgAnalyzer: SVGPoint: add checking of relative position to other point --- tests/svg_element.cpp | 18 ++++++++++++++++++ tests/svg_element.h | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/tests/svg_element.cpp b/tests/svg_element.cpp index 0d150c7ff..0209e95bf 100644 --- a/tests/svg_element.cpp +++ b/tests/svg_element.cpp @@ -396,3 +396,21 @@ std::string_view SVG::tag(SVGElementType type) { } UNREACHABLE(); } + +bool SVG::SVGPoint::is_higher_than(const SVGPoint &other) const { + // SVG uses inverted y axis, so smaller is higher + return y < other.y; +} + +bool SVG::SVGPoint::is_lower_than(const SVGPoint &other) const { + // SVG uses inverted y axis, so larger is lower + return y > other.y; +} + +bool SVG::SVGPoint::is_more_left_than(const SVGPoint &other) const { + return x < other.x; +} + +bool SVG::SVGPoint::is_more_right_than(const SVGPoint &other) const { + return x > other.x; +} diff --git a/tests/svg_element.h b/tests/svg_element.h index 2837496dc..11c3f5fe4 100644 --- a/tests/svg_element.h +++ b/tests/svg_element.h @@ -11,6 +11,10 @@ namespace SVG { struct SVGPoint { double x; double y; + bool is_higher_than(const SVGPoint &other) const; + bool is_lower_than(const SVGPoint &other) const; + bool is_more_left_than(const SVGPoint &other) const; + bool is_more_right_than(const SVGPoint &other) const; }; struct SVGRect { -- 2.40.0