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):
|
||||
|
||||
def test_8u(self):
|
||||
im = Image.new('RGB', (512, 9), (0, 64, 255))
|
||||
im = im.resize((9, 512), Image.LANCZOS)
|
||||
r, g, b = im.split()
|
||||
def make_case(self, mode, fill):
|
||||
im = Image.new(mode, (512, 9), fill)
|
||||
return (im.resize((9, 512), Image.LANCZOS), im.load()[0, 0])
|
||||
|
||||
for channel, color in [(r, 0), (g, 64), (b, 255)]:
|
||||
def run_cases(self, cases):
|
||||
for channel, color in cases:
|
||||
px = channel.load()
|
||||
for x in range(channel.size[0]):
|
||||
for y in range(channel.size[1]):
|
||||
|
@ -166,6 +166,26 @@ class CoreResampleConsistencyTest(PillowTestCase):
|
|||
px[x, y], color, (x, y))
|
||||
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__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Reference in New Issue
Block a user