coverage: improve leptonic; don't create objects with null pointers

This commit is contained in:
James R. Barlow
2018-11-02 01:10:10 -07:00
parent 64c9ede979
commit 3be02e1e8d
2 changed files with 58 additions and 3 deletions
+7 -2
View File
@@ -139,6 +139,8 @@ class Pix:
"""
def __init__(self, pix):
if not pix:
raise ValueError('NULL box')
self._pix = ffi.gc(pix, Pix._pix_destroy)
def __repr__(self):
@@ -403,8 +405,6 @@ class Pix:
display,
pdfdir))
print(repr(cropbox))
cropped_pix = lept.pixClipRectangle(
self._pix,
cropbox._box,
@@ -549,8 +549,11 @@ class Box:
"""
def __init__(self, box):
if not box:
raise ValueError('NULL box')
self._box = ffi.gc(box, Box._box_destroy)
def __repr__(self):
if self._box:
return '<leptonica.Box x={0} y={1} w={2} h={3}>'.format(
@@ -583,6 +586,8 @@ class BoxArray:
"""Wrapper around Leptonica's BOXA (Array of BOX) objects."""
def __init__(self, boxa):
if not boxa:
raise ValueError('NULL boxa')
self._boxa = ffi.gc(boxa, BoxArray._boxa_destroy)
def __repr__(self):