From ad2c9526976d64c1172e3938753be06afac7f13b Mon Sep 17 00:00:00 2001 From: Alexander Date: Tue, 22 Aug 2017 00:52:42 +0300 Subject: [PATCH] Add more tests --- Tests/test_lib_pack.py | 18 ++++++++++++++++++ libImaging/Unpack.c | 1 - 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Tests/test_lib_pack.py b/Tests/test_lib_pack.py index dbd5501fc..a1118a6d9 100644 --- a/Tests/test_lib_pack.py +++ b/Tests/test_lib_pack.py @@ -96,6 +96,17 @@ class TestLibPack(PillowTestCase): self.assertEqual(unpack_1("1", "1;R", 170), (0, X, 0, X, 0, X, 0, X)) self.assertEqual(unpack_1("1", "1;IR", 170), (X, 0, X, 0, X, 0, X, 0)) + self.assertEqual(unpack("P", "P;1", 1), 0) + self.assertEqual(unpack("P", "P;2", 2), 0) + self.assertEqual(unpack("P", "P;2L", 2), 0) + self.assertEqual(unpack("P", "P;4", 4), 0) + self.assertEqual(unpack("P", "P;4L", 4), 0) + self.assertEqual(unpack("P", "P", 8), 1) + self.assertEqual(unpack("P", "P;R", 8), 128) + + self.assertEqual(unpack("PA", "PA", 16), (1, 2)) + self.assertEqual(unpack("PA", "PA;L", 16), (1, 2)) + self.assertEqual(unpack("L", "L;2", 1), 0) self.assertEqual(unpack("L", "L;4", 1), 0) self.assertEqual(unpack("L", "L", 1), 1) @@ -133,6 +144,8 @@ class TestLibPack(PillowTestCase): self.assertEqual(unpack("RGBA", "RGBA;15", 2), (8, 131, 0, 0)) self.assertEqual(unpack("RGBA", "BGRA;15", 2), (0, 131, 8, 0)) self.assertEqual(unpack("RGBA", "RGBA;4B", 2), (17, 0, 34, 0)) + self.assertEqual(unpack("RGBA", "RGBA;L", 4), (1, 2, 3, 4)) + self.assertEqual(unpack("RGBA", "LA", 2), (1, 1, 1, 2)) self.assertEqual(unpack("RGBA", "LA;16B", 4), (1, 1, 1, 3)) self.assertEqual(unpack("RGBA", "RGBA;16B", 8), (1, 3, 5, 7)) @@ -152,6 +165,11 @@ class TestLibPack(PillowTestCase): self.assertEqual(unpack("CMYK", "CMYK", 4), (1, 2, 3, 4)) self.assertEqual(unpack("CMYK", "CMYK;I", 4), (254, 253, 252, 251)) + self.assertEqual(unpack("CMYK", "C;I", 1), (254, 0, 0, 0)) + self.assertEqual(unpack("CMYK", "M;I", 1), (0, 254, 0, 0)) + self.assertEqual(unpack("CMYK", "Y;I", 1), (0, 0, 254, 0)) + self.assertEqual(unpack("CMYK", "K;I", 1), (0, 0, 0, 254)) + self.assertRaises(ValueError, lambda: unpack("L", "L", 0)) self.assertRaises(ValueError, lambda: unpack("RGB", "RGB", 2)) self.assertRaises(ValueError, lambda: unpack("CMYK", "CMYK", 2)) diff --git a/libImaging/Unpack.c b/libImaging/Unpack.c index 53b9d3d04..30740d259 100644 --- a/libImaging/Unpack.c +++ b/libImaging/Unpack.c @@ -859,7 +859,6 @@ ImagingUnpackLAB(UINT8* out, const UINT8* in, int pixels) int i; /* LAB triplets */ for (i = 0; i < pixels; i++) { - /* signed in outside world */ out[0] = in[0]; out[1] = in[1] ^ 128; /* signed in outside world */ out[2] = in[2] ^ 128;