forked from Vasistareddy/python-rlsa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_rlsa_unittest.py
62 lines (50 loc) · 1.86 KB
/
test_rlsa_unittest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import unittest
import numpy
from rlsa import rlsa
value = 2
Input = [[255, 0, 255, 0, 255], [0, 0, 255, 0, 0], [255, 255, 0, 0, 255]]
image = numpy.array([numpy.array(l) for l in Input])
out_h = [[255, 0, 0, 0, 255], [0, 0, 0, 0, 0], [255, 255, 0, 0, 255]]
out_h = numpy.array([numpy.array(l) for l in out_h])
out_v = [[255, 0, 255, 0, 255], [0, 0, 255, 0, 0], [255, 255, 0, 0, 255]]
out_v = numpy.array([numpy.array(l) for l in out_v])
out_h_v = [[255, 0, 0, 0, 255], [0, 0, 0, 0, 0], [255, 255, 0, 0, 255]]
out_h_v = numpy.array([numpy.array(l) for l in out_h_v])
class TestRLSA(unittest.TestCase):
def test_rlsa_hori(self):
"""
RLSA horizontal test
"""
self.assertEqual(rlsa(image.copy(), True, False, value).tolist(), out_h.tolist())
def test_rlsa_vert(self):
"""
RLSA vertical test
"""
self.assertEqual(rlsa(image.copy(), False, True, value).tolist(), out_v.tolist())
def test_rlsa_hori_vert(self):
"""
RLSA horizontal and vertical test
"""
self.assertEqual(rlsa(image.copy(), True, True, value).tolist(), out_h_v.tolist())
def test_bool(self):
"""
Bool Test
when both the boolean variable "horizontal" and "vertical" are False
output == input
"""
self.assertEqual(rlsa(image.copy(), False, False, value).tolist(), image.copy().tolist())
def test_value(self):
"""
Value Test
when the value is lessthan or equal to 1
output == input
"""
self.assertEqual(rlsa(image.copy(), True, False, -1).tolist(), image.copy().tolist())
def test_image(self):
"""
Image type Test
when the Input is not ndarray, it throws 'None'
"""
self.assertEqual(rlsa(list(image), True, False, value), None)
if __name__ == '__main__':
unittest.main()