@@ -85,74 +85,6 @@ def test_nonbmp(self):
8585 w = c_wchar (u )
8686 self .assertEqual (w .value , u )
8787
88- class StringTestCase (unittest .TestCase ):
89- @unittest .skip ('test disabled' )
90- def test_basic_strings (self ):
91- cs = c_string ("abcdef" )
92-
93- # Cannot call len on a c_string any longer
94- self .assertRaises (TypeError , len , cs )
95- self .assertEqual (sizeof (cs ), 7 )
96-
97- # The value property is the string up to the first terminating NUL.
98- self .assertEqual (cs .value , "abcdef" )
99- self .assertEqual (c_string ("abc\000 def" ).value , "abc" )
100-
101- # The raw property is the total buffer contents:
102- self .assertEqual (cs .raw , "abcdef\000 " )
103- self .assertEqual (c_string ("abc\000 def" ).raw , "abc\000 def\000 " )
104-
105- # We can change the value:
106- cs .value = "ab"
107- self .assertEqual (cs .value , "ab" )
108- self .assertEqual (cs .raw , "ab\000 \000 \000 \000 \000 " )
109-
110- cs .raw = "XY"
111- self .assertEqual (cs .value , "XY" )
112- self .assertEqual (cs .raw , "XY\000 \000 \000 \000 \000 " )
113-
114- self .assertRaises (TypeError , c_string , "123" )
115-
116- @unittest .skip ('test disabled' )
117- def test_sized_strings (self ):
118-
119- # New in releases later than 0.4.0:
120- self .assertRaises (TypeError , c_string , None )
121-
122- # New in releases later than 0.4.0:
123- # c_string(number) returns an empty string of size number
124- self .assertEqual (len (c_string (32 ).raw ), 32 )
125- self .assertRaises (ValueError , c_string , - 1 )
126- self .assertRaises (ValueError , c_string , 0 )
127-
128- # These tests fail, because it is no longer initialized
129- ## self.assertEqual(c_string(2).value, "")
130- ## self.assertEqual(c_string(2).raw, "\000\000")
131- self .assertEqual (c_string (2 ).raw [- 1 ], "\000 " )
132- self .assertEqual (len (c_string (2 ).raw ), 2 )
133-
134- @unittest .skip ('test disabled' )
135- def test_initialized_strings (self ):
136-
137- self .assertEqual (c_string ("ab" , 4 ).raw [:2 ], "ab" )
138- self .assertEqual (c_string ("ab" , 4 ).raw [:2 :], "ab" )
139- self .assertEqual (c_string ("ab" , 4 ).raw [:2 :- 1 ], "ba" )
140- self .assertEqual (c_string ("ab" , 4 ).raw [:2 :2 ], "a" )
141- self .assertEqual (c_string ("ab" , 4 ).raw [- 1 ], "\000 " )
142- self .assertEqual (c_string ("ab" , 2 ).raw , "a\000 " )
143-
144- @unittest .skip ('test disabled' )
145- def test_toolong (self ):
146- cs = c_string ("abcdef" )
147- # Much too long string:
148- self .assertRaises (ValueError , setattr , cs , "value" , "123456789012345" )
149-
150- # One char too long values:
151- self .assertRaises (ValueError , setattr , cs , "value" , "1234567" )
152-
153- @unittest .skip ('test disabled' )
154- def test_perf (self ):
155- check_perf ()
15688
15789@need_symbol ('c_wchar' )
15890class WStringTestCase (unittest .TestCase ):
@@ -208,25 +140,6 @@ def run_test(rep, msg, func, arg):
208140 stop = clock ()
209141 print ("%20s: %.2f us" % (msg , ((stop - start )* 1e6 / 5 / rep )))
210142
211- def check_perf ():
212- # Construct 5 objects
213-
214- REP = 200000
215-
216- run_test (REP , "c_string(None)" , c_string , None )
217- run_test (REP , "c_string('abc')" , c_string , 'abc' )
218-
219- # Python 2.3 -OO, win2k, P4 700 MHz:
220- #
221- # c_string(None): 1.75 us
222- # c_string('abc'): 2.74 us
223-
224- # Python 2.2 -OO, win2k, P4 700 MHz:
225- #
226- # c_string(None): 2.95 us
227- # c_string('abc'): 3.67 us
228-
229143
230144if __name__ == '__main__' :
231- ## check_perf()
232145 unittest .main ()
0 commit comments