• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright Niall Douglas 2005.
2# Distributed under the Boost Software License, Version 1.0.
3# (See accompanying file LICENSE_1_0.txt or copy at
4# http://www.boost.org/LICENSE_1_0.txt)
5
6
7"""
8>>> from voidptr_ext import *
9
10
11    Check for correct conversion
12
13>>> use(get())
14
15    Check that None is converted to a NULL void pointer
16
17>>> useany(get())
181
19>>> useany(None)
200
21
22    Check that we don't lose type information by converting NULL
23    opaque pointers to None
24
25>>> assert getnull() is None
26>>> useany(getnull())
270
28
29   Check that there is no conversion from integers ...
30
31>>> try: use(0)
32... except TypeError: pass
33... else: print('expected a TypeError')
34
35   ... and from strings to opaque objects
36
37>>> try: use("")
38... except TypeError: pass
39... else: print('expected a TypeError')
40"""
41def run(args = None):
42    import sys
43    import doctest
44
45    if args is not None:
46        sys.argv = args
47    return doctest.testmod(sys.modules.get(__name__))
48
49if __name__ == '__main__':
50    print("running...")
51    import sys
52    status = run()[0]
53    if (status == 0): print("Done.")
54    sys.exit(status)
55