Mercurial > pub > dyncall > bindings
comparison python/pydc/test/types.py @ 57:80b11152c659
make pydc tests display failed ones
author | Tassilo Philipp |
---|---|
date | Mon, 08 Feb 2021 09:58:25 +0100 |
parents | c21d1c2c84e1 |
children | e4bf6e44fbf5 |
comparison
equal
deleted
inserted
replaced
56:16151547265e | 57:80b11152c659 |
---|---|
1 import pydc | 1 import pydc |
2 import sys | 2 import sys |
3 import platform | 3 import platform |
4 | 4 import copy |
5 import types | |
5 | 6 |
6 | 7 |
7 | 8 |
8 def theader(title): | 9 def theader(title): |
9 print("\n"+title) | 10 print("\n"+title) |
10 print('%8s %20s %16s %-20s %11s %-16s -> %16s %-16s %12s %-16s # %s' % ('DC_SIG', 'C_RET_T', 'C_FSYM', 'C_PARAMLIST', 'PY_ARG_T', 'IN_ARGS', 'RET_VAL', 'PY_RET_T', 'OUT_ARGS', 'OUT_ARGS_T', 'NOTES')) | 11 print('%8s %20s %16s %-20s %11s %-16s -> %16s %-16s %12s %-16s # %s' % ('DC_SIG', 'C_RET_T', 'C_FSYM', 'C_PARAMLIST', 'PY_ARG_T', 'IN_ARGS', 'RET_VAL', 'PY_RET_T', 'OUT_ARGS', 'OUT_ARGS_T', 'NOTES')) |
11 | 12 |
12 | 13 |
13 def t(lib, dcsig, c_rtype, c_fsym, c_paramlist, extra_msg, *args): | 14 def t(lib, dcsig, c_rtype, c_fsym, c_paramlist, extra_msg, **kwargs): |
15 args = kwargs['i'] if 'i' in kwargs else () | |
16 post_args = kwargs['p'] if 'p' in kwargs else copy.deepcopy(args) # expected args after call (as some can be modified in-place) | |
17 exp_ret = kwargs['r'] if 'r' in kwargs else None # expected return value | |
18 err_sgr = '' | |
14 # before call | 19 # before call |
15 inarg_types = '('+','.join(map(lambda x: type(x).__name__, args))+')' | 20 inarg_types = '('+','.join(map(lambda x: type(x).__name__, args))+')' |
16 inargs = ','.join(map(str, args)) | 21 inargs_str = ','.join(map(str, args)) |
17 # call | 22 # call |
18 try: | 23 try: |
19 fp = pydc.find(lib, c_fsym) | 24 fp = pydc.find(lib, c_fsym) |
20 r = pydc.call(fp, dcsig, *args) | 25 r = pydc.call(fp, dcsig, *args) |
21 rt = type(r).__name__ | 26 rt = type(r).__name__ |
27 if(r != exp_ret or args != post_args): | |
28 if((type(exp_ret) is types.LambdaType) and exp_ret(r) == False): | |
29 err_sgr = '\033[41m' | |
22 except: | 30 except: |
23 r = '[EXCEPTION]' | 31 r = '[EXCEPTION]' |
24 rt = '!' | 32 rt = '!' |
33 if(exp_ret != Exception): | |
34 err_sgr = '\033[41m' | |
25 e = str(sys.exc_info()[1]) | 35 e = str(sys.exc_info()[1]) |
26 extra_msg += ' "'+(e if len(e)<32 else e[0:32]+'...')+'"' | 36 extra_msg += ' "'+(e if len(e)<32 else e[0:32]+'...')+'"' |
27 # after call | 37 # after call |
28 outarg_types = '('+','.join(map(lambda x: type(x).__name__, args))+')' | 38 outarg_types = '('+','.join(map(lambda x: type(x).__name__, args))+')' |
29 outargs = ','.join(map(str, args)) | 39 outargs = ','.join(map(str, args)) |
30 print('%8s %20s %16s %-20s %11s \033[33m%-16s\033[0m -> \033[32m%16.16s\033[0m %-16s %12s \033[32m%-16s\033[0m # %s' % (dcsig, c_rtype, c_fsym, c_paramlist, inarg_types, inargs, str(r), '('+rt+')', outarg_types, outargs, extra_msg)) | 40 print('%s%8s %20s %16s %-20s %11s \033[33m%-16s\033[39m -> \033[32m%16.16s\033[39m %-16s %12s \033[32m%-16s\033[0m # %s' % (err_sgr, dcsig, c_rtype, c_fsym, c_paramlist, inarg_types, inargs_str, str(r), '('+rt+')', outarg_types, outargs, extra_msg)) |
41 | |
42 return r | |
31 | 43 |
32 | 44 |
33 | 45 |
34 # some libc tests ------------------ | 46 # some libc tests ------------------ |
35 | 47 |
36 try: | 48 try: |
37 if sys.platform == "win32": | 49 if len(sys.argv) > 1: |
50 libc = pydc.load(sys.argv[1]) | |
51 elif sys.platform == "win32": | |
38 libc = pydc.load("msvcrt") | 52 libc = pydc.load("msvcrt") |
39 elif sys.platform == "darwin": | 53 elif sys.platform == "darwin": |
40 libc = pydc.load("/usr/lib/libc.dylib") | 54 libc = pydc.load("/usr/lib/libc.dylib") |
41 elif "bsd" in sys.platform: | 55 elif "bsd" in sys.platform: |
42 libc = pydc.load("/usr/lib/libc.so") | 56 libc = pydc.load("/usr/lib/libc.so") |
43 #libc = pydc.load("/lib/libc.so.7") | 57 #libc = pydc.load("/lib/libc.so.7") |
44 elif platform.architecture()[0] == "64bit": | 58 elif platform.architecture()[0] == "64bit": |
45 libc = pydc.load("/lib64/libc.so.6") | 59 libc = pydc.load("/lib64/libc.so.6") |
46 else: | 60 else: |
47 libc = pydc.load("/lib/libc.so.6") | 61 libc = pydc.load("/lib/libc.so") |
48 | 62 |
49 theader('CLIB TESTS:') | 63 theader('CLIB TESTS:') |
50 | 64 |
51 # void() | 65 # void() |
52 t(libc, ")v", "void", "sranddev", "(void)", '') | 66 t(libc, ")v", "void", "sranddev", "(void)", '') |
53 | 67 |
54 # int() | 68 # int() |
55 t(libc, ")i", "int", "rand", "(void)", '') | 69 t(libc, ")i", "int", "rand", "(void)", '') |
56 | 70 |
57 # void(unsigned int) | 71 # void(unsigned int) |
58 t(libc, "I)v", "void", "srand", "(int)", '', 123) | 72 t(libc, "I)v", "void", "srand", "(int)", '', i=(123,)) |
59 | 73 |
60 # int() (and one different helper call for test) | 74 # int() (and one different helper call for test) |
61 t(libc, ")i", "int", "rand", "(void)", 'with seed <------,') | 75 x = \ |
62 t(libc, "I)v", "void", "srand", "(int)", 'set same seed |', 123) | 76 t(libc, ")i", "int", "rand", "(void)", 'with seed <------,', r=lambda i: type(i) is int) |
63 t(libc, ")i", "int", "rand", "(void)", 'should be same result...') | 77 t(libc, "I)v", "void", "srand", "(int)", 'set same seed |', i=(123,)) |
64 t(libc, ")i", "int", "rand", "(void)", '...and now different result') | 78 t(libc, ")i", "int", "rand", "(void)", 'should be same result...', r=x) |
79 t(libc, ")i", "int", "rand", "(void)", '...and now different result', r=lambda i: type(i) is int and i!=x) | |
65 | 80 |
66 # int(int) | 81 # int(int) |
67 t(libc, "i)i", "int", "abs", "(int)", ' 10 => 10', 10) | 82 t(libc, "i)i", "int", "abs", "(int)", ' 10 => 10', i=( 10,), r=10) |
68 t(libc, "i)i", "int", "abs", "(int)", ' 0 => 0', 0) | 83 t(libc, "i)i", "int", "abs", "(int)", ' 0 => 0', i=( 0,), r=0) |
69 t(libc, "i)i", "int", "abs", "(int)", ' -9209 => 9209', -9209) | 84 t(libc, "i)i", "int", "abs", "(int)", ' -9209 => 9209', i=(-9209,), r=9209) |
70 | 85 |
71 # long(long) | 86 # long(long) |
72 t(libc, "j)j", "long", "labs", "(long)", ' 48 => 48', 48) | 87 t(libc, "j)j", "long", "labs", "(long)", ' 48 => 48', i=( 48,), r=48) |
73 t(libc, "j)j", "long", "labs", "(long)", ' 0 => 0', 0) | 88 t(libc, "j)j", "long", "labs", "(long)", ' 0 => 0', i=( 0,), r=0) |
74 t(libc, "j)j", "long", "labs", "(long)", '-4271477497 => 4271477497', -4271477497) | 89 t(libc, "j)j", "long", "labs", "(long)", '-4271477497 => 4271477497', i=(-4271477497,), r=4271477497) |
75 | 90 |
76 # long long(long long) | 91 # long long(long long) |
77 t(libc, "l)l", "long long", "labs", "(long long)", ' 6334810198 => 6334810198', 6334810198) | 92 t(libc, "l)l", "long long", "labs", "(long long)", ' 6334810198 => 6334810198', i=( 6334810198,), r=6334810198) |
78 t(libc, "l)l", "long long", "labs", "(long long)", ' 1 => 1', 1) | 93 t(libc, "l)l", "long long", "labs", "(long long)", ' 1 => 1', i=( 1,), r=1) |
79 t(libc, "l)l", "long long", "labs", "(long long)", ' 0 => 0', 0) | 94 t(libc, "l)l", "long long", "labs", "(long long)", ' 0 => 0', i=( 0,), r=0) |
80 t(libc, "l)l", "long long", "labs", "(long long)", ' -1 => 1', -1) | 95 t(libc, "l)l", "long long", "labs", "(long long)", ' -1 => 1', i=( -1,), r=1) |
81 t(libc, "l)l", "long long", "labs", "(long long)", '-7358758407 => 7358758407', -7358758407) | 96 t(libc, "l)l", "long long", "labs", "(long long)", '-7358758407 => 7358758407', i=(-7358758407,), r=7358758407) |
82 | 97 |
83 pydc.free(libc) | 98 pydc.free(libc) |
84 except: | 99 except: |
85 print("skipping clib tests because: "+str(sys.exc_info()[1])) | 100 print("\033[33mskipping clib tests because: "+str(sys.exc_info()[1])+"\033[0m\nnote: c-lib to use can be specified as command line param") |
86 | 101 |
87 | 102 |
88 # tests with own .so for testing all conversions ------------------ | 103 # tests with own .so for testing all conversions ------------------ |
89 | 104 |
90 l = pydc.load(sys.path[0]+"/test.so") | 105 l = pydc.load(sys.path[0]+"/test.so") |
97 long_h = long(0xdeadc0de) | 112 long_h = long(0xdeadc0de) |
98 | 113 |
99 # test all possible arg types and their conversions to and from python, with | 114 # test all possible arg types and their conversions to and from python, with |
100 # specific focus/tests in areas where python 2 and 3 differ | 115 # specific focus/tests in areas where python 2 and 3 differ |
101 theader('ARG & RET TYPE CONVERSION TESTS:') | 116 theader('ARG & RET TYPE CONVERSION TESTS:') |
102 t(l, "B)B", "int", "i_plus_one", "(int)", ' False => True (using int func in C)', False) | 117 t(l, "B)B", "int", "i_plus_one", "(int)", ' False => True (using int func in C)', i=(False,), r=True) |
103 | 118 |
104 t(l, "c)c", "char", "c_plus_one", "(char)", ' "a" (97) => 98', 'a') | 119 t(l, "c)c", "char", "c_plus_one", "(char)", ' "a" (97) => 98', i=( 'a',), r=98) |
105 t(l, "C)C", "unsigned char", "uc_plus_one", "(unsigned char)", ' "a" (97) => 98', 'a') | 120 t(l, "C)C", "unsigned char", "uc_plus_one", "(unsigned char)", ' "a" (97) => 98', i=( 'a',), r=98) |
106 t(l, "c)c", "char", "c_plus_one", "(char)", ' -2 => -1', -2) | 121 t(l, "c)c", "char", "c_plus_one", "(char)", ' -2 => -1', i=( -2,), r=-1) |
107 t(l, "C)C", "unsigned char", "uc_plus_one", "(unsigned char)", ' 10 => 11', 10) | 122 t(l, "C)C", "unsigned char", "uc_plus_one", "(unsigned char)", ' 10 => 11', i=( 10,), r=11) |
108 | 123 |
109 t(l, "s)s", "short", "s_plus_one", "(short)", ' 10 => 11', 10) | 124 t(l, "s)s", "short", "s_plus_one", "(short)", ' 10 => 11', i=( 10,), r=11) |
110 t(l, "S)S", "unsigned short", "us_plus_one", "(unsigned short)", ' 10 => 11', 10) | 125 t(l, "S)S", "unsigned short", "us_plus_one", "(unsigned short)", ' 10 => 11', i=( 10,), r=11) |
111 | 126 |
112 t(l, "i)i", "int", "i_plus_one", "(int)", ' 10 => 11', 10) | 127 t(l, "i)i", "int", "i_plus_one", "(int)", ' 10 => 11', i=( 10,), r=11) |
113 t(l, "I)I", "unsigned int", "ui_plus_one", "(unsigned int)", ' 10 => 11', 10) | 128 t(l, "I)I", "unsigned int", "ui_plus_one", "(unsigned int)", ' 10 => 11', i=( 10,), r=11) |
114 | 129 |
115 t(l, "j)j", "long", "l_plus_one", "(long)", ' 10 => 11', 10) | 130 t(l, "j)j", "long", "l_plus_one", "(long)", ' 10 => 11', i=( 10,), r=11) |
116 t(l, "J)J", "unsigned long", "ul_plus_one", "(unsigned long)", ' 10 => 11', 10) | 131 t(l, "J)J", "unsigned long", "ul_plus_one", "(unsigned long)", ' 10 => 11', i=( 10,), r=11) |
117 | 132 |
118 t(l, "l)l", "long long", "ll_plus_one", "(long long)", ' 10 => 11', 10) | 133 t(l, "l)l", "long long", "ll_plus_one", "(long long)", ' 10 => 11', i=( 10,), r=11) |
119 t(l, "L)L", "unsigned long long", "ull_plus_one", "(unsigned long long)", ' 10 => 11', 10) | 134 t(l, "L)L", "unsigned long long", "ull_plus_one", "(unsigned long long)", ' 10 => 11', i=( 10,), r=11) |
120 t(l, "l)l", "long long", "ll_plus_one", "(long long)", ' 11234 => 11235', long_i) | 135 t(l, "l)l", "long long", "ll_plus_one", "(long long)", ' 11234 => 11235', i=(long_i,), r=11235) |
121 t(l, "L)L", "unsigned long long", "ull_plus_one", "(unsigned long long)", ' 11234 => 11235', long_i) | 136 t(l, "L)L", "unsigned long long", "ull_plus_one", "(unsigned long long)", ' 11234 => 11235', i=(long_i,), r=11235) |
122 | 137 |
123 t(l, "f)f", "float", "f_plus_one", "(float)", ' -1.23 => -0.23', -1.23) | 138 t(l, "f)f", "float", "f_plus_one", "(float)", ' -1.23 => -0.23... (w/ fp imprecision)', i=( -1.23,), r=-0.23000001907348633) |
124 t(l, "d)d", "double", "d_plus_one", "(double)", ' 5.67 => 6.67', 5.67) | 139 t(l, "d)d", "double", "d_plus_one", "(double)", ' 5.67 => 6.67', i=( 5.67,), r= 6.67) |
125 | 140 |
126 t(l, "Z)Z", "const char*", "ccp_plus_one", "(const char*)", '"lose char" => "ose char"', 'lose char') # string object | 141 t(l, "Z)Z", "const char*", "ccp_plus_one", "(const char*)", '"lose char" => "ose char"', i=( 'lose char',), r= 'ose char') # string object |
127 t(l, "Z)Z", "const char*", "ccp_plus_one", "(const char*)", '"X_unicode" => "_unicode"', u'X_unicode') # string object (unicode in Python 2) | 142 t(l, "Z)Z", "const char*", "ccp_plus_one", "(const char*)", '"X_unicode" => "_unicode"', i=( u'X_unicode',), r=u'_unicode') # string object (unicode in Python 2) |
128 t(l, "Z)Z", "const char*", "ccp_plus_one", "(const char*)", '"1lessbyte" => "lessbyte"', b'1lessbyte') # bytes object | 143 t(l, "Z)Z", "const char*", "ccp_plus_one", "(const char*)", '"1lessbyte" => "lessbyte"', i=( b'1lessbyte',), r= 'lessbyte') # bytes object |
129 t(l, "Z)Z", "const char*", "ccp_plus_one", "(const char*)", ' "xY" => "Y"', bytearray(b'xY')) # bytearray object | 144 t(l, "Z)Z", "const char*", "ccp_plus_one", "(const char*)", ' "xY" => "Y"', i=(bytearray(b'xY'),), r= 'Y') # bytearray object |
130 | 145 |
131 t(l, "p)Z", "const char*", "ccp_plus_one", "(const char*)", ' "xY" => "Y"', bytearray(b'xY')) # bytearray object | 146 t(l, "p)Z", "const char*", "ccp_plus_one", "(const char*)", ' "xY" => "Y"', i=(bytearray(b'xY'),), r='Y') # bytearray object |
132 t(l, "p)p", "const char*", "ccp_plus_one", "(const char*)", ' "xY" => p+1 (~ odd addr)', bytearray(b'xY')) # bytearray object | 147 t(l, "p)p", "const char*", "ccp_plus_one", "(const char*)", ' "xY" => p+1 (~ odd addr)', i=(bytearray(b'xY'),), r='??') # bytearray object |
133 t(l, "p)p", "const char*", "ccp_plus_one", "(const char*)", ' 0xdeadc0de => 0xdeadc0de+1=3735929055', long_h) # handle (integer interpreted as ptr) | 148 t(l, "p)p", "const char*", "ccp_plus_one", "(const char*)", ' 0xdeadc0de => 0xdeadc0de+1=3735929055', i=(long_h,), r=3735929055) # handle (integer interpreted as ptr) |
134 t(l, "p)p", "const char*", "ccp_plus_one", "(const char*)", ' 0xdeadc0de => 0xdeadc0de+1=3735929055', long_h) # handle (integer interpreted as ptr, long in Python 2) | 149 t(l, "p)p", "const char*", "ccp_plus_one", "(const char*)", ' 0xdeadc0de => 0xdeadc0de+1=3735929055', i=(long_h,), r=3735929055) # handle (integer interpreted as ptr, long in Python 2) |
135 t(l, "p)p", "const char*", "ccp_plus_one", "(const char*)", ' NULL => NULL+1=1', None) # NULL, adding one will result in 0x1 | 150 t(l, "p)p", "const char*", "ccp_plus_one", "(const char*)", ' NULL => NULL+1=1', i=( None,), r=1) # NULL, adding one will result in 0x1 |
136 | 151 |
137 # functions that change buffers | 152 # functions that change buffers |
138 theader('TESTS OF IMMUTABLE AND MUTABLE PYTHON BUFFERS:') | 153 theader('TESTS OF IMMUTABLE AND MUTABLE PYTHON BUFFERS:') |
139 t(l, "Z)v", "const char*", "cp_head_incr", "(const char*)", ' "string" => None / arg => "string" (not modified)"', 'string') # string object | 154 t(l, "Z)v", "const char*", "cp_head_incr", "(const char*)", ' "string" => None / arg => "string" (not modified)"', i=( 'string',)) # string object |
140 t(l, "Z)v", "const char*", "cp_head_incr", "(const char*)", ' "UnIcOdE" => None / arg => "UnIcOdE" (not modified)"', u'UnIcOdE') # string object (unicode in Python 2) | 155 t(l, "Z)v", "const char*", "cp_head_incr", "(const char*)", ' "UnIcOdE" => None / arg => "UnIcOdE" (not modified)"', i=( u'UnIcOdE',)) # string object (unicode in Python 2) |
141 t(l, "Z)v", "const char*", "cp_head_incr", "(const char*)", ' "BCssk#" => None / arg => "BCssk#" (not modified)"', b'BCssk#') # bytes object | 156 t(l, "Z)v", "const char*", "cp_head_incr", "(const char*)", ' "BCssk#" => None / arg => "BCssk#" (not modified)"', i=( b'BCssk#',)) # bytes object |
142 t(l, "Z)v", "const char*", "cp_head_incr", "(const char*)", ' "xY" => None / arg => "xY" (not modified)"', bytearray(b'xY')) # bytearray object | 157 t(l, "Z)v", "const char*", "cp_head_incr", "(const char*)", ' "xY" => None / arg => "xY" (not modified)"', i=(bytearray(b'xY'),)) # bytearray object |
143 t(l, "p)v", "const char*", "cp_head_incr", "(const char*)", ' "xY" => None / arg => "yY" (!MODIFIED!)"', bytearray(b'xY')) # bytearray object | 158 t(l, "p)v", "const char*", "cp_head_incr", "(const char*)", ' "xY" => None / arg => "yY" (!MODIFIED!)"', i=(bytearray(b'xY'),), p=(bytearray(b'yY'),)) # bytearray object |
144 | 159 |
145 # tested checked value conversions | 160 # tested checked value conversions |
146 theader('ARG & RET TYPE CONVERSION TESTS FOR RANGE CHECKED TYPES:') | 161 theader('ARG & RET TYPE CONVERSION TESTS FOR RANGE CHECKED TYPES:') |
147 t(l, "c)c", "char", "c_plus_one", "(char)", ' "~" => 127', '~') | 162 t(l, "c)c", "char", "c_plus_one", "(char)", ' "~" => 127', i=( '~',), r=127) |
148 t(l, "c)c", "char", "c_plus_one", "(char)", ' "~" => 127', '~') | 163 t(l, "c)c", "char", "c_plus_one", "(char)", ' "~" => 127', i=( '~',), r=127) |
149 t(l, "c)c", "char", "c_plus_one", "(char)", ' "" => input exc:', '') | 164 t(l, "c)c", "char", "c_plus_one", "(char)", ' "" => input exc:', i=( '',), r=Exception) |
150 t(l, "c)c", "char", "c_plus_one", "(char)", ' "" => input exc:', '') | 165 t(l, "c)c", "char", "c_plus_one", "(char)", ' "" => input exc:', i=( '',), r=Exception) |
151 t(l, "C)C", "unsigned char", "uc_plus_one", "(unsigned char)", ' "ab" => input exc:', 'ab') | 166 t(l, "C)C", "unsigned char", "uc_plus_one", "(unsigned char)", ' "ab" => input exc:', i=('ab',), r=Exception) |
152 t(l, "C)C", "unsigned char", "uc_plus_one", "(unsigned char)", ' "ab" => input exc:', 'ab') | 167 t(l, "C)C", "unsigned char", "uc_plus_one", "(unsigned char)", ' "ab" => input exc:', i=('ab',), r=Exception) |
168 | |
169 t(l, "c)c", "char", "c_plus_one", "(char)", ' -128 => -127', i=(-128,), r=-127) | |
170 t(l, "c)c", "char", "c_plus_one", "(char)", ' 127 => -128 (wrapped)', i=( 127,), r=-128) | |
171 t(l, "c)c", "char", "c_plus_one", "(char)", ' -129 => input exc:', i=(-129,), r=Exception) | |
172 t(l, "c)c", "char", "c_plus_one", "(char)", ' 128 => input exc:', i=( 128,), r=Exception) | |
173 | |
174 t(l, "C)C", "unsigned char", "uc_plus_one", "(unsigned char)", ' 0 => 1', i=( 0,), r=1) | |
175 t(l, "C)C", "unsigned char", "uc_plus_one", "(unsigned char)", ' 255 => 0 (wrapped)', i=( 255,), r=0) | |
176 t(l, "C)C", "unsigned char", "uc_plus_one", "(unsigned char)", ' -1 => input exc:', i=( -1,), r=Exception) | |
177 t(l, "C)C", "unsigned char", "uc_plus_one", "(unsigned char)", ' 256 => input exc:', i=( 256,), r=Exception) | |
178 | |
179 t(l, "s)s", "short", "s_plus_one", "(short)", ' -32768 => -32767', i=(-32768,), r=-32767) | |
180 t(l, "s)s", "short", "s_plus_one", "(short)", ' 32767 => -32768 (wrapped)',i=( 32767,), r=-32768) | |
181 t(l, "s)s", "short", "s_plus_one", "(short)", ' -32769 => input exc:', i=(-32769,), r=Exception) | |
182 t(l, "s)s", "short", "s_plus_one", "(short)", ' 32768 => input exc:', i=( 32768,), r=Exception) | |
183 | |
184 t(l, "S)S", "unsigned short", "us_plus_one", "(unsigned short)", ' 0 => 1', i=( 0,), r=1) | |
185 t(l, "S)S", "unsigned short", "us_plus_one", "(unsigned short)", ' 65535 => 0 (wrapped)', i=(65535,), r=0) | |
186 t(l, "S)S", "unsigned short", "us_plus_one", "(unsigned short)", ' -1 => input exc:', i=( -1,), r=Exception) | |
187 t(l, "S)S", "unsigned short", "us_plus_one", "(unsigned short)", ' 65536 => input exc:', i=(65536,), r=Exception) | |
188 | |
189 t(l, "p)Z", "const char*", "ccp_plus_one", "(const char*)", '"w/pointer" => input exc:',i=( 'w/pointer',), r=Exception) # string object, not passable as 'p'ointer | |
190 t(l, "p)Z", "const char*", "ccp_plus_one", "(const char*)", '"X_unicode" => input exc:',i=(u'X_unicode',), r=Exception) # string object (unicode in Python 2), not passable as 'p'ointer | |
191 t(l, "p)Z", "const char*", "ccp_plus_one", "(const char*)", '"1less/ptr" => input exc:',i=(b'1less/ptr',), r=Exception) # bytes object, not passable as 'p'ointer | |
192 t(l, "p)p", "const char*", "ccp_plus_one", "(const char*)", ' "x" => input exc:',i=( 'x',), r=Exception) # string object, not passable as 'p'ointer | |
153 | 193 |
154 t(l, "c)c", "char", "c_plus_one", "(char)", ' -128 => -127', -128) | |
155 t(l, "c)c", "char", "c_plus_one", "(char)", ' 127 => -128 (wrapped)', 127) | |
156 t(l, "c)c", "char", "c_plus_one", "(char)", ' -129 => input exc:', -129) | |
157 t(l, "c)c", "char", "c_plus_one", "(char)", ' 128 => input exc:', 128) | |
158 | |
159 t(l, "C)C", "unsigned char", "uc_plus_one", "(unsigned char)", ' 0 => 1', 0) | |
160 t(l, "C)C", "unsigned char", "uc_plus_one", "(unsigned char)", ' 255 => 0 (wrapped)', 255) | |
161 t(l, "C)C", "unsigned char", "uc_plus_one", "(unsigned char)", ' -1 => input exc:', -1) | |
162 t(l, "C)C", "unsigned char", "uc_plus_one", "(unsigned char)", ' 256 => input exc:', 256) | |
163 | |
164 t(l, "s)s", "short", "s_plus_one", "(short)", ' -32768 => -32767', -32768) | |
165 t(l, "s)s", "short", "s_plus_one", "(short)", ' 32767 => -32768 (wrapped)', 32767) | |
166 t(l, "s)s", "short", "s_plus_one", "(short)", ' -32769 => input exc:', -32769) | |
167 t(l, "s)s", "short", "s_plus_one", "(short)", ' 32768 => input exc:', 32768) | |
168 | |
169 t(l, "S)S", "unsigned short", "us_plus_one", "(unsigned short)", ' 0 => 1', 0) | |
170 t(l, "S)S", "unsigned short", "us_plus_one", "(unsigned short)", ' 65535 => 0 (wrapped)', 65535) | |
171 t(l, "S)S", "unsigned short", "us_plus_one", "(unsigned short)", ' -1 => input exc:', -1) | |
172 t(l, "S)S", "unsigned short", "us_plus_one", "(unsigned short)", ' 65536 => input exc:', 65536) | |
173 | |
174 t(l, "p)Z", "const char*", "ccp_plus_one", "(const char*)", '"w/pointer" => input exc:', 'w/pointer') # string object, not passable as 'p'ointer | |
175 t(l, "p)Z", "const char*", "ccp_plus_one", "(const char*)", '"X_unicode" => input exc:',u'X_unicode') # string object (unicode in Python 2), not passable as 'p'ointer | |
176 t(l, "p)Z", "const char*", "ccp_plus_one", "(const char*)", '"1less/ptr" => input exc:',b'1less/ptr') # bytes object, not passable as 'p'ointer | |
177 t(l, "p)p", "const char*", "ccp_plus_one", "(const char*)", ' "x" => input exc:', 'x') # string object, not passable as 'p'ointer | |
178 |