Skip to content

Commit

Permalink
Merge 757a728 into 5477941
Browse files Browse the repository at this point in the history
  • Loading branch information
homm committed May 16, 2016
2 parents 5477941 + 757a728 commit 56a325a
Show file tree
Hide file tree
Showing 2 changed files with 265 additions and 169 deletions.
38 changes: 38 additions & 0 deletions Tests/test_image_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,43 @@ def test_invalid_size(self):
except ValueError:
self.assertTrue(True, "Should raise ValueError")


class CoreResampleConsistencyTest(PillowTestCase):

def make_case(self, mode, fill):
im = Image.new(mode, (512, 9), fill)
return (im.resize((9, 512), Image.LANCZOS), im.load()[0, 0])

def run_case(self, case):
channel, color = case
px = channel.load()
for x in range(channel.size[0]):
for y in range(channel.size[1]):
if px[x, y] != color:
message = "{} != {} for pixel {}".format(
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))
r, g, b = im.split()
self.run_case((r, color[0]))
self.run_case((g, color[1]))
self.run_case((b, color[2]))
self.run_case(self.make_case('L', 12))

def test_32i(self):
self.run_case(self.make_case('I', 12))
self.run_case(self.make_case('I', 0x7fffffff))
self.run_case(self.make_case('I', -12))
self.run_case(self.make_case('I', -1 << 31))

def test_32f(self):
self.run_case(self.make_case('F', 1))
self.run_case(self.make_case('F', 3.40282306074e+38))
self.run_case(self.make_case('F', 1.175494e-38))
self.run_case(self.make_case('F', 1.192093e-07))


if __name__ == '__main__':
unittest.main()
Loading

0 comments on commit 56a325a

Please sign in to comment.