Skip to content

Commit

Permalink
Merge pull request #94 from FoamyGuy/png_load_test
Browse files Browse the repository at this point in the history
load png test case
  • Loading branch information
tannewt authored Jan 17, 2025
2 parents 3bf2a56 + bf6f32d commit 95b5c09
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
Binary file added tests/test_png.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions tests/test_png.png.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# SPDX-FileCopyrightText: 2025 Tim Cocks for Adafruit Industries
# SPDX-License-Identifier: MIT
24 changes: 24 additions & 0 deletions tests/test_png_load.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SPDX-FileCopyrightText: 2025 Tim Cocks for Adafruit Industries
# SPDX-License-Identifier: MIT

from unittest import TestCase

from adafruit_imageload import load


class TestPngLoad(TestCase):
def test_expected_pixels(self):
img, palette = load("tests/test_png.png")
self.assertEqual(len(palette), 3)
self.assertEqual(img.width, 4)
self.assertEqual(img.height, 4)

self.assertEqual(img[0, 0], 0)
self.assertEqual(img[1, 0], 2)
self.assertEqual(img[2, 0], 1)
self.assertEqual(img[3, 0], 0)

self.assertEqual(img[0, 3], 0)
self.assertEqual(img[1, 3], 2)
self.assertEqual(img[2, 3], 1)
self.assertEqual(img[3, 3], 0)

0 comments on commit 95b5c09

Please sign in to comment.