Back to index

python3.2  3.2.2
Public Member Functions
ctypes.test.test_strings.StringTestCase Class Reference

List of all members.

Public Member Functions

def XX_test_basic_strings
def XX_test_sized_strings

Detailed Description

Definition at line 84 of file test_strings.py.


Member Function Documentation

Definition at line 85 of file test_strings.py.

00085 
00086     def XX_test_basic_strings(self):
00087         cs = c_string("abcdef")
00088 
00089         # Cannot call len on a c_string any longer
00090         self.assertRaises(TypeError, len, cs)
00091         self.assertEqual(sizeof(cs), 7)
00092 
00093         # The value property is the string up to the first terminating NUL.
00094         self.assertEqual(cs.value, "abcdef")
00095         self.assertEqual(c_string("abc\000def").value, "abc")
00096 
00097         # The raw property is the total buffer contents:
00098         self.assertEqual(cs.raw, "abcdef\000")
00099         self.assertEqual(c_string("abc\000def").raw, "abc\000def\000")
00100 
00101         # We can change the value:
00102         cs.value = "ab"
00103         self.assertEqual(cs.value, "ab")
00104         self.assertEqual(cs.raw, "ab\000\000\000\000\000")
00105 
00106         cs.raw = "XY"
00107         self.assertEqual(cs.value, "XY")
00108         self.assertEqual(cs.raw, "XY\000\000\000\000\000")
00109 
00110         self.assertRaises(TypeError, c_string, "123")

Here is the call graph for this function:

Definition at line 111 of file test_strings.py.

00111 
00112     def XX_test_sized_strings(self):
00113 
00114         # New in releases later than 0.4.0:
00115         self.assertRaises(TypeError, c_string, None)
00116 
00117         # New in releases later than 0.4.0:
00118         # c_string(number) returns an empty string of size number
00119         self.assertTrue(len(c_string(32).raw) == 32)
00120         self.assertRaises(ValueError, c_string, -1)
00121         self.assertRaises(ValueError, c_string, 0)
00122 
        # These tests fail, because it is no longer initialized

Here is the call graph for this function:


The documentation for this class was generated from the following file: