|
1 | 1 | # Copyright David Abrahams 2004. Distributed under the Boost |
2 | 2 | # Software License, Version 1.0. (See accompanying |
3 | 3 | # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
4 | | -from past.builtins import long |
| 4 | +import sys |
| 5 | +if (sys.version_info.major >= 3): |
| 6 | + from past.builtins import long |
5 | 7 | r""" |
6 | 8 | >>> from builtin_converters_ext import * |
7 | 9 |
|
|
74 | 76 |
|
75 | 77 | test unsigned long values which don't fit in a signed long. |
76 | 78 | strip any 'L' characters in case the platform has > 32 bit longs |
77 | | - |
| 79 | +
|
78 | 80 | >>> hex(rewrap_value_unsigned_long(0x80000001L)).replace('L','') |
79 | 81 | '0x80000001' |
80 | 82 |
|
|
83 | 85 | >>> rewrap_value_unsigned_long_long(42) == 42 |
84 | 86 | True |
85 | 87 |
|
86 | | - show that we have range checking. |
| 88 | + show that we have range checking. |
87 | 89 |
|
88 | 90 | >>> should_pass(rewrap_value_signed_char, _signed_values(char_size())) |
89 | 91 | >>> should_pass(rewrap_value_short, _signed_values(short_size())) |
|
140 | 142 | yo, wassup? |
141 | 143 |
|
142 | 144 | wrap strings with embedded nulls: |
143 | | - |
| 145 | +
|
144 | 146 | >>> rewrap_value_string('yo,\0wassup?') |
145 | 147 | 'yo,\x00wassup?' |
146 | 148 |
|
|
152 | 154 |
|
153 | 155 | Note that we can currently get a mutable pointer into an immutable |
154 | 156 | Python string: |
155 | | - |
| 157 | +
|
156 | 158 | >>> rewrap_value_mutable_cstring('hello, world') |
157 | 159 | 'hello, world' |
158 | 160 |
|
@@ -285,16 +287,16 @@ def run(args = None): |
285 | 287 | import sys |
286 | 288 | import doctest |
287 | 289 | import builtin_converters_ext |
288 | | - |
| 290 | + |
289 | 291 | if 'rewrap_value_long_long' in dir(builtin_converters_ext): |
290 | 292 | print('LONG_LONG supported, testing...') |
291 | 293 | else: |
292 | 294 | print('LONG_LONG not supported, skipping those tests...') |
293 | | - |
| 295 | + |
294 | 296 | if args is not None: |
295 | 297 | sys.argv = args |
296 | 298 | return doctest.testmod(sys.modules.get(__name__)) |
297 | | - |
| 299 | + |
298 | 300 | if __name__ == '__main__': |
299 | 301 | print("running...") |
300 | 302 | import sys |
|
0 commit comments