From 5056e07f378972001fa891d6f20c56cdcee27835 Mon Sep 17 00:00:00 2001 From: drewcassidy Date: Sat, 6 Mar 2021 22:41:42 -0800 Subject: [PATCH] Add unit tests --- tests/test_rgbcx.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/test_rgbcx.py diff --git a/tests/test_rgbcx.py b/tests/test_rgbcx.py new file mode 100644 index 0000000..ee3dbde --- /dev/null +++ b/tests/test_rgbcx.py @@ -0,0 +1,20 @@ +import unittest +import python_rgbcx + + +class MyTestCase(unittest.TestCase): + def setUp(self): + self.bc1_encoder = python_rgbcx.BC1Encoder() + self.image = b'\x00\x00\x00\xFF\xFF\xFF\xFF\xFF\x55\x55\x55\xFF\xAA\xAA\xAA\xFF' \ + b'\x00\x00\x00\xFF\xFF\xFF\xFF\xFF\x55\x55\x55\xFF\xAA\xAA\xAA\xFF' \ + b'\x00\x00\x00\xFF\xFF\xFF\xFF\xFF\x55\x55\x55\xFF\xAA\xAA\xAA\xFF' \ + b'\x00\x00\x00\xFF\xFF\xFF\xFF\xFF\x55\x55\x55\xFF\xAA\xAA\xAA\xFF' + + def test_block_size(self): + out = self.bc1_encoder.encode_image(self.image, 4, 4) + self.assertEqual(self.bc1_encoder.block_size, 8, 'incorrect reported block size') + self.assertEqual(len(out), 8, 'incorrect returned block size') + + +if __name__ == '__main__': + unittest.main()