pygame / test / color_test.py

Diff from to

test/color_test.py

         c1_frompickle = pickle.loads(pickle_string)
         self.assertEqual(c1,c1_frompickle) 
 
+################################################################################
+# only available if ctypes module is also available
+
+    def test_arraystruct(self):
+        import pygame.tests.test_utils.arrinter as ai
+        import ctypes as ct
+
+        c_byte_p = ct.POINTER(ct.c_byte)
+        c = pygame.Color(5, 7, 13, 23)
+        flags = (ai.PAI_CONTIGUOUS | ai.PAI_FORTRAN |
+                 ai.PAI_ALIGNED | ai.PAI_NOTSWAPPED)
+        for i in range(1, 5):
+            c.set_length(i)
+            inter = ai.ArrayInterface(c)
+            self.assertEqual(inter.two, 2)
+            self.assertEqual(inter.nd, 1)
+            self.assertEqual(inter.typekind, 'u')
+            self.assertEqual(inter.itemsize, 1)
+            self.assertEqual(inter.flags, flags)
+            self.assertEqual(inter.shape[0], i)
+            self.assertEqual(inter.strides[0], 1)
+            data = ct.cast(inter.data, c_byte_p)
+            for j in range(i):
+                self.assertEqual(data[j], c[j])
+
+    try:
+        import ctypes
+    except ImportError:
+        del test_arraystruct
 
 
 ################################################################################
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.