1 #include <gtest/gtest.h>
4 class VPathTest : public ::testing::Test {
8 pathRect.addRect({-10, -20, 100, 100});
9 pathRoundRect.addRoundRect({0, 0, 100, 100}, 5, 5);
10 pathRoundRectZeroCorner.addRoundRect({0, 0, 100, 100}, 0, 0);
11 pathRoundRectHalfCircle.addRoundRect({0, 0, 100, 100}, 60, 60);
12 pathOval.addOval({0,0,100,50});
13 pathOvalCircle.addOval({0,0,100,100});
14 pathCircle.addCircle(0, 0, 100);
15 pathCircleZeroRadius.addCircle(10, 10, 0);
16 pathPolygon.addPolygon(10, 50, 5, 0, 0, 0);
17 pathPolystar.addPolystar(10, 50, 100, 7, 14, 0, 0, 0);
18 pathPolygonZero.addPolygon(10, 50, 0, 0, 0, 0);
19 pathPolystarZero.addPolystar(10, 50, 100, 0, 0, 0, 0, 0);
29 VPath pathRoundRectZeroCorner;
30 VPath pathRoundRectHalfCircle;
34 VPath pathCircleZeroRadius;
37 VPath pathPolygonZero;
38 VPath pathPolystarZero;
41 TEST_F(VPathTest, emptyPath) {
42 ASSERT_EQ(sizeof(pathEmpty), sizeof(void *));
43 ASSERT_TRUE(pathEmpty.empty());
44 ASSERT_FALSE(pathEmpty.segments());
45 ASSERT_EQ(pathEmpty.segments() , 0);
46 ASSERT_EQ(pathEmpty.elements().size() , 0);
47 ASSERT_EQ(pathEmpty.elements().capacity() , pathEmpty.elements().size());
48 ASSERT_EQ(pathEmpty.points().size() , 0);
49 ASSERT_EQ(pathEmpty.points().capacity() , pathEmpty.points().size());
52 TEST_F(VPathTest, reset) {
54 ASSERT_TRUE(pathRect.empty());
55 ASSERT_EQ(pathRect.segments() , 0);
56 ASSERT_GE(pathRect.points().capacity(), 1);
57 ASSERT_GE(pathRect.elements().capacity(), 1);
60 TEST_F(VPathTest, reserve) {
61 pathEmpty.reserve(10, 10);
62 ASSERT_EQ(pathEmpty.points().capacity(), 10);
63 ASSERT_GE(pathEmpty.elements().capacity(), 10);
64 ASSERT_EQ(pathEmpty.segments() , 0);
65 ASSERT_EQ(pathEmpty.points().size(), 0);
66 ASSERT_GE(pathEmpty.elements().size(), 0);
69 TEST_F(VPathTest, clone) {
71 pathClone.clone(pathOval);
72 ASSERT_EQ(pathClone.segments(), pathOval.segments());
73 ASSERT_EQ(pathClone.points().size(), pathOval.points().size());
74 ASSERT_NE(pathClone.points().data(), pathOval.points().data());
75 ASSERT_EQ(pathClone.elements().size(), pathOval.elements().size());
76 ASSERT_NE(pathClone.elements().data(), pathOval.elements().data());
79 TEST_F(VPathTest, copyOnWrite) {
82 ASSERT_EQ(pathCopy.segments(), pathOval.segments());
83 ASSERT_EQ(pathCopy.points().size(), pathOval.points().size());
84 ASSERT_EQ(pathCopy.points().data(), pathOval.points().data());
85 ASSERT_EQ(pathCopy.elements().size(), pathOval.elements().size());
86 ASSERT_EQ(pathCopy.elements().data(), pathOval.elements().data());
89 TEST_F(VPathTest, addRect) {
90 ASSERT_FALSE(pathRect.empty());
91 ASSERT_EQ(pathRect.segments() , 1);
92 ASSERT_EQ(pathRect.elements().capacity() , pathRect.elements().size());
93 ASSERT_EQ(pathRect.points().capacity() , pathRect.points().size());
96 TEST_F(VPathTest, addRect_N) {
97 pathEmpty.addRect({});
98 ASSERT_TRUE(pathEmpty.empty());
99 ASSERT_EQ(pathEmpty.segments() , 0);
102 TEST_F(VPathTest, addRoundRect) {
103 ASSERT_FALSE(pathRoundRect.empty());
104 ASSERT_EQ(pathRoundRect.segments() , 1);
105 ASSERT_EQ(pathRoundRect.elements().capacity() , pathRoundRect.elements().size());
106 ASSERT_EQ(pathRoundRect.points().capacity() , pathRoundRect.points().size());
109 TEST_F(VPathTest, addRoundRectZeoCorner) {
110 ASSERT_FALSE(pathRoundRectZeroCorner.empty());
111 ASSERT_EQ(pathRoundRectZeroCorner.segments() , 1);
112 ASSERT_EQ(pathRoundRectZeroCorner.elements().size() , pathRect.elements().size());
113 ASSERT_EQ(pathRoundRectZeroCorner.elements().capacity() , pathRoundRectZeroCorner.elements().size());
114 ASSERT_EQ(pathRoundRectZeroCorner.points().size() , pathRect.points().size());
115 ASSERT_EQ(pathRoundRectZeroCorner.points().capacity() , pathRoundRectZeroCorner.points().size());
118 TEST_F(VPathTest, addRoundRectHalfCircle) {
119 ASSERT_FALSE(pathRoundRectHalfCircle.empty());
120 ASSERT_EQ(pathRoundRectHalfCircle.segments() , 1);
121 ASSERT_EQ(pathRoundRectHalfCircle.elements().capacity() , pathRoundRectHalfCircle.elements().size());
122 ASSERT_EQ(pathRoundRectHalfCircle.points().capacity() , pathRoundRectHalfCircle.points().size());
125 TEST_F(VPathTest, addOval) {
126 ASSERT_FALSE(pathOval.empty());
127 ASSERT_EQ(pathOval.segments() , 1);
128 ASSERT_EQ(pathOval.elements().capacity() , pathOval.elements().size());
129 ASSERT_EQ(pathOval.points().capacity() , pathOval.points().size());
132 TEST_F(VPathTest, addOvalCircle) {
133 ASSERT_FALSE(pathOvalCircle.empty());
134 ASSERT_EQ(pathOvalCircle.segments() , 1);
135 ASSERT_EQ(pathOvalCircle.elements().size() , pathOval.elements().size());
136 ASSERT_EQ(pathOvalCircle.elements().capacity() , pathOvalCircle.elements().size());
137 ASSERT_EQ(pathOvalCircle.points().size() , pathOval.points().size());
138 ASSERT_EQ(pathOvalCircle.points().capacity() , pathOvalCircle.points().size());
141 TEST_F(VPathTest, addCircle) {
142 ASSERT_FALSE(pathCircle.empty());
143 ASSERT_EQ(pathCircle.segments() , 1);
144 ASSERT_EQ(pathCircle.elements().size() , pathOval.elements().size());
145 ASSERT_EQ(pathCircle.elements().capacity() , pathCircle.elements().size());
146 ASSERT_EQ(pathCircle.points().size() , pathOval.points().size());
147 ASSERT_EQ(pathCircle.points().capacity() , pathCircle.points().size());
150 TEST_F(VPathTest, addCircleZeroRadius) {
151 ASSERT_TRUE(pathCircleZeroRadius.empty());
152 ASSERT_EQ(pathCircleZeroRadius.segments() , 0);
155 TEST_F(VPathTest, length) {
156 ASSERT_EQ(pathRect.length(), 400);
159 TEST_F(VPathTest, lengthEmptyPath) {
160 ASSERT_EQ(pathEmpty.length(), 0);
163 TEST_F(VPathTest, addPolygon) {
164 ASSERT_FALSE(pathPolygon.empty());
165 ASSERT_EQ(pathPolygon.segments() , 1);
166 ASSERT_EQ(pathPolygon.elements().size() , pathPolygon.elements().capacity());
167 ASSERT_EQ(pathPolygon.points().size() , pathPolygon.points().capacity());
170 TEST_F(VPathTest, addPolygonZeroRoundness) {
171 ASSERT_FALSE(pathPolygonZero.empty());
172 ASSERT_EQ(pathPolygonZero.segments() , 1);
173 ASSERT_EQ(pathPolygonZero.elements().size() , pathPolygonZero.elements().capacity());
174 ASSERT_EQ(pathPolygonZero.points().size() , pathPolygonZero.points().capacity());
177 TEST_F(VPathTest, addPolystar) {
178 ASSERT_FALSE(pathPolystar.empty());
179 ASSERT_EQ(pathPolystar.segments() , 1);
180 ASSERT_EQ(pathPolystar.elements().size() , pathPolystar.elements().capacity());
181 ASSERT_EQ(pathPolystar.points().size() , pathPolystar.points().capacity());
184 TEST_F(VPathTest, addPolystarZeroRoundness) {
185 ASSERT_FALSE(pathPolystarZero.empty());
186 ASSERT_EQ(pathPolystarZero.segments() , 1);
187 ASSERT_EQ(pathPolystarZero.elements().size() , pathPolystarZero.elements().capacity());
188 ASSERT_EQ(pathPolystarZero.points().size() , pathPolystarZero.points().capacity());