MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / test_irect

Function test_irect

tests/test_geometry.py:71–121  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

69
70
71def test_irect():
72 p1 = pymupdf.Point(10, 20)
73 p2 = pymupdf.Point(100, 200)
74 p3 = pymupdf.Point(150, 250)
75 r = pymupdf.IRect(10, 20, 100, 200)
76 r_tuple = tuple(r)
77 assert tuple(pymupdf.IRect(p1, p2)) == r_tuple
78 assert tuple(pymupdf.IRect(p1, 100, 200)) == r_tuple
79 assert tuple(pymupdf.IRect(10, 20, p2)) == r_tuple
80 assert tuple(r.include_point(p3)) == (10, 20, 150, 250)
81 r = pymupdf.IRect(10, 20, 100, 200)
82 assert tuple(r.include_rect((100, 200, 110, 220))) == (10, 20, 110, 220)
83 r = pymupdf.IRect(10, 20, 100, 200)
84 # include empty rect makes no change
85 assert tuple(r.include_rect((0, 0, 0, 0))) == r_tuple
86 r = pymupdf.IRect()
87 for i in range(4):
88 r[i] = i + 1
89 assert r == pymupdf.IRect(1, 2, 3, 4)
90
91 failed = False
92 try:
93 r = pymupdf.IRect(1)
94 except:
95 failed = True
96 assert failed
97 failed = False
98 try:
99 r = pymupdf.IRect(1, 2, 3, 4, 5)
100 except:
101 failed = True
102 assert failed
103 failed = False
104 try:
105 r = pymupdf.IRect((1, 2, 3, 4, 5))
106 except:
107 failed = True
108 assert failed
109 failed = False
110 try:
111 r = pymupdf.IRect(1, 2, 3, "x")
112 except:
113 failed = True
114 assert failed
115 failed = False
116 try:
117 r = pymupdf.IRect()
118 r[5] = 1
119 except:
120 failed = True
121 assert failed
122
123
124def test_inversion():

Callers

nothing calls this directly

Calls 2

include_pointMethod · 0.95
include_rectMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…