mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-03-03 19:45:56 +03:00
tests for 32bit modes
This commit is contained in:
parent
9618ec98b8
commit
e47002dec3
|
@ -152,12 +152,12 @@ class TestImagingCoreResampleAccuracy(PillowTestCase):
|
||||||
|
|
||||||
class CoreResampleConsistencyTest(PillowTestCase):
|
class CoreResampleConsistencyTest(PillowTestCase):
|
||||||
|
|
||||||
def test_8u(self):
|
def make_case(self, mode, fill):
|
||||||
im = Image.new('RGB', (512, 9), (0, 64, 255))
|
im = Image.new(mode, (512, 9), fill)
|
||||||
im = im.resize((9, 512), Image.LANCZOS)
|
return (im.resize((9, 512), Image.LANCZOS), im.load()[0, 0])
|
||||||
r, g, b = im.split()
|
|
||||||
|
|
||||||
for channel, color in [(r, 0), (g, 64), (b, 255)]:
|
def run_cases(self, cases):
|
||||||
|
for channel, color in cases:
|
||||||
px = channel.load()
|
px = channel.load()
|
||||||
for x in range(channel.size[0]):
|
for x in range(channel.size[0]):
|
||||||
for y in range(channel.size[1]):
|
for y in range(channel.size[1]):
|
||||||
|
@ -166,6 +166,26 @@ class CoreResampleConsistencyTest(PillowTestCase):
|
||||||
px[x, y], color, (x, y))
|
px[x, y], color, (x, y))
|
||||||
self.assertEqual(px[x, y], color, message)
|
self.assertEqual(px[x, y], color, message)
|
||||||
|
|
||||||
|
def test_8u(self):
|
||||||
|
im, color = self.make_case('RGB', (0, 64, 255))
|
||||||
|
self.run_cases(zip(im.split(), color))
|
||||||
|
|
||||||
|
def test_32i(self):
|
||||||
|
self.run_cases([
|
||||||
|
self.make_case('I', 12),
|
||||||
|
self.make_case('I', 0x7fffffff),
|
||||||
|
self.make_case('I', -12),
|
||||||
|
self.make_case('I', -1 << 31),
|
||||||
|
])
|
||||||
|
|
||||||
|
def test_32f(self):
|
||||||
|
self.run_cases([
|
||||||
|
self.make_case('F', 1),
|
||||||
|
self.make_case('F', 3.40282306074e+38),
|
||||||
|
self.make_case('F', 1.175494e-38),
|
||||||
|
self.make_case('F', 1.192093e-07),
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user