Back to index

python3.2  3.2.2
Classes | Functions
ctypes.test.test_strings Namespace Reference

Classes

class  StringArrayTestCase
class  WStringArrayTestCase
 print BUF.from_param(c_char_p("python")) print BUF.from_param(BUF(*"pyth")) More...
class  StringTestCase
class  WStringTestCase
 def test_perf(self): check_perf() More...

Functions

def test_param_2
 print c_char_p.from_param(buf)
def XX_test_initialized_strings
 self.assertTrue(c_string(2).value == "") self.assertTrue(c_string(2).raw == "\000\000")
def XX_test_toolong
def run_test
def check_perf

Function Documentation

Definition at line 204 of file test_strings.py.

00204 
00205 def check_perf():
00206     # Construct 5 objects
00207 
00208     REP = 200000
00209 
00210     run_test(REP, "c_string(None)", c_string, None)
00211     run_test(REP, "c_string('abc')", c_string, 'abc')
00212 
00213 # Python 2.3 -OO, win2k, P4 700 MHz:
00214 #
00215 #      c_string(None): 1.75 us
00216 #     c_string('abc'): 2.74 us
00217 
00218 # Python 2.2 -OO, win2k, P4 700 MHz:
00219 #
00220 #      c_string(None): 2.95 us
00221 #     c_string('abc'): 3.67 us
00222 

Here is the call graph for this function:

def ctypes.test.test_strings.run_test (   rep,
  msg,
  func,
  arg 
)

Definition at line 195 of file test_strings.py.

00195 
00196 def run_test(rep, msg, func, arg):
00197     items = range(rep)
00198     from time import clock
00199     start = clock()
00200     for i in items:
00201         func(arg); func(arg); func(arg); func(arg); func(arg)
00202     stop = clock()
00203     print("%20s: %.2f us" % (msg, ((stop-start)*1e6/5/rep)))

Here is the caller graph for this function:

print c_char_p.from_param(buf)

Definition at line 50 of file test_strings.py.

00050 
00051     def test_param_2(self):
00052         BUF = c_char * 4
        buf = BUF()

self.assertTrue(c_string(2).value == "") self.assertTrue(c_string(2).raw == "\000\000")

Definition at line 128 of file test_strings.py.

00128 
00129     def XX_test_initialized_strings(self):
00130 
00131         self.assertTrue(c_string("ab", 4).raw[:2] == "ab")
00132         self.assertTrue(c_string("ab", 4).raw[:2:] == "ab")
00133         self.assertTrue(c_string("ab", 4).raw[:2:-1] == "ba")
00134         self.assertTrue(c_string("ab", 4).raw[:2:2] == "a")
00135         self.assertTrue(c_string("ab", 4).raw[-1] == "\000")
00136         self.assertTrue(c_string("ab", 2).raw == "a\000")

Here is the call graph for this function:

Definition at line 137 of file test_strings.py.

00137 
00138     def XX_test_toolong(self):
00139         cs = c_string("abcdef")
00140         # Much too long string:
00141         self.assertRaises(ValueError, setattr, cs, "value", "123456789012345")
00142 
00143         # One char too long values:
00144         self.assertRaises(ValueError, setattr, cs, "value", "1234567")

Here is the call graph for this function: