2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-27 19:12:16 +00:00

Add new test.

[SVN r25438]
This commit is contained in:
Jonathan Brandmeyer
2004-09-27 20:05:52 +00:00
parent bd74676685
commit 8e396f8e91
3 changed files with 56 additions and 0 deletions

View File

@@ -108,6 +108,7 @@ bpl-test crossmod_exception
[ bpl-test exception_translator ]
[ bpl-test pearu1 : test_cltree.py cltree.cpp ]
[ bpl-test try : newtest.py m1.cpp m2.cpp ]
[ bpl-test const_argument ]
[ bpl-test keywords : keywords.cpp keywords_test.py ]

30
test/const_argument.cpp Normal file
View File

@@ -0,0 +1,30 @@
/* Copyright 2004 Jonathan Brandmeyer
* Use, modification and distribution are subject to the
* Boost Software License, Version 1.0. (See accompanying file
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
* The purpose of this test is to determine if a function can be called from
* Python with a const value type as an argument, and whether or not the
* presence of a prototype without the cv-qualifier will work around the
* compiler's bug.
*/
#include <boost/python.hpp>
using namespace boost::python;
bool accept_const_arg_noproto( const object)
{
return true;
}
bool accept_const_arg_with_proto( object);
bool accept_const_arg_with_proto( const object)
{
return true;
}
BOOST_PYTHON_MODULE( const_argument_ext)
{
def( "accept_const_arg_noproto", accept_const_arg_noproto);
def( "accept_const_arg_with_proto", accept_const_arg_with_proto);
}

25
test/const_argument.py Normal file
View File

@@ -0,0 +1,25 @@
# Copyright Jonathan Brandmeyer, 2004. Distributed under the Boost
# Software License, Version 1.0 (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
"""
>>> from const_argument_ext import *
>>> accept_const_arg_noproto(1)
1
>>> accept_const_arg_with_proto(1)
1
"""
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
status = run()[0]
if (status == 0): print "Done."
sys.exit(status)