File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed
Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -310,5 +310,30 @@ TEST(GeometryTest, RectIntersection) {
310310 }
311311}
312312
313+ TEST (GeometryTest, RectContainsPoint) {
314+ {
315+ // Origin is inclusive
316+ Rect r (100 , 100 , 100 , 100 );
317+ Point p (100 , 100 );
318+ ASSERT_TRUE (r.Contains (p));
319+ }
320+ {
321+ // Size is exclusive
322+ Rect r (100 , 100 , 100 , 100 );
323+ Point p (200 , 200 );
324+ ASSERT_FALSE (r.Contains (p));
325+ }
326+ {
327+ Rect r (100 , 100 , 100 , 100 );
328+ Point p (99 , 99 );
329+ ASSERT_FALSE (r.Contains (p));
330+ }
331+ {
332+ Rect r (100 , 100 , 100 , 100 );
333+ Point p (199 , 199 );
334+ ASSERT_TRUE (r.Contains (p));
335+ }
336+ }
337+
313338} // namespace testing
314339} // namespace impeller
Original file line number Diff line number Diff line change @@ -80,8 +80,8 @@ struct TRect {
8080 }
8181
8282 constexpr bool Contains (const TPoint<Type>& p) const {
83- return p.x >= origin.x && p.x <= size.width && p.y >= origin.y &&
84- p.y <= size.height ;
83+ return p.x >= origin.x && p.x < origin. x + size.width && p.y >= origin.y &&
84+ p.y < origin. y + size.height ;
8585 }
8686
8787 constexpr bool IsZero () const { return size.IsZero (); }
You can’t perform that action at this time.
0 commit comments