Added STRING_OUT typemap test.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5494 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2003-12-06 23:03:30 +00:00
commit e1fd92428f
2 changed files with 30 additions and 0 deletions

View file

@ -39,6 +39,30 @@ public class java_lib_various_runme {
if ( !langs[i].equals(langscheck[i]) )
throw new RuntimeException("Languages read failed " + i + " " + langs[i] + "|" + langscheck[i]);
// STRING_RET test
{
String stringOutArray[] = { "" };
java_lib_various.char_ptr_ptr_out(stringOutArray);
if (!stringOutArray[0].equals("returned string"))
throw new RuntimeException("Test failed: expected: returned string. got: " + stringOutArray[0]);
}
// STRING_RET null array test. Check that exception is thrown.
try {
String stringOutArray[] = null;
java_lib_various.char_ptr_ptr_out(stringOutArray);
throw new RuntimeException("Test failed: null array");
} catch (NullPointerException e) {
}
// STRING_RET empty array test. Check that exception is thrown.
try {
String stringOutArray[] = {};
java_lib_various.char_ptr_ptr_out(stringOutArray);
throw new RuntimeException("Test failed: empty array");
} catch (IndexOutOfBoundsException e) {
}
// BYTE typemap check
byte b[] = new byte[20];
java_lib_various.charout(b);

View file

@ -7,6 +7,7 @@
%apply char **STRING_ARRAY { char **get_names };
%apply char **STRING_ARRAY { char **languages };
%apply char *BYTE { char *chars };
%apply char **STRING_OUT { char **string_ptr };
%{
char *langs[] = { "Hungarian", "Afrikaans", "Norwegian", 0 };
@ -41,5 +42,10 @@ void charout(char *chars) {
sprintf(chars, "by jove");
}
void char_ptr_ptr_out(char **string_ptr) {
static char ret[] = "returned string";
*string_ptr = ret;
}
%}