<s> import unittest <EOL> from ctypes import * <EOL> class MyInt ( c_int ) : <EOL> def __cmp__ ( self , other ) : <EOL> if type ( other ) != MyInt : <EOL> return - <NUM_LIT:1> <EOL> return cmp ( self . value , other . value ) <EOL> class Test ( unittest . TestCase ) : <EOL> def test_compare ( self ) : <EOL> self . failUnlessEqual ( MyInt ( <NUM_LIT:3> ) , MyInt ( <NUM_LIT:3> ) ) <EOL> self . failIfEqual ( MyInt ( <NUM_LIT> ) , MyInt ( <NUM_LIT> ) ) <EOL> def test_ignore_retval ( self ) : <EOL> proto = CFUNCTYPE ( None ) <EOL> def func ( ) : <EOL> return ( <NUM_LIT:1> , "<STR_LIT:abc>" , None ) <EOL> cb = proto ( func ) <EOL> self . failUnlessEqual ( None , cb ( ) ) <EOL> def test_int_callback ( self ) : <EOL> args = [ ] <EOL> def func ( arg ) : <EOL> args . append ( arg ) <EOL> return arg <EOL> cb = CFUNCTYPE ( None , MyInt ) ( func ) <EOL> self . failUnlessEqual ( None , cb ( <NUM_LIT> ) ) <EOL> self . failUnlessEqual ( type ( args [ - <NUM_LIT:1> ] ) , MyInt ) <EOL> cb = CFUNCTYPE ( c_int , c_int ) ( func ) <EOL> self . failUnlessEqual ( <NUM_LIT> , cb ( <NUM_LIT> ) ) <EOL> self . failUnlessEqual ( type ( args [ - <NUM_LIT:1> ] ) , int ) <EOL> def test_int_struct ( self ) : <EOL> class X ( Structure ) : <EOL> _fields_ = [ ( "<STR_LIT:x>" , MyInt ) ] <EOL> self . failUnlessEqual ( X ( ) . x , MyInt ( ) ) <EOL> s = X ( ) <EOL> s . x = MyInt ( <NUM_LIT> ) <EOL> self . failUnlessEqual ( s . x , MyInt ( <NUM_LIT> ) ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
