home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_385 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  1.5 KB  |  36 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import unittest
  5. from ctypes import *
  6. import _ctypes_test
  7.  
  8. class ReturnFuncPtrTestCase(unittest.TestCase):
  9.     
  10.     def test_with_prototype(self):
  11.         dll = CDLL(_ctypes_test.__file__)
  12.         get_strchr = dll.get_strchr
  13.         get_strchr.restype = CFUNCTYPE(c_char_p, c_char_p, c_char)
  14.         strchr = get_strchr()
  15.         self.failUnlessEqual(strchr('abcdef', 'b'), 'bcdef')
  16.         self.failUnlessEqual(strchr('abcdef', 'x'), None)
  17.         self.assertRaises(ArgumentError, strchr, 'abcdef', 3)
  18.         self.assertRaises(TypeError, strchr, 'abcdef')
  19.  
  20.     
  21.     def test_without_prototype(self):
  22.         dll = CDLL(_ctypes_test.__file__)
  23.         get_strchr = dll.get_strchr
  24.         get_strchr.restype = c_void_p
  25.         addr = get_strchr()
  26.         strchr = CFUNCTYPE(c_char_p, c_char_p, c_char)(addr)
  27.         self.failUnless(strchr('abcdef', 'b'), 'bcdef')
  28.         self.failUnlessEqual(strchr('abcdef', 'x'), None)
  29.         self.assertRaises(ArgumentError, strchr, 'abcdef', 3)
  30.         self.assertRaises(TypeError, strchr, 'abcdef')
  31.  
  32.  
  33. if __name__ == '__main__':
  34.     unittest.main()
  35.  
  36.