Skip to content

Commit b7d665c

Browse files
committed
Add test for clip_color
1 parent 7bd1ab0 commit b7d665c

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

pilgram/css/blending/tests/test_nonseparable.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
from pilgram import util
2222
from pilgram.css.blending.nonseparable import _min3, _max3
23+
from pilgram.css.blending.nonseparable import _clip_color
2324
from pilgram.css.blending.nonseparable import lum, lum_im, set_lum
2425
from pilgram.css.blending.nonseparable import sat
2526

@@ -43,7 +44,18 @@ def test_max3():
4344

4445

4546
def test_clip_color():
46-
pass # TODO
47+
im = util.fill((1, 1), [0, 128, 255])
48+
r, g, b = im.split()
49+
bands = ImageMath.eval(
50+
'clip_color((float(r - 64), float(g), float(b + 64)))',
51+
clip_color=_clip_color, r=r, g=g, b=b)
52+
53+
expected = [
54+
[pytest.approx(25.70517158047366, 1e-6)],
55+
[pytest.approx(106.8796587856024, 1e-6)],
56+
[pytest.approx(187.63136220320442, 1e-6)],
57+
]
58+
assert [list(band.im.getdata()) for band in bands] == expected
4759

4860

4961
def test_lum():

0 commit comments

Comments
 (0)