add argcargv test
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5708 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
4e3d516cee
commit
2c15a0a2b1
2 changed files with 43 additions and 0 deletions
20
Examples/test-suite/python/argcargvtest.i
Normal file
20
Examples/test-suite/python/argcargvtest.i
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
%module argcargvtest
|
||||
|
||||
%include <argcargv.i>
|
||||
|
||||
%apply (int ARGC, char **ARGV) { (size_t argc, const char **argv) }
|
||||
|
||||
%inline %{
|
||||
|
||||
int mainc(size_t argc, const char **argv)
|
||||
{
|
||||
return argc;
|
||||
}
|
||||
|
||||
const char* mainv(size_t argc, const char **argv, int idx)
|
||||
{
|
||||
return argv[idx];
|
||||
}
|
||||
|
||||
|
||||
%}
|
||||
23
Examples/test-suite/python/argcargvtest_runme.py
Normal file
23
Examples/test-suite/python/argcargvtest_runme.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
from argcargvtest import *
|
||||
|
||||
largs=['hi','hola','hello']
|
||||
if mainc(largs) != 3:
|
||||
raise RuntimeError, "bad main typemap"
|
||||
|
||||
targs=('hi','hola')
|
||||
if mainv(targs,1) != 'hola':
|
||||
raise RuntimeError, "bad main typemap"
|
||||
|
||||
targs=('hi', 'hola')
|
||||
if mainv(targs,1) != 'hola':
|
||||
raise RuntimeError, "bad main typemap"
|
||||
|
||||
try:
|
||||
error = 0
|
||||
mainv('hello',1)
|
||||
error = 1
|
||||
except TypeError:
|
||||
pass
|
||||
if error:
|
||||
raise RuntimeError, "bad main typemap"
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue