Update unit tests.

This commit is contained in:
iabdalkader 2020-02-01 22:09:04 +02:00
parent 0e6652a3be
commit 5a6903e4e6
4 changed files with 11 additions and 7 deletions

View File

@ -1,4 +1,4 @@
def unittest(data_path, temp_path):
import image
gs = image.rgb_to_grayscale((120, 200, 120))
return (gs == 167)
return (abs(167-gs) < 2)

View File

@ -2,4 +2,4 @@ def unittest(data_path, temp_path):
import image
img = image.Image("unittest/data/shapes.ppm", copy_to_fb=True)
circles = img.find_circles(threshold = 5000, x_margin = 30, y_margin = 30, r_margin = 30)
return len(circles) == 1 and circles[0][0:] == (118, 56, 22, 5829)
return len(circles) == 1 and circles[0][0:-1] == (118, 56, 22)

View File

@ -3,7 +3,11 @@ def unittest(data_path, temp_path):
img = image.Image("unittest/data/shapes.ppm", copy_to_fb=True)
lines = img.find_lines(threshold = 10000, theta_margin = 25, rho_margin = 25)
return len(lines) == 4 and\
lines[0][0:] == (22, 0, 22, 119, 119, 17340, 0, 22) and\
lines[1][0:] == (0, 39, 159, 39, 159, 17340, 90, 39) and\
lines[2][0:] == (57, 0, 57, 119, 119, 17340, 0, 57) and\
lines[3][0:] == (0, 75, 159, 75, 159, 21420, 90, 75)
lines[0][0:-3] == (22, 0, 22, 119, 119) and\
lines[1][0:-3] == (0, 39, 159, 39, 159) and\
lines[2][0:-3] == (57, 0, 57, 119, 119) and\
lines[3][0:-3] == (0, 75, 159, 75, 159) and\
lines[0][-2:] == (0, 22) and\
lines[1][-2:] == (90, 39) and\
lines[2][-2:] == (0, 57) and\
lines[3][-2:] == (90, 75)

View File

@ -2,4 +2,4 @@ def unittest(data_path, temp_path):
import image
img = image.Image("unittest/data/shapes.ppm", copy_to_fb=True)
rects = img.find_rects(threshold = 50000)
return len(rects) == 1 and rects[0][0:] == (23, 39, 35, 36, 146566)
return len(rects) == 1 and rects[0][0:-1] == (23, 39, 35, 36)