Commits

illume committed 2b8405e

Started on a unittest for Mask.

Comments (0)

Files changed (2)

 #
 #
 May 9, 2007
-    Windows bitmap copy/paste is working for scrap.
+    Windows image copy/paste is working for scrap.
+    Adding bitmask code from Ulf Ekström - for pixelperfect collision.
+      Still need to get unittest, documentation and some more methods added.
+      There's a unittest with some problems checked in.
 
 May 2, 2007
     [BUG] fromstring,tostring work for alpha. Thanks Brian Fisher.

test/mask_test.py

+
+import unittest
+import pygame
+
+
+class MaskTest( unittest.TestCase ):
+    
+    def test_mask_access( self ):
+        """ 
+        """
+        m = pygame.Mask((10,10))
+        m.set_at((0,0), 1)
+        self.assertEqual(m.get_at((0,0)), 1)
+        m.set_at((9,0), 1)
+        self.assertEqual(m.get_at((9,0)), 1)
+
+        #s = pygame.Surface((10,10))
+        #s.set_at((1,0), (0, 0, 1, 255))
+        #self.assertEqual(s.get_at((1,0)), (0, 0, 1, 255))
+        #s.set_at((-1,0), (0, 0, 1, 255))
+
+
+
+        # out of bounds, should get IndexError
+        m.get_at((-1,0))
+        m.set_at((-1,0), 1)
+        m.set_at((10,0), 1)
+        m.set_at((0,10), 1)
+
+
+
+
+if __name__ == '__main__':
+    unittest.main()