#NEWLINE# @ need_symbol ( 'c_wchar' ) #NEWLINE# def test_wchar_ptr( self ) : #NEWLINE# #INDENT# s = 'abcdefghijklmnopqrstuvwxyz\x00' #NEWLINE# dll = CDLL ( _ctypes_test . __file__ ) #NEWLINE# dll . my_wcsdup . restype = POINTER ( c_wchar ) #NEWLINE# dll . my_wcsdup . argtypes = ( POINTER ( c_wchar ) , ) #NEWLINE# dll . my_free . restype = None #NEWLINE# res = dll . my_wcsdup ( s ) #NEWLINE# self . assertEqual ( res [ : len ( s ) ] , s ) #NEWLINE# self . assertEqual ( res [ : len ( s ) ] , s ) #NEWLINE# self . assertEqual ( res [ ( len ( s ) - 1 ) : ( - 1 ) : ( - 1 ) ] , s [ : : ( - 1 ) ] ) #NEWLINE# self . assertEqual ( res [ ( len ( s ) - 1 ) : 5 : ( - 7 ) ] , s [ : 5 : ( - 7 ) ] ) #NEWLINE# import operator #NEWLINE# self . assertRaises ( TypeError , operator . setslice , res , 0 , 5 , 'abcde' ) #NEWLINE# self . assertRaises ( TypeError , operator . setitem , res , slice ( 0 , 5 ) , 'abcde' ) #NEWLINE# dll . my_free ( res ) #NEWLINE# if ( sizeof ( c_wchar ) == sizeof ( c_short ) ) : #NEWLINE# #INDENT# dll . my_wcsdup . restype = POINTER ( c_short ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( sizeof ( c_wchar ) == sizeof ( c_int ) ) : #NEWLINE# #INDENT# dll . my_wcsdup . restype = POINTER ( c_int ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( sizeof ( c_wchar ) == sizeof ( c_long ) ) : #NEWLINE# #INDENT# dll . my_wcsdup . restype = POINTER ( c_long ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . skipTest ( 'Pointers to c_wchar are not supported' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# res = dll . my_wcsdup ( s ) #NEWLINE# tmpl = range ( ord ( 'a' ) , ( ord ( 'z' ) + 1 ) ) #NEWLINE# self . assertEqual ( res [ : ( len ( s ) - 1 ) ] , tmpl ) #NEWLINE# self . assertEqual ( res [ : ( len ( s ) - 1 ) ] , tmpl ) #NEWLINE# self . assertEqual ( res [ ( len ( s ) - 2 ) : ( - 1 ) : ( - 1 ) ] , tmpl [ : : ( - 1 ) ] ) #NEWLINE# self . assertEqual ( res [ ( len ( s ) - 2 ) : 5 : ( - 7 ) ] , tmpl [ : 5 : ( - 7 ) ] ) #NEWLINE# dll . my_free ( res )