add argcargv test
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5708 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
f16583559c
commit
5291809136
2 changed files with 43 additions and 0 deletions
20
SWIG/Examples/test-suite/python/argcargvtest.i
Normal file
20
SWIG/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
SWIG/Examples/test-suite/python/argcargvtest_runme.py
Normal file
23
SWIG/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