5 #include <rive/math/aabb.hpp>
6 #include <rive/math/raw_path.hpp>
7 #include "no_op_renderer.hpp"
14 TEST_CASE("rawpath-basics", "[rawpath]") {
17 REQUIRE(path.empty());
18 REQUIRE(path.bounds() == AABB{0, 0, 0, 0});
21 REQUIRE(!path.empty());
22 REQUIRE(path.bounds() == AABB{1, 2, 1, 2});
25 REQUIRE(path.empty());
26 REQUIRE(path.bounds() == AABB{0, 0, 0, 0});
31 REQUIRE(!path.empty());
32 REQUIRE(path.bounds() == AABB{-1, -2, 3, 5});
35 TEST_CASE("rawpath-add-helpers", "[rawpath]") {
38 path.addRect({1, 1, 5, 6});
39 REQUIRE(!path.empty());
40 REQUIRE(path.bounds() == AABB{1, 1, 5, 6});
41 REQUIRE(path.points().size() == 4);
42 REQUIRE(path.verbs().size() == 5); // move, line, line, line, close
45 path.addOval({0, 0, 3, 6});
46 REQUIRE(!path.empty());
47 REQUIRE(path.bounds() == AABB{0, 0, 3, 6});
48 REQUIRE(path.points().size() == 13);
49 REQUIRE(path.verbs().size() == 6); // move, cubic, cubic, cubic, cubic, close
57 constexpr auto size = sizeof(pts) / sizeof(pts[0]);
59 for (auto isClosed : {false, true}) {
61 path.addPoly({pts, size}, isClosed);
62 REQUIRE(path.bounds() == AABB{1, -100, 100, 5});
63 REQUIRE(path.points().size() == size);
64 REQUIRE(path.verbs().size() == size + isClosed);
66 for (size_t i = 0; i < size; ++i) {
67 REQUIRE(path.points()[i] == pts[i]);
69 REQUIRE(path.verbs()[0] == PathVerb::move);
70 for (size_t i = 1; i < size; ++i) {
71 REQUIRE(path.verbs()[i] == PathVerb::line);
74 REQUIRE(path.verbs()[size] == PathVerb::close);