home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_370 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  1.5 KB  |  35 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. lib = CDLL(_ctypes_test.__file__)
  8.  
  9. class LibTest(unittest.TestCase):
  10.     
  11.     def test_sqrt(self):
  12.         lib.my_sqrt.argtypes = (c_double,)
  13.         lib.my_sqrt.restype = c_double
  14.         self.failUnlessEqual(lib.my_sqrt(4), 2)
  15.         import math
  16.         self.failUnlessEqual(lib.my_sqrt(2), math.sqrt(2))
  17.  
  18.     
  19.     def test_qsort(self):
  20.         comparefunc = CFUNCTYPE(c_int, POINTER(c_char), POINTER(c_char))
  21.         lib.my_qsort.argtypes = (c_void_p, c_size_t, c_size_t, comparefunc)
  22.         lib.my_qsort.restype = None
  23.         
  24.         def sort(a, b):
  25.             return cmp(a[0], b[0])
  26.  
  27.         chars = create_string_buffer('spam, spam, and spam')
  28.         lib.my_qsort(chars, len(chars) - 1, sizeof(c_char), comparefunc(sort))
  29.         self.failUnlessEqual(chars.raw, '   ,,aaaadmmmnpppsss\x00')
  30.  
  31.  
  32. if __name__ == '__main__':
  33.     unittest.main()
  34.  
  35.