mirror of
https://github.com/boostorg/python.git
synced 2026-02-01 08:42:16 +00:00
---------------------------------------------------------------------- Committing in . Modified Files: boost/python/reference_from_python.hpp boost/python/value_from_python.hpp boost/python/converter/body.hpp boost/python/converter/handle.hpp libs/python/src/converter/builtin_converters.cpp libs/python/test/m1.cpp libs/python/test/m2.cpp Added Files: boost/python/converter/builtin_converters.hpp boost/python/converter/builtin_to_python_converters.hpp boost/python/converter/from_python.hpp boost/python/converter/from_python_data.hpp boost/python/converter/from_python_function.hpp boost/python/converter/to_python.hpp boost/python/converter/to_python_function.hpp boost/python/object/auto_ptr_generator.hpp boost/python/object/pointer_holder.hpp libs/python/src/converter/from_python.cpp libs/python/src/converter/to_python.cpp libs/python/test/test_builtin_converters.cpp libs/python/test/test_builtin_converters.py Removed Files: boost/python/convert.hpp boost/python/converter/unwrap.hpp boost/python/converter/unwrapper.hpp boost/python/converter/wrap.hpp boost/python/converter/wrapper.hpp boost/python/object/class_unwrapper.hpp ---------------------------------------------------------------------- [SVN r12596]
87 lines
1.6 KiB
Python
87 lines
1.6 KiB
Python
"""
|
|
>>> from builtin_converters_ext import *
|
|
>>> rewrap_value_signed_char(42)
|
|
42
|
|
>>> rewrap_value_unsigned_char(42)
|
|
42
|
|
>>> rewrap_value_int(42)
|
|
42
|
|
>>> rewrap_value_unsigned_int(42)
|
|
42
|
|
>>> rewrap_value_short(42)
|
|
42
|
|
>>> rewrap_value_unsigned_short(42)
|
|
42
|
|
>>> rewrap_value_long(42)
|
|
42
|
|
>>> rewrap_value_unsigned_long(42)
|
|
42
|
|
|
|
>>> abs(rewrap_value_float(4.2) - 4.2) < .000001
|
|
1
|
|
>>> rewrap_value_double(4.2) - 4.2
|
|
0.0
|
|
>>> rewrap_value_long_double(4.2) - 4.2
|
|
0.0
|
|
|
|
>>> rewrap_value_cstring('hello, world')
|
|
'hello, world'
|
|
>>> rewrap_value_string('yo, wassup?')
|
|
'yo, wassup?'
|
|
|
|
>>> rewrap_const_reference_signed_char(42)
|
|
42
|
|
>>> rewrap_const_reference_unsigned_char(42)
|
|
42
|
|
>>> rewrap_const_reference_int(42)
|
|
42
|
|
>>> rewrap_const_reference_unsigned_int(42)
|
|
42
|
|
>>> rewrap_const_reference_short(42)
|
|
42
|
|
>>> rewrap_const_reference_unsigned_short(42)
|
|
42
|
|
>>> rewrap_const_reference_long(42)
|
|
42
|
|
>>> rewrap_const_reference_unsigned_long(42)
|
|
42
|
|
>>> abs(rewrap_const_reference_float(4.2) - 4.2) < .000001
|
|
1
|
|
>>> rewrap_const_reference_double(4.2) - 4.2
|
|
0.0
|
|
>>> rewrap_const_reference_long_double(4.2) - 4.2
|
|
0.0
|
|
|
|
>>> rewrap_const_reference_cstring('hello, world')
|
|
'hello, world'
|
|
>>> rewrap_const_reference_string('yo, wassup?')
|
|
'yo, wassup?'
|
|
|
|
Now check implicit conversions between floating/integer types
|
|
|
|
>>> rewrap_const_reference_float(42)
|
|
42.0
|
|
|
|
>>> rewrap_const_reference_int(42.0)
|
|
42
|
|
|
|
>>> rewrap_value_float(42)
|
|
42.0
|
|
|
|
>>> rewrap_value_int(42.0)
|
|
42
|
|
|
|
"""
|
|
def run(args = None):
|
|
import sys
|
|
import doctest
|
|
|
|
if args is not None:
|
|
sys.argv = args
|
|
return doctest.testmod(sys.modules.get(__name__))
|
|
|
|
if __name__ == '__main__':
|
|
print "running..."
|
|
import sys
|
|
sys.exit(run()[0])
|