Back to index

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

List of all members.

Public Member Functions

def test
def test_c_buffer_value
def test_c_buffer_raw
def test_param_1

Detailed Description

Definition at line 4 of file test_strings.py.


Member Function Documentation

Definition at line 5 of file test_strings.py.

00005 
00006     def test(self):
00007         BUF = c_char * 4
00008 
00009         buf = BUF(b"a", b"b", b"c")
00010         self.assertEqual(buf.value, b"abc")
00011         self.assertEqual(buf.raw, b"abc\000")
00012 
00013         buf.value = b"ABCD"
00014         self.assertEqual(buf.value, b"ABCD")
00015         self.assertEqual(buf.raw, b"ABCD")
00016 
00017         buf.value = b"x"
00018         self.assertEqual(buf.value, b"x")
00019         self.assertEqual(buf.raw, b"x\000CD")
00020 
00021         buf[1] = b"Z"
00022         self.assertEqual(buf.value, b"xZCD")
00023         self.assertEqual(buf.raw, b"xZCD")
00024 
00025         self.assertRaises(ValueError, setattr, buf, "value", b"aaaaaaaa")
00026         self.assertRaises(TypeError, setattr, buf, "value", 42)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 37 of file test_strings.py.

00037 
00038     def test_c_buffer_raw(self):
00039         buf = c_buffer(32)
00040 
00041         buf.raw = memoryview(b"Hello, World")
00042         self.assertEqual(buf.value, b"Hello, World")
00043         self.assertRaises(TypeError, setattr, buf, "value", memoryview(b"abc"))
00044         self.assertRaises(ValueError, setattr, buf, "raw", memoryview(b"x" * 100))

Here is the call graph for this function:

Definition at line 27 of file test_strings.py.

00027 
00028     def test_c_buffer_value(self):
00029         buf = c_buffer(32)
00030 
00031         buf.value = b"Hello, World"
00032         self.assertEqual(buf.value, b"Hello, World")
00033 
00034         self.assertRaises(TypeError, setattr, buf, "value", memoryview(b"Hello, World"))
00035         self.assertRaises(TypeError, setattr, buf, "value", memoryview(b"abc"))
00036         self.assertRaises(ValueError, setattr, buf, "raw", memoryview(b"x" * 100))

Here is the call graph for this function:

Definition at line 45 of file test_strings.py.

00045 
00046     def test_param_1(self):
00047         BUF = c_char * 4
        buf = BUF()

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