Mercurial > pub > dyncall > bindings
comparison python/pydc/test/types.py @ 58:e4bf6e44fbf5
fixes to test code
author | Tassilo Philipp |
---|---|
date | Mon, 08 Feb 2021 10:15:27 +0100 |
parents | 80b11152c659 |
children |
comparison
equal
deleted
inserted
replaced
57:80b11152c659 | 58:e4bf6e44fbf5 |
---|---|
22 # call | 22 # call |
23 try: | 23 try: |
24 fp = pydc.find(lib, c_fsym) | 24 fp = pydc.find(lib, c_fsym) |
25 r = pydc.call(fp, dcsig, *args) | 25 r = pydc.call(fp, dcsig, *args) |
26 rt = type(r).__name__ | 26 rt = type(r).__name__ |
27 if(r != exp_ret or args != post_args): | 27 if(r != exp_ret or args != post_args): # @@@ type test also or type(r) is not type(exp_ret)): |
28 if((type(exp_ret) is types.LambdaType) and exp_ret(r) == False): | 28 if((type(exp_ret) is not types.LambdaType) or exp_ret(r) == False): |
29 err_sgr = '\033[41m' | 29 err_sgr = '\033[41m' |
30 except: | 30 except: |
31 r = '[EXCEPTION]' | 31 r = '[EXCEPTION]' |
32 rt = '!' | 32 rt = '!' |
33 if(exp_ret != Exception): | 33 if(exp_ret != Exception): |
64 | 64 |
65 # void() | 65 # void() |
66 t(libc, ")v", "void", "sranddev", "(void)", '') | 66 t(libc, ")v", "void", "sranddev", "(void)", '') |
67 | 67 |
68 # int() | 68 # int() |
69 t(libc, ")i", "int", "rand", "(void)", '') | 69 t(libc, ")i", "int", "rand", "(void)", '', r=lambda i: type(i) is int) |
70 | 70 |
71 # void(unsigned int) | 71 # void(unsigned int) |
72 t(libc, "I)v", "void", "srand", "(int)", '', i=(123,)) | 72 t(libc, "I)v", "void", "srand", "(int)", '', i=(123,)) |
73 | 73 |
74 # int() (and one different helper call for test) | 74 # int() (and one different helper call for test) |
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) | 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) |
143 t(l, "Z)Z", "const char*", "ccp_plus_one", "(const char*)", '"1lessbyte" => "lessbyte"', i=( b'1lessbyte',), r= 'lessbyte') # bytes object | 143 t(l, "Z)Z", "const char*", "ccp_plus_one", "(const char*)", '"1lessbyte" => "lessbyte"', i=( b'1lessbyte',), r= 'lessbyte') # bytes object |
144 t(l, "Z)Z", "const char*", "ccp_plus_one", "(const char*)", ' "xY" => "Y"', i=(bytearray(b'xY'),), r= 'Y') # bytearray object | 144 t(l, "Z)Z", "const char*", "ccp_plus_one", "(const char*)", ' "xY" => "Y"', i=(bytearray(b'xY'),), r= 'Y') # bytearray object |
145 | 145 |
146 t(l, "p)Z", "const char*", "ccp_plus_one", "(const char*)", ' "xY" => "Y"', i=(bytearray(b'xY'),), r='Y') # bytearray object | 146 t(l, "p)Z", "const char*", "ccp_plus_one", "(const char*)", ' "xY" => "Y"', i=(bytearray(b'xY'),), r='Y') # 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 | 147 t(l, "p)p", "const char*", "ccp_plus_one", "(const char*)", ' "xY" => p+1 (~ odd addr)', i=(bytearray(b'xY'),), r=lambda i: type(i) is int and (i%2)==1) # bytearray object |
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) | 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) |
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) | 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) |
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 | 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 |
151 | 151 |
152 # functions that change buffers | 152 # functions that change buffers |