Initial commit

This commit is contained in:
Bassem Girgis
2018-12-20 17:34:07 -06:00
parent 7a2d899662
commit 81b4b9e273
34743 changed files with 5940233 additions and 0 deletions

View File

@@ -0,0 +1,90 @@
#######################################################################
# Makefile for scilab test-suite
#######################################################################
LANGUAGE = scilab
SCILAB = @SCILAB@
SCILAB_OPT = @SCILABOPT@
SCRIPTSUFFIX = _runme.sci
srcdir = @srcdir@
top_srcdir = ../@top_srcdir@
top_builddir = ../@top_builddir@
C_TEST_CASES += \
scilab_consts \
scilab_identifier_name \
CPP_TEST_CASES += \
inout \
primitive_types \
scilab_li_matrix \
scilab_multivalue \
scilab_enums \
scilab_pointer_conversion_functions \
CPP_STD_TEST_CASES += \
li_std_container_typemaps \
li_std_string_extra \
include $(srcdir)/../common.mk
# Overriden variables
SRCDIR = ../$(srcdir)/
# Local variables
TEST_DIR = $*.dir
RUNME_SCRIPT = $(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)
SRC_RUNME_SCRIPT = $(srcdir)/$(RUNME_SCRIPT)
# Hide too long identifier warnings
SWIGOPT += -w720
# Rules for the different types of tests
%.cpptest:
$(setup)
+(cd $(TEST_DIR) && $(swig_and_compile_cpp))
cd $(TEST_DIR) && $(run_testcase)
%.ctest:
$(setup)
+(cd $(TEST_DIR) && $(swig_and_compile_c))
cd $(TEST_DIR) && $(run_testcase)
%.multicpptest:
$(setup)
+(cd $(TEST_DIR) && $(swig_and_compile_multi_cpp))
cd $(TEST_DIR) && $(run_testcase)
# Copies files and creates directories needed for the test case
setup = \
if [ ! -d $(TEST_DIR) ]; then \
mkdir $(TEST_DIR); \
fi; \
if [ -f $(SRC_RUNME_SCRIPT) ]; then \
echo "$(ACTION)ing $(LANGUAGE) testcase $* (with run test)" ; \
if [ ! -f $(TEST_DIR) ]; then \
cp $(SRC_RUNME_SCRIPT) $(TEST_DIR); \
fi; \
if [ ! -f $(TEST_DIR)/swigtest.start ]; then \
cp $(srcdir)/swigtest.start $(TEST_DIR); \
fi; \
if [ ! -f $(TEST_DIR)/swigtest.quit ]; then \
cp $(srcdir)/swigtest.quit $(TEST_DIR); \
fi; \
else \
echo "$(ACTION)ing $(LANGUAGE) testcase $*" ; \
fi; \
# Runs the testcase. A testcase is only run if
# a file is found which has _runme.sci appended after the testcase name.
run_testcase = \
if [ -f $(RUNME_SCRIPT) ]; then ( \
env LD_LIBRARY_PATH=$(srcdir):$$LD_LIBRARY_PATH $(RUNTOOL) $(SCILAB) $(SCILAB_OPT) -f $(RUNME_SCRIPT); ) \
fi
# Clean: remove the generated files
%.clean:
@rm -rf $(TEST_DIR)
clean:

View File

@@ -0,0 +1,16 @@
exec("swigtest.start", -1);
try
D = new_D();
catch
swigtesterror();
end
if A_do_x(D) <> 1 then swigtesterror(); end
try
delete_D(D);
catch
swigtesterror();
end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,11 @@
exec("swigtest.start", -1);
try
Spam = new_Spam()
catch
swigtesterror();
end
if Foo_blah(Spam)<>0 then swigtesterror; end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,10 @@
exec("swigtest.start", -1);
try
// This call must fail because the constructor does not exist
Spam = new_Spam()
swigtesterror();
catch
end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,10 @@
exec("swigtest.start", -1);
// These calls must fail
ierr = execstr('abstract_foo_meth(1)', 'errcatch');
if ierr == 0 then swigtesterror(); end
ierr = execstr('abstract_bar_meth(1)', 'errcatch');
if ierr == 0 then swigtesterror(); end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,15 @@
exec("swigtest.start", -1);
try
a = new_A_UF();
catch
swigtesterror();
end
try
delete_A_UF(a);
catch
swigtesterror();
end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,17 @@
exec("swigtest.start", -1);
try
e = new_Engine();
catch
swigtesterror();
end
try
a = new_A();
catch
swigtesterror();
end
// TODO: test write method
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,27 @@
exec("swigtest.start", -1);
try
d = new_D();
catch
swigtesterror();
end
try
delete_D(d);
catch
swigtesterror();
end
try
e = new_E();
catch
swigtesterror();
end
try
delete_E(e);
catch
swigtesterror();
end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,39 @@
exec("swigtest.start", -1);
try
baseInt = new_BaseInt();
catch
swigtesterror();
end
try
delete_BaseInt(baseInt);
catch
swigtesterror();
end
try
derivedInt = new_DerivedInt();
catch
swigtesterror();
end
try
delete_DerivedInt(derivedInt);
catch
swigtesterror();
end
try
bottomInt = new_BottomInt();
catch
swigtesterror();
end
try
delete_BottomInt(bottomInt);
catch
swigtesterror();
end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,27 @@
exec("swigtest.start", -1);
try
foo = new_Foo();
catch
swigtesterror();
end
try
foo2 = Foo_blah(foo);
catch
swigtesterror();
end
try
delete_Foo(foo);
catch
swigtesterror();
end
try
delete_Foo(foo2);
catch
swigtesterror();
end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,21 @@
exec("swigtest.start", -1);
if UP_get()<>1 then swigtesterror(); end
if typeof(UP_get())<>"constant" then pause; end
if DOWN_get()<>2 then swigtesterror(); end
if typeof(DOWN_get())<>"constant" then pause; end
if LEFT_get()<>3 then swigtesterror(); end
if typeof(LEFT_get())<>"constant" then pause; end
if RIGHT_get()<>4 then swigtesterror(); end
if typeof(RIGHT_get())<>"constant" then pause; end
// TODO: move is a Scilab function...
//result = move(UP_get());
//result = move(DOWN_get());
//result = move(LEFT_get());
//result = move(RIGHT_get());
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,5 @@
exec("swigtest.start", -1);
// TODO: add tests here
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,80 @@
exec("swigtest.start", -1);
// Class Klass
try
klass = new_Klass("allprotected_klass")
catch
swigtesterror(lasterror());
end
checkequal(Klass_getName(klass), "allprotected_klass", "Klass_getName(new_Klass(""allprotected_klass""))");
// Class PubBase
try
pubBase = new_PubBase("allprotected_PubBase");
catch
swigtesterror(lasterror());
end
checkequal(PubBase_virtualMethod(pubBase), "PublicBase", "PubBase_virtualMethod(pubBase)");
class = PubBase_instanceMethod(pubBase, klass);
checkequal(Klass_getName(class), "allprotected_klass", "Klass_getName(PubBase_instanceMethod(pubBase, klass))");
class = PubBase_instanceOverload(pubBase, klass);
checkequal(Klass_getName(class), "allprotected_klass", "Klass_getName(PubBase_instanceOverloaded(pubBase, klass))");
class = PubBase_instanceOverload(pubBase, klass, "allprotected_klass2");
checkequal(Klass_getName(class), "allprotected_klass2", "Klass_getName(PubBase_instanceOverloaded(pubBase, klass, ""allprotected_klass2""))");
class = PubBase_staticMethod(klass);
checkequal(Klass_getName(class), "allprotected_klass", "Klass_getName(PubBase_staticMethod(klass))");
class = PubBase_staticOverloaded(klass);
checkequal(Klass_getName(class), "allprotected_klass", "Klass_getName(PubBase_staticOverloaded(klass))");
class = PubBase_staticOverloaded(klass, "allprotected_klass3");
checkequal(Klass_getName(class), "allprotected_klass3", "Klass_getName(PubBase_staticOverloaded(klass, ""allprotected_klass3""))");
checkequal(PubBase_EnumVal1_get(), 0, "PubBase_EnumVal1_get()");
checkequal(PubBase_EnumVal2_get(), 1, "(PubBase_EnumVal2_get()");
PubBase_instanceMemb_set(pubBase, 12);
checkequal(PubBase_instanceMemb_get(pubBase), 12, "PubBase_instanceMemb_get(pubBase)");
checkequal(PubBase_staticConstM_get(), 20, "PubBase_staticConstM_get()");
checkequal(PubBase_staticMember_get(), 10, "PubBase_staticMember_get()")
PubBase_stringMember_set(pubBase, "dummy");
checkequal(PubBase_stringMember_get(pubBase), "dummy", "PubBase_stringMember_get()");
// TODO does not work (wrong ENUM mapping?)
//PubBase_anEnum_get(PubBase)
//PubBase_anEnum_set(PubBase, ???)
// Class ProcBase
try
// Constructor is propected and must not be defined here
ProcBase = new_ProctectedBase("allprotected_ProcBase");
swigtesterror();
catch
end
checkequal(ProcBase_EnumVal1_get(), 0, "ProcBase_EnumVal1_get()");
checkequal(ProcBase_EnumVal2_get(), 1, "ProcBase_EnumVal2_get()");
try
delete_Klass(klass);
catch
swigtesterror();
end
try
delete_PubBase(pubBase);
catch
swigtesterror();
end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,60 @@
exec("swigtest.start", -1);
try
foo = new_Foo();
catch
swigtesterror();
end
checkequal(Foo_x_get(foo), 0, "Foo_x_get()");
checkequal(Foo_y_get(foo), 0, "Foo_y_get()");
checkequal(Foo_z_get(foo), 0, "Foo_y_get()");
checkequal(Foo_f_get(foo), 0, "Foo_f_get()");
checkequal(Foo_seq_get(foo), 0, "Foo_seq_get()");
try
Foo_x_set(foo, 5);
catch
swigtesterror();
end
checkequal(Foo_x_get(foo), 5, "Foo_x_get()");
try
Foo_y_set(foo, 5);
catch
swigtesterror();
end
checkequal(Foo_y_get(foo), 5, "Foo_y_get()");
try
Foo_f_set(foo, 1);
catch
swigtesterror();
end
checkequal(Foo_f_get(foo), 1, "Foo_f_get()");
try
Foo_z_set(foo, 13);
catch
swigtesterror();
end
checkequal(Foo_z_get(foo), 13, "Foo_z_get()");
try
Foo_seq_set(foo, 3);
catch
swigtesterror();
end
checkequal(Foo_seq_get(foo), 3, "Foo_seq_get()");
try
delete_Foo(foo);
catch
swigtesterror();
end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,43 @@
exec("swigtest.start", -1);
smallnum = -127;
checkequal(CharValFunction(smallnum), smallnum, "CharValFunction(smallnum)");
checkequal(CCharValFunction(smallnum), smallnum, "CCharValFunction(smallnum)");
checkequal(CCharRefFunction(smallnum), smallnum, "CCharRefFunction(smallnum)");
try
globalchar_set(smallnum);
catch
swigtesterror();
end
checkequal(globalchar_get(), smallnum, "globalchar_get()");
checkequal(globalconstchar_get(), -110, "globalconstchar_get()");
try
dirTest = new_DirTest();
catch
swigtesterror();
end
checkequal(DirTest_CharValFunction(dirTest, smallnum), smallnum, "DirTest_CharValFunction(dirTest, smallnum)");
checkequal(DirTest_CCharValFunction(dirTest, smallnum), smallnum, "DirTest_CCharValFunction(dirTest, smallnum)");
checkequal(DirTest_CCharRefFunction(dirTest, smallnum), smallnum, "DirTest_CCharRefFunction(dirTest, smallnum)");
// TODO Too long identifiers
//if dirTest_memberchar_get(dirTest) <> -111 then swigtesterror(); end
//try
// dirTest_memberchar_set(dirTest, smallnum)
//catch
// swigtesterror();
//end
//if dirTest_memberchar_get(dirTest) <> smallnum then swigtesterror(); end
//if dirTest_memberconstchar_get(dirTest) <> -112 then swigtesterror(); end
try
delete_DirTest(dirTest);
catch
swigtesterror();
end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,45 @@
exec("swigtest.start", -1);
testString = "Scilab test string";
checkequal(UCharFunction(testString), testString, "UCharFunction(testString)");
checkequal(SCharFunction(testString), testString, "SCharFunction(testString)");
checkequal(CUCharFunction(testString), testString, "CUCharFunction(testString)");
checkequal(CSCharFunction(testString), testString, "CSCharFunction(testString)");
//checkequal(CharFunction(testString), testString, "CharFunction(testString)");
//checkequal(CCharFunction(testString), testString, "CCharFunction(testString)");
try
tNum = new_TNum();
catch
swigtesterror();
end
//TNumber_DigitsMemberA_get()
//TNumber_DigitsMemberA_set
//TNumber_DigitsMemberB_get()
//TNumber_DigitsMemberB_set
try
delete_TNum(tNum);
catch
swigtesterror();
end
try
dirTest = new_DirTest();
catch
swigtesterror();
end
checkequal(DirTest_UCharFunction(dirTest, testString), testString, "DirTest_UCharFunction");
checkequal(DirTest_SCharFunction(dirTest, testString), testString, "DirTest_SCharFunction(dirTest, testString)");
checkequal(DirTest_CUCharFunction(dirTest, testString), testString, "DirTest_CUCharFunction(dirTest, testString)");
checkequal(DirTest_CSCharFunction(dirTest, testString), testString, "DirTest_CSharFunction(dirTest, testString)");
//checkequal(DirTest_CharFunction(dirTest, testString), testString, "DirTest_CharFunction(dirTest, testString)");
//checkequal(DirTest_CCharFunction(dirTest, testString), testString, "DirTest_CCharFunction(dirTest, testString)");
try
delete_DirTest(dirTest);
catch
swigtesterror();
end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,16 @@
exec("swigtest.start", -1);
f = new_Foo();
Foo_data_set(f, [0:7]);
checkequal(Foo_data_get(f), [0:7], "Foo_data_get()");
Foo_text_set(f, "abcdefgh");
checkequal(Foo_text_get(f), "abcdefgh", "Foo_text_get()");
delete_Foo(f);
m = new_MyBuff();
MyBuff_x_set(m, [0:11]);
checkequal(MyBuff_x_get(m), [0:11], "MyBuff_x_get()");
delete_MyBuff(m);
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,55 @@
exec("swigtest.start", -1);
// bool
checkequal(arr_bool([%T %F %F %T %F %T %T %T], 8), 5, "arr_bool");
// char
checkequal(arr_char(["charptr"], 7), 756, "arr_char");
// signed char
checkequal(arr_schar([1, 2, 3, 4], 4), 10, "arr_schar");
checkequal(arr_schar(int8([1, 2, 3, 4]), 4), 10, "arr_schar");
// unsigned char
checkequal(arr_uchar([1, 2, 3, 4], 4), 10, "arr_uchar");
checkequal(arr_uchar(uint8([1, 2, 3, 4]), 4), 10, "arr_uchar");
// short
checkequal(arr_short([1, 2, 3, 4], 4), 10, "arr_short");
checkequal(arr_short(int16([1, 2, 3, 4]), 4), 10, "arr_short");
// unsigned short
checkequal(arr_ushort([1, 2, 3, 4], 4), 10, "arr_ushort");
checkequal(arr_ushort(uint16([1, 2, 3, 4]), 4), 10, "arr_ushort");
// int
checkequal(arr_int([1, 2, 3, 4], 4), 10, "arr_int");
checkequal(arr_int(int32([1, 2, 3, 4]), 4), 10, "arr_int");
// unsigned int
checkequal(arr_uint([1, 2, 3, 4], 4), 10, "");
checkequal(arr_uint(uint32([1, 2, 3, 4]), 4), 10, "");
// long
checkequal(arr_long([1, 2, 3, 4], 4), 10, "arr_long");
checkequal(arr_long(int32([1, 2, 3, 4]), 4), 10, "arr_long");
// unsigned long
checkequal(arr_ulong([1, 2, 3, 4], 4), 10, "arr_ulong");
checkequal(arr_ulong(uint32([1, 2, 3, 4]), 4), 10, "arr_ulong");
// long long
// No equivalent in Scilab 5
// unsigned long long
// No equivalent in Scilab 5
// float
a = [1, 2, 3, 4];
checkequal(arr_float(a, 4), 10, "arr_float");
// double
a = [1, 2, 3, 4];
checkequal(arr_double(a, 4), 10, "arr_double");
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,54 @@
exec("swigtest.start", -1);
function testArray(arrayName, arraySetFunc, arrayGetFunc, in_values, ..
expected_out_values)
try
arraySetFunc(in_values);
catch
swigtesterror("error in " + arrayName + "_set()");
end
try
checkequal(arrayGetFunc(), expected_out_values, arrayName + "_get()");
catch
swigtesterror("error in " + arrayName + "_get()");
end
endfunction
m = [-10, 20];
um = [10, 20];
testArray("array_c", array_c_set, array_c_get, ['ab'], ['ab']);
testArray("array_sc", array_sc_set, array_sc_get, m, m);
testArray("array_sc", array_sc_set, array_sc_get, int8(m), m);
testArray("array_uc", array_uc_set, array_uc_get, uint8(um), um);
testArray("array_s", array_s_set, array_s_get, m, m);
testArray("array_s", array_s_set, array_s_get, int16(m), m);
testArray("array_us", array_us_set, array_us_get, uint16(um), um);
testArray("array_i", array_i_set, array_i_get, m, m);
testArray("array_i", array_i_set, array_i_get, int32(m), m);
testArray("array_ui", array_ui_set, array_ui_get, uint32(um), um);
testArray("array_l", array_l_set, array_l_get, m, m);
testArray("array_l", array_l_set, array_l_get, int32(m), m);
testArray("array_ul", array_ul_set, array_ul_get, uint32(um), um);
testArray("array_f", array_f_set, array_f_get, [-2.5, 2.5], [-2.5, 2.5]);
testArray("array_d", array_d_set, array_d_get, [-10.5, 20.4], [-10.5, 20.4]);
checkequal(array_const_i_get(), [10, 20], "array_const_i_get()");
ierr = execstr('array_i_set([0:10]', 'errcatch');
if ierr == 0 then swigtesterror("Overflow error expected"); end
checkequal(BeginString_FIX44a_get(), "FIX.a.a", "BeginString_FIX44a_get()");
checkequal(BeginString_FIX44b_get(), "FIX.b.b", "BeginString_FIX44b_get()");
checkequal(BeginString_FIX44c_get(), "FIX.c.c", "BeginString_FIX44c_get()");
checkequal(BeginString_FIX44d_get(), "FIX.d.d", "BeginString_FIX44d_get()");
BeginString_FIX44b_set(strcat(["12","\0","45"]));
checkequal(BeginString_FIX44b_get(), "12\045", "BeginString_FIX44b_get()");
checkequal(BeginString_FIX44d_get(), "FIX.d.d", "BeginString_FIX44d_get()");
checkequal(BeginString_FIX44e_get(), "FIX.e.e", "BeginString_FIX44e_get()");
checkequal(BeginString_FIX44f_get(), "FIX.f.f", "BeginString_FIX44f_get()");
checkequal(test_a("hello","hi","chello","chi"), "hi", "test_a()");
checkequal(test_b("1234567","hi"), "1234567", "test_b()");
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,12 @@
exec("swigtest.start", -1);
a = [1, 2, 3, 4; 5, 6, 7, 8;]
//try
// array_d_set(a);
//catch
// swigtesterror();
//end
//if array_d_get() <> a then swigtesterror(); end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,20 @@
exec("swigtest.start", -1);
function checkBool(bool_val, expected_bool_val)
if typeof(bool_val) <> "boolean" then swigtesterror(); end
if bool_val <> expected_bool_val then swigtesterror(); end
endfunction
checkBool(constbool_get(), %f);
checkBool(bool1_get(), %t);
checkBool(bool2_get(), %f);
checkBool(bo(%t), %t);
checkBool(bo(%f), %f);
bs = new_BoolSt();
checkBool(BoolSt_m_bool1_get(bs), %t);
checkBool(BoolSt_m_bool2_get(bs), %f);
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,9 @@
exec("swigtest.start", -1);
if CHAR_CONSTANT_get() <> "x" then swigtesterror(); end
if STRING_CONSTANT_get() <> "xyzzy" then swigtesterror(); end
if ESC_CONST_get() <> ascii(1) then swigtesterror(); end
if ia_get() <> ascii('a') then swigtesterror(); end
if ib_get() <> ascii('b') then swigtesterror(); end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,22 @@
exec("swigtest.start", -1);
p = test("test");
if strcmp(p, "test") <> 0 then swigtesterror(); end
p = test_pconst("test");
if strcmp(p, "test_pconst") <> 0 then swigtesterror(); end
f = new_Foo();
p = Foo_test(f, "test");
if strcmp(p,"test") <> 0 then swigtesterror(); end
p = Foo_test_pconst(f, "test");
if strcmp(p,"test_pconst") <> 0 then swigtesterror(); end
p = Foo_test_constm(f, "test");
if strcmp(p,"test_constmethod") <> 0 then swigtesterror(); end
p = Foo_test_pconstm(f, "test");
if strcmp(p,"test_pconstmethod") <> 0 then swigtesterror(); end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,36 @@
exec("swigtest.start", -1);
f1 = new_Foo1(3);
f11 = new_Foo1(f1);
checkequal(Foo1_x_get(f1), Foo1_x_get(f11), "Foo1_x_get(f1) <> Foo1_x_get(f11)");
delete_Foo1(f1);
delete_Foo1(f11);
f8 = new_Foo8();
try
f81 = new_Foo8(f8);
swigtesterror("Foo(f8) called.");
catch
end
bi = new_Bari(5);
bc = new_Bari(bi);
checkequal(Bari_x_get(bi), Bari_x_get(bc), "Bar_x_get(bi) <> Bar_x_get(bc)");
delete_Bari(bi);
delete_Bari(bc);
bd = new_Bard(5);
try
bc = Bard(bd);
swigtesterror("Bard(bd) called.");
catch
end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,64 @@
exec("swigtest.start", -1);
f = new_Foo(4);
checkequal(Foo_num_get(f), 4, "Foo_num_get(f)");
Foo_num_set(f, -17);
checkequal(Foo_num_get(f), -17, "Foo_num_get(f)");
b = new_Bar();
Bar_fptr_set(b, f);
fptr = Bar_fptr_get(b);
checkequal(Foo_num_get(fptr), -17, "Foo_num_get(ftr)");
checkequal(Bar_test(b, -3, fptr), -5, "Bar_test(b, -3, fptr)");
fref = Bar_fref_get(b);
checkequal(Foo_num_get(fref), -4, "Foo_num_get(fref)");
checkequal(Bar_test(b, 12, fref), 23, "Bar_test(b, 12, fref)");
f2 = new_Foo(23);
Bar_fref_set(b, f2);
fref = Bar_fref_get(b);
checkequal(Foo_num_get(fref), 23, "Foo_num_get(fref)");
fval = Bar_fval_get(b);
checkequal(Bar_test(b, 3, fval), 33, "Bar_test(b, 3, fval)");
Bar_fval_set(b, new_Foo(-15));
fval = Bar_fval_get(b);
checkequal(Foo_num_get(fval), -15, "Foo_num_get(fval)");
checkequal(Bar_test(b, 3, fval), -27, "Bar_test(b, 3, fval)");
f3 = Bar_testFoo(b, 12, fref);
checkequal(Foo_num_get(f3), 32, "Foo_num_get(f3)");
// Test globals
f4 = new_Foo(6);
Bar_global_fptr_set(f4);
checkequal(Foo_num_get(Bar_global_fptr_get()), 6, "Foo_num_get(Bar_global_fptr_get())");
checkequal(Foo_num_get(Bar_global_fref_get()), 23, "Foo_num_get(Bar_global_fref_get())");
checkequal(Foo_num_get(Bar_global_fval_get()), 3, "Foo_num_get(Bar_global_fval_get())");
// Test member function pointers
func1_ptr = get_func1_ptr();
func2_ptr = get_func2_ptr();
Foo_num_set(f, 4);
checkequal(Foo_func1(f, 2), 16, "Foo_func1(f, 2)");
checkequal(Foo_func2(f, 2), -8, "Foo_func2(f, 2)");
Foo_func_ptr_set(f, func1_ptr);
checkequal(test_func_ptr(f, 2), 16, "Foo_test_func_ptr(f, 2)");
Foo_func_ptr_set(f, func2_ptr);
checkequal(test_func_ptr(f, 2), -8, "Foo_test_func_ptr(f, 2)");
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,10 @@
exec("swigtest.start", -1);
f = new_Foo();
if Foo_hola_get(f) <> Hello_get() then swigtesterror("Foo_hola_get() <> ""Hello"""); end
Foo_hola_set(f, Hi_get());
if Foo_hola_get(f) <> Hi_get() then swigtesterror("Foo_hola_get() <> ""Hi"""); end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,67 @@
exec("swigtest.start", -1);
checkequal(anonymous(), 7771, "anonymous()");
checkequal(anonymous(1234), 1234, "anonymous(1234)");
checkequal(booltest(), %T, "booltest()");
checkequal(booltest(%T), %T, "booltest(%T)");
checkequal(booltest(%F), %F, "booltest(%T)");
ec = new_EnumClass();
checkequal(EnumClass_blah(ec), %T, "EnumClass_blah(ec)");
checkequal(casts1(), [], "casts1()");
checkequal(casts1("Ciao"), "Ciao", "casts1(""Ciao"")");
checkequal(casts2(), "Hello", "casts2()");
checkequal(chartest1(), 'x', "chartest1()");
checkequal(chartest2(), '', "chartest2()");
checkequal(chartest1('y'), 'y', "chartest1(''y'')");
checkequal(reftest1(), 42, "reftest1()");
checkequal(reftest1(400), 400, "reftest1(400)");
checkequal(reftest2(), "hello", "reftest2()");
// Rename
f = new_Foo();
Foo_newname(f);
Foo_newname(f, 10);
Foo_renamed3arg(f, 10, 10.0);
Foo_renamed2arg(f, 10);
Foo_renamed1arg(f);
delete_Foo(f);
// Static functions
checkequal(Statics_staticmethod(), 10+20+30, "Statics_staticmethod()");
checkequal(Statics_staticmethod(100), 100+20+30, "Statics_staticmethod(100)");
checkequal(Statics_staticmethod(100, 200, 300), 100+200+300, "Statics_staticmethod(100, 200, 300)");
tricky = new_Tricky();
checkequal(Tricky_privatedefault(tricky), 200, "Tricky_privatedefault(tricky)");
checkequal(Tricky_protectedint(tricky), 2000, "Tricky_protectedint(tricky)");
checkequal(Tricky_protecteddouble(tricky), 987.654, "Tricky_protecteddouble(tricky)");
checkequal(Tricky_functiondefault(tricky), 500, "Tricky_functiondefault(tricky)");
checkequal(Tricky_contrived(tricky), 'X', "Tricky_contrived(tricky)");
delete_Tricky(tricky);
// Default argument is a constructor
k = constructorcall();
checkequal(Klass_val_get(k), -1, "Klass_constructorcall()");
delete_Klass(k);
k = constructorcall(new_Klass(2222));
checkequal(Klass_val_get(k), 2222, "Klass_constructorcall(new Klass(2222)");
delete_Klass(k);
k = constructorcall(new_Klass());
checkequal(Klass_val_get(k), -1, "Klass_constructorcall(new_Klass()");
delete_Klass(k);
// Const methods
cm = new_ConstMethods();
checkequal(ConstMethods_coo(cm), 20, "ConstMethods_coo()");
checkequal(ConstMethods_coo(cm, 1.0), 20, "ConstMethods_coo(1.0)");
// C linkage (extern "C")
checkequal(cfunc1(1), 2, "cfunc1(1)");
checkequal(cfunc2(1), 3, "cfunc2(1)");
checkequal(cfunc3(1), 4, "cfunc3(1)");
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,104 @@
exec("swigtest.start", -1);
a = new_A();
delete_A(a);
aa = new_AA();
delete_AA(aa);
try
b = new_B();
swigtestswigtesterror("new_BB created.")
catch
end
del_b = delete_B;
try
bb = new_BB();
swigtesterror("new_BB created.")
catch
end
del_bb = delete_BB;
try
c = new_C();
swigtesterror("new_C created.")
catch
end
del_c = delete_C;
cc = new_CC();
delete_CC(cc);
try
d = new_D();
swigtesterror("new_D created")
catch
end
del_d = delete_D;
try
dd = new_DD();
swigtesterror("new_DD created")
catch
end
dd = delete_DD;
try
ad = new_AD();
swigtesterror("new_AD created")
catch
end
del_ad = delete_AD;
exec("swigtest.start", -1);
e = new_E();
delete_E(e);
ee = new_EE();
delete_EE(ee);
try
eb = new_EB();
swigtesterror("new_EB created")
catch
end
del_eb = delete_EB;
f = new_F();
try
del_f = delete_F;
swigtesterror("delete_F created")
catch
end
F_destroy(f);
g = new_G();
try
del_g = delete_G;
swigtesterror("delete_G created")
catch
end
G_destroy(g);
gg = new_GG();
delete_GG(gg);
hh = new_HH(1,1);
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,3 @@
exec("swigtest.start", -1);
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,3 @@
exec("swigtest.start", -1);
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,39 @@
exec("swigtest.start", -1);
if typeof(CSP_ITERATION_FWD_get()) <> "constant" then swigtesterror(); end
if typeof(CSP_ITERATION_BWD_get()) <> "constant" then swigtesterror(); end
if typeof(ABCDE_get()) <> "constant" then swigtesterror(); end
if typeof(FGHJI_get()) <> "constant" then swigtesterror(); end
try
bar1(CSP_ITERATION_FWD_get())
bar1(CSP_ITERATION_BWD_get())
bar1(1)
bar1(int32(1))
bar2(ABCDE_get())
bar2(FGHJI_get())
bar2(1)
bar2(int32(1))
bar3(ABCDE_get())
bar3(FGHJI_get())
bar3(1)
bar3(int32(1))
catch
swigtesterror()
end
if typeof(enumInstance_get()) <> "constant" then swigtesterror(); end
if enumInstance_get() <> 2 then swigtesterror(); end
if typeof(Slap_get()) <> "constant" then swigtesterror(); end
if Slap_get() <> 10 then swigtesterror(); end
if typeof(Mine_get()) <> "constant" then swigtesterror(); end
if Mine_get() <> 11 then swigtesterror(); end
if typeof(Thigh_get()) <> "constant" then swigtesterror(); end
if Thigh_get() <> 12 then swigtesterror(); end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,8 @@
exec("swigtest.start", -1);
checkequal(call1(ADD_BY_VALUE_get(), 10, 11), 21, "ADD_BY_VALUE");
checkequal(call2(ADD_BY_POINTER_get(), 12, 13), 25, "ADD_BY_POINTER");
checkequal(call3(ADD_BY_REFERENCE_get(), 14, 15), 29, "ADD_BY_REFERENCE");
checkequal(call1(ADD_BY_VALUE_C_get(), 2, 3), 5, "ADD_BY_VALUE_C");
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,6 @@
exec("swigtest.start", -1);
if add(7, 9) <> 16 then swigtesterror(); end
if do_op(7, 9, funcvar_get()) <> 16 then swigtesterror(); end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,31 @@
exec("swigtest.start", -1);
b_set("hello");
checkequal(b_get(), "hello", "b_get()");
sa = new_A();
A_x_set(sa, 5);
checkequal(A_x_get(sa), 5, "A_x_get(sa)");
a_set(sa);
checkequal(A_x_get(a_get()), 5, "A_x_get(a)");
ap_set(sa);
A_x_set(sa, 14);
checkequal(A_x_get(ap_get()), 14, "A_x_get(ap)");
delete_A(sa);
sa2 = new_A();
cap_set(sa2);
A_x_set(sa2, 16);
checkequal(A_x_get(cap_get()), 16, "A_x_get(cap)");
checkequal(A_x_get(ar_get()), 5, "A_x_get(ar)");
ar_set(sa2);
checkequal(A_x_get(ar_get()), 16, "A_x_get(ar)");
delete_A(sa2);
x_set(11);
checkequal(x_get(), 11, "x_get()");
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,20 @@
exec("swigtest.start", -1);
try
a = new_A();
catch
printf("did not find A\ntherefore, I did not include ""testdir/subdir1/hello.i""\n");
swigtesterror();
end
try
b = new_B();
catch
printf("did not find B\ntherefore, I did not include ""testdir/subdir2/hello.i""\n");
swigtesterror();
end
if importtest1(5) <> 15 then swigtesterror(); end
if importtest2("black") <> "white" then swigtesterror(); end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,15 @@
exec("swigtest.start", -1);
a = new_Foo();
b = new_Bar();
c = new_Spam();
checkequal(do_blah(a), "Foo::blah", "do_blah(a)");
checkequal(do_blah(b), "Bar::blah", "do_blah(b)");
checkequal(do_blah(c), "Spam::blah", "do_blah(c)");
delete_Foo(a);
delete_Bar(b);
delete_Spam(c);
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,15 @@
exec("swigtest.start", -1);
a = AddOne1(10);
if a <> 11 then swigtesterror(); end
[a, b, c] = AddOne3(1, 2, 3);
if a <> 2 then swigtesterror(); end
if b <> 3 then swigtesterror(); end
if c <> 4 then swigtesterror(); end
a = AddOne1r(20);
if a <> 21 then swigtesterror(); end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,29 @@
exec("swigtest.start", -1);
// Negative values
checkequal(signed_char_identity(-1), -1, "signed_char_identity(-1)");
checkequal(signed_short_identity(-1), -1, "signed_short_identity(-1)");
checkequal(signed_int_identity(-1), -1, "signed_int_identity(-1)");
checkequal(signed_long_identity(-1), -1, "signed_long_identity(-1)");
// Overflow errors
ierr = execstr('signed_char_identity(2^8)', 'errcatch');
checkequal(ierr, 20007, 'signed_char_identity(2^8)');
ierr = execstr('signed_short_identity(2^16)', 'errcatch');
checkequal(ierr, 20007, 'signed_short_identity(2^16)');
ierr = execstr('signed_int_identity(2^32)', 'errcatch');
checkequal(ierr, 20007, 'signed_int_identity(2^32)');
ierr = execstr('signed_long_identity(2^64)', 'errcatch');
checkequal(ierr, 20007, 'signed_long_identity(2^64)');
// Value errors
ierr = execstr('signed_char_identity(100.2)', 'errcatch');
checkequal(ierr, 20009, 'signed_char_identity(100.2)');
ierr = execstr('signed_short_identity(100.2)', 'errcatch');
checkequal(ierr, 20009, 'signed_short_identity(100.2)');
ierr = execstr('signed_int_identity(100.2)', 'errcatch');
checkequal(ierr, 20009, 'signed_int_identity(100.2)');
ierr = execstr('signed_long_identity(100.2)', 'errcatch');
checkequal(ierr, 20009, 'signed_long_identity(100.2)');
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,11 @@
exec("swigtest.start", -1);
d = new_intArray(10);
intArray_setitem(d, 0, 7);
intArray_setitem(d, 5, intArray_getitem(d, 0) + 3);
checkequal(intArray_getitem(d, 5) + intArray_getitem(d, 0), 17, "d(5) + d(0) <> 17");
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,11 @@
exec("swigtest.start", -1);
d = new_intArray(10);
intArray_setitem(d, 0, 7);
intArray_setitem(d, 5, intArray_getitem(d, 0) + 3);
checkequal(intArray_getitem(d, 5) + intArray_getitem(d, 0), 17, "d(5) + d(0) <> 17");
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,8 @@
exec("swigtest.start", -1);
p = new_intp();
intp_assign(p, 3);
checkequal(intp_value(p), 3, "intp_value(p)");
delete_intp(p);
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,8 @@
exec("swigtest.start", -1);
p = new_intp();
intp_assign(p, 3);
checkequal(intp_value(p), 3, "intp_value(p)");
delete_intp(p);
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,9 @@
exec("swigtest.start", -1);
try
x = fmod(M_PI_get(), M_1_PI_get())
catch
swigtesterror();
end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,108 @@
// test STL containers typemaps
exec("swigtest.start", -1);
function checkerror(ierr, cmd)
if ierr <> 0 then swigtesterror("error " + string(ierr) + " in """ + cmd + """"); end
endfunction
// test container of pointers returned from fonction (expected a list)
function [classAPtr_list, classAPtr1, classAPtr2] = testCreateContainerPtr(container, value1, value2)
classAPtr1 = new_ClassA(value1);
classAPtr2 = new_ClassA(value2);
func = msprintf("ret_ClassAPtr_%s", container);
cmd = msprintf("classAPtr_list = %s(classAPtr1, classAPtr2);", func);
ierr = execstr(cmd, "errcatch");
if ierr <> 0 then swigtesterror("error in " + cmd); end
if ~exists('classAPtr_list') | (size(classAPtr_list) <> 2) then
swigtesterror(func);
end
checkequal(ClassA_a_get(classAPtr_list(1)), value1, "ClassA_a_get(classAPtr_list(1))");
checkequal(ClassA_a_get(classAPtr_list(2)), value2, "ClassA_a_get(classAPtr_list(2))");
endfunction
// test a given container of pointer
// -container: type of container: "vector", "set"...
// -value1, value2: values to store in container
// -expected_accumulate_value: expected value of an accumulation function
// computed on the container
function testContainerPtr(container, value1, value2, expected_accumulate_value)
// test container of pointers returned from flonction (expected a list)
[classAPtr_list, classAPtr1, classAPtr2] = testCreateContainerPtr(container, value1, value2);
// test container passed as value of function
func = msprintf("val_ClassAPtr_%s", container);
cmd = msprintf("classAPtr = %s(classAPtr_list);", func);
ierr = execstr(cmd, "errcatch");
checkerror(ierr, cmd);
checkequal(ClassA_a_get(classAPtr), expected_accumulate_value, func);
// recreate a container
[classAPtr_list, classAPtr1, classAPtr2] = testCreateContainerPtr(container, value1, value2);
// test container passed as reference of function
func = msprintf("ref_ClassAPtr_%s", container);
cmd = msprintf("classAPtr = %s(classAPtr_list);", func);
ierr = execstr(cmd, "errcatch");
checkerror(ierr, cmd);
checkequal(ClassA_a_get(classAPtr), expected_accumulate_value, func);
endfunction
// test a given container of a given primitive type
// -container: type of container: "vector", "set"...
// -value_type: type of element stored in container: "int", ...
// -value1, value2: values to store in container
// -expected_accumulate_value: expected value of an accumulation function
// computed on the container
function testContainerType(container, value_type, value1, value2, ..
expected_returned_container, expected_accumulate_value)
// test container of basic type returned from fonction
func = msprintf("ret_%s_%s", value_type, container);
if value_type == "string" then
cmd = msprintf("c = %s(''%s'', ''%s'');", func, value1, value2);
elseif value_type == "bool" then
cmd = msprintf("c = %s(%s, %s);", func, "%"+string(value1), "%"+string(value2));
else
cmd = msprintf("c = %s(%d, %d);", func, value1, value2);
end
ierr = execstr(cmd, "errcatch");
checkerror(ierr, cmd);
checkequal(c, expected_returned_container, func);
// test container passed as value of function
func = msprintf("val_%s_%s", value_type, container);
cmd = msprintf("s = %s(c);", func);
ierr = execstr(cmd, "errcatch");
checkerror(ierr, cmd);
checkequal(s, expected_accumulate_value, func);
// test container passed as reference of function
func = msprintf("ref_%s_%s", value_type, container);
cmd = msprintf("s = %s(c);", func);
ierr = execstr(cmd, "errcatch");
checkerror(ierr, cmd);
checkequal(s, expected_accumulate_value, func);
endfunction
// test a given container of different types
// -container: type of container: "vector", "set"...
function testContainer(container)
testContainerType(container, "int", 1, 2, [1, 2], 3);
testContainerType(container, "double", 2., 3., [2., 3.], 5.);
testContainerType(container, "float", 2., 3., [2., 3.], 5.);
testContainerType(container, "string", "a", "b", ["a", "b"], "ab");
testContainerType(container, "bool", %F, %T, [%F, %T], %T);
testContainerPtr("vector", 1, 3, 4);
endfunction
testContainer("vector");
testContainer("list");
testContainer("deque");
testContainer("set");
testContainer("multiset");
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,49 @@
exec("swigtest.start", -1);
// Test constructors for std::deque<int>
intDeque = new_IntDeque();
intDeque2 = new_IntDeque(3);
intDeque3 = new_IntDeque(4, 42);
//intDeque4 = new_IntDeque(intDeque3);
// Test constructors for std::deque<double>
doubleDeque = new_DoubleDeque();
doubleDeque2 = new_DoubleDeque(3);
doubleDeque3 = new_DoubleDeque(4, 42.0);
//doubleDeque4 = new_DoubleDeque(doubleDeque3);
// Test constructors for std::deque<Real>
realDeque = new_RealDeque();
realDeque2 = new_RealDeque(3);
realDeque3 = new_RealDeque(4, 42.0);
//realDeque4 = new_RealDeque(realDeque3);
// average() should return the average of all values in a std::deque<int>
IntDeque_push_back(intDeque, 2);
IntDeque_push_back(intDeque, 4);
IntDeque_push_back(intDeque, 6);
avg = average(intDeque);
checkequal(avg, 4.0, "average(intDeque)");
// half shoud return a deque with elements half of the input elements
RealDeque_clear(realDeque);
RealDeque_push_front(realDeque, 2.0);
RealDeque_push_front(realDeque, 4.0);
halfDeque = half(realDeque);
checkequal(halfDeque, [2., 1.], "half(realDeque)");
// same for halve_in_place
//DoubleDeque_clear(doubleDeque);
//DoubleDeque_push_front(doubleDeque, 2.0);
//DoubleDeque_push_front(doubleDeque, 4.0);
//halfDeque2 = halve_in_place(doubleDeque);
//checkequal(halfDeque2, [2., 1.], "halve_in_place(doubleDeque)");
delete_IntDeque(intDeque);
delete_DoubleDeque(doubleDeque);
delete_RealDeque(realDeque);
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,33 @@
exec('swigtest.start', -1);
function checkException(cmd, expected_ierr, expected_error_msg)
ierr = execstr(cmd, 'errcatch');
checkequal(ierr, expected_ierr, cmd + ': ierr');
checkequal(lasterror(), 'SWIG/Scilab: ' + expected_error_msg, cmd + ': msg');
endfunction
t = new_Test();
checkException('Test_throw_bad_exception(t)', 20010, 'SystemError: std::bad_exception');
checkException('Test_throw_domain_error(t)', 20009, 'ValueError: oops');
checkException('Test_throw_exception(t)', 20010, 'SystemError: std::exception');
checkException('Test_throw_invalid_argum(t)', 20009, 'ValueError: oops');
checkException('Test_throw_length_error(t)', 20004, 'IndexError: oops');
checkException('Test_throw_logic_error(t)', 20003, 'RuntimeError: oops');
checkException('Test_throw_out_of_range(t)', 20004, 'IndexError: oops');
checkException('Test_throw_overflow_erro(t)', 20007, 'OverflowError: oops');
checkException('Test_throw_range_error(t)', 20007, 'OverflowError: oops');
checkException('Test_throw_runtime_error(t)', 20003, 'RuntimeError: oops');
delete_Test(t);
exec('swigtest.quit', -1);

View File

@@ -0,0 +1,38 @@
exec("swigtest.start", -1);
function checkPair(pair, expected_first, expected_second, func)
checkequal(IntPair_first_get(pair), expected_first, func + ": first");;
checkequal(IntPair_second_get(pair), expected_second, func + ": second");;
endfunction
intPair = makeIntPair(7, 6);
checkPair(intPair, 7, 6, "makeIntPair()");
intPairPtr = makeIntPairPtr(7, 6);
checkPair(intPairPtr, 7, 6, "makeIntPairPtr()");
intPairRef = makeIntPairRef(7, 6);
checkPair(intPairRef, 7, 6, "makeIntPairRef()");
intPairConstRef = makeIntPairConstRef(7, 6);
checkPair(intPairConstRef, 7, 6, "makeIntPairConstRef()");
// call fns
checkequal(product1(intPair), 42, "product1(intPair)");
checkequal(product2(intPair), 42, "product2(intPair)");
checkequal(product3(intPair), 42, "product3(intPair)")
// also use the pointer version
checkequal(product1(intPairPtr), 42, "product1(intPairPtr)");
checkequal(product2(intPairPtr), 42, "product2(intPairPtr)");
checkequal(product3(intPairPtr), 42, "product3(intPairPtr)");
// or the other types
checkequal(product1(intPairRef), 42, "product1(intPairRef)");
checkequal(product2(intPairRef), 42, "product2(intPairRef)");
checkequal(product3(intPairRef), 42, "product3(intPairRef)");
checkequal(product1(intPairConstRef), 42, "product3(intPairConstRef)");
checkequal(product2(intPairConstRef), 42, "product2(intPairConstRef)");
checkequal(product3(intPairConstRef), 42, "product1(intPairConstRef)");
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,58 @@
exec("swigtest.start", -1);
x = "hello";
// li_std_string tests
// Function tests
checkequal(test_ccvalue(x), x, "test_ccvalue()");
checkequal(test_cvalue(x), x, "test_cvalue(x)");
checkequal(test_value(x), x, "test_value()");
checkequal(test_const_reference(x), x, "test_const_reference(x)");
checkequal(test_reference_input(x), x, "test_reference_input(x)");
checkequal(test_reference_inout(x), x+x, "test_reference_inout(x)");
//checkequal(test_reference_out(), "test_reference_out message", "test_reference_out()");
//checkequal(test_const_pointer_out(), "x", "test_const_pointer_out()");
s = "initial string";
// Global variable tests
checkequal(GlobalString2_get(), "global string 2", "GlobalString2_get()");
GlobalString2_set(s);
checkequal(GlobalString2_get(), s, "GlobalString2_get()");
checkequal(ConstGlobalString_get(), "const global string", "ConstGlobalString_get()");
// Member variable tests
myStructure = new_Structure();
checkequal(Structure_Str2_get(myStructure), "member string 2", "Structure_Str2_get(myStructure)");
Structure_Str2_set(myStructure, s);
checkequal(Structure_Str2_get(myStructure), s, "Structure_Str2_get(myStructure)");
checkequal(Structure_ConstStr_get(myStructure), "const member string", "Structure_ConstStr_get(myStructure)");
checkequal(Structure_StaticStr2_get(), "static member string 2", "Structure_StaticStr2_get()");
Structure_StaticStr2_set(s);
checkequal(Structure_StaticStr2_get(), s, "Structure_StaticStr2_get()");
checkequal(Structure_ConstStati_get(), "const static member string", "Structure_ConstStaticStr_get()");
checkequal(stdstring_empty(), "", "stdstring_empty()");
checkequal(c_empty(), "", "c_empty()");
// li_std_string_extra tests
//checkequal(test_value_basic1(x), x, "");
//checkequal(test_value_basic2(x), x, "");
//checkequal(test_value_basic3(x), x, "");
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,12 @@
exec("swigtest.start", -1);
// TODO: support for STL vectors operator =
iv = new_DoubleVector();
//for i=1:4
// iv(i) = i;
//end
//x = average(iv);
//if x <> 2.5 then swigtesterror(); end
exit
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,116 @@
exec("swigtest.start", -1);
// double
checkequal(in_double(22.22), 22.22, "in_double");
checkequal(inr_double(22.22), 22.22, "inr_double");
checkequal(out_double(22.22), 22.22, "out_double");
checkequal(outr_double(22.22), 22.22, "outr_double");
checkequal(inout_double(22.22), 22.22, "inout_double");
checkequal(inoutr_double(22.22), 22.22, "inoutr_double");
// signed char
checkequal(in_schar(22), 22, "in_schar");
checkequal(inr_schar(22), 22, "inr_schar");
checkequal(out_schar(22), 22, "out_schar");
checkequal(outr_schar(22), 22, "outr_schar");
checkequal(inout_schar(22), 22, "inout_schar");
checkequal(inoutr_schar(22), 22, "inoutr_schar");
// unsigned char
checkequal(in_uchar(uint8(22)), 22, "in_uchar");
checkequal(inr_uchar(uint8(22)), 22, "inr_uchar");
checkequal(out_uchar(uint8(22)), 22, "out_uchar");
checkequal(outr_uchar(uint8(22)), 22, "outr_uchar");
checkequal(inout_uchar(uint8(22)), 22, "inout_uchar");
checkequal(inoutr_uchar(uint8(22)), 22, "inoutr_uchar");
// short
checkequal(in_short(22), 22, "in_short");
checkequal(inr_short(22), 22, "inr_short");
checkequal(out_short(22), 22, "out_short");
checkequal(outr_short(22), 22, "outr_short");
checkequal(inout_short(22), 22, "inout_short");
checkequal(inoutr_short(22), 22, "inoutr_short");
// unsigned short
checkequal(in_ushort(uint16(22)), 22, "in_ushort");
checkequal(inr_ushort(uint16(22)), 22, "in_ushort");
checkequal(out_ushort(uint16(22)), 22, "out_ushort");
checkequal(outr_ushort(uint16(22)), 22, "outr_ushort");
checkequal(inout_ushort(uint16(22)), 22, "inout_ushort");
checkequal(inoutr_ushort(uint16(22)), 22, "inoutr_ushort");
// int
checkequal(in_int(22), 22, "in_int");
checkequal(inr_int(22), 22, "inr_int");
checkequal(out_int(22), 22, "out_int");
checkequal(outr_int(22), 22, "outr_int");
checkequal(inout_int(22), 22, "inout_int");
checkequal(inoutr_int(22), 22, "inoutr_int");
// unsigned int
checkequal(in_uint(uint32(22)), 22, "in_uint");
checkequal(inr_uint(uint32(22)), 22, "inr_uint");
checkequal(out_uint(uint32(22)), 22, "out_uint");
checkequal(outr_uint(uint32(22)), 22, "outr_uint");
checkequal(inout_uint(uint32(22)), 22, "inout_uint");
checkequal(inoutr_uint(uint32(22)), 22, "inoutr_uint");
// long
checkequal(in_long(22), 22, "in_long");
checkequal(inr_long(22), 22, "inr_long");
checkequal(out_long(22), 22, "out_long");
checkequal(outr_long(22), 22, "outr_long");
checkequal(inout_long(22), 22, "inout_long");
checkequal(inoutr_long(22), 22, "inoutr_long");
// unsigned long
checkequal(in_ulong(uint32(22)), 22, "in_ulong");
checkequal(inr_ulong(uint32(22)), 22, "inr_ulong");
checkequal(out_ulong(uint32(22)), 22, "out_ulong");
checkequal(outr_ulong(uint32(22)), 22, "outr_ulong");
checkequal(inout_ulong(uint32(22)), 22, "inout_ulong");
checkequal(inoutr_ulong(uint32(22)), 22, "inoutr_ulong");
// bool
checkequal(in_bool(%t), %t, "in_bool");
checkequal(inr_bool(%f), %f, "inr_bool");
checkequal(out_bool(%t), %t, "out_bool");
checkequal(outr_bool(%f), %f, "outr_bool");
checkequal(inout_bool(%t), %t, "inout_bool");
checkequal(inoutr_bool(%f), %f, "inoutr_bool");
// float
checkequal(in_float(2.5), 2.5, "in_float");
checkequal(inr_float(2.5), 2.5, "inr_float");
checkequal(out_float(2.5), 2.5, "out_float");
checkequal(outr_float(2.5), 2.5, "outr_float");
checkequal(inout_float(2.5), 2.5, "inout_float");
checkequal(inoutr_float(2.5), 2.5, "inoutr_float");
// long long
// Not supported in Scilab 5.5
//checkequal(in_longlong(22), 22, "in_longlong");
//checkequal(inr_longlong(22), 22, "inr_longlong");
//checkequal(out_longlong(22), 22, "out_longlong");
//checkequal(outr_longlong(22), 22, "outr_longlong");
//checkequal(inout_longlong(22), 22, "inout_longlong");
//checkequal(inoutr_longlong(22), 22, "inoutr_longlong");
// unsigned long long
// Not supported in Scilab 5.5
//checkequal(in_ulonglong(uint64(22)), 22, "in_ulonglong");
//checkequal(inr_ulonglong(uint64(22)), 22, "inr_ulonglong");
//checkequal(out_ulonglong(uint64(22)), 22, "out_ulonglong");
//checkequal(outr_ulonglong(uint64(22)), 22, "outr_ulonglong");
//checkequal(inout_ulonglong(uint64(22)), 22, "inout_ulonglong");
//checkequal(inoutr_ulonglong(uint64(22)), 22, "inoutr_ulonglong");
// the others
//a,b = inoutr_int2(1, 2);
//checkequal(a<>1 || b<>2), "");
//f,i = out_foo(10)
//checkequal(f.a, 10 || i, 20), "");
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,20 @@
exec("swigtest.start", -1);
s = new_Square(10);
// Functions
checkequal(do_op(s, areapt()), 100.0, "Square area");
checkequal(do_op(s, perimeterpt()), 40.0, "Square perimeter");
// Variables
checkequal(do_op(s, areavar_get()), 100.0, "Square area");
areavar_set(perimeterpt());
checkequal(do_op(s, areavar_get()), 40.0, "Square perimeter");
// Constants
checkequal(do_op(s, AREAPT_get()), 100.0, "Square area");
checkequal(do_op(s, PERIMPT_get()), 40.0, "Square perimeter");
delete_Square(s);
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,11 @@
exec("swigtest.start", -1);
try
foo_2();
catch
swigtesterror();
end
if bar_2_get() <> 17 then swigtesterror(); end
if Baz_2_get() <> 47 then swigtesterror(); end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,34 @@
exec("swigtest.start", -1);
try
outer = new_Outer();
setValues(outer, 10);
inner1 = Outer_inner1_get(outer);
inner2 = Outer_inner2_get(outer);
inner3 = Outer_inner3_get(outer);
inner4 = Outer_inner4_get(outer);
catch
swigtesterror();
end
checkequal(Outer_inner1_val_get(inner1), 10, "Outer_inner1_val_get(inner1)");
checkequal(Outer_inner1_val_get(inner2), 20, "Outer_inner1_val_get(inner2)");
checkequal(Outer_inner1_val_get(inner3), 20, "Outer_inner1_val_get(inner3)");
checkequal(Outer_inner1_val_get(inner4), 40, "Outer_inner1_val_get(inner4)");
try
inside1 = Outer_inside1_get(outer);
inside2 = Outer_inside2_get(outer);
inside3 = Outer_inside3_get(outer);
inside4 = Outer_inside4_get(outer);
catch
swigtesterror();
end
checkequal(Named_val_get(inside1), 100, "Named_val_get(inside1)");
checkequal(Named_val_get(inside2), 200, "Named_val_get(inside2)");
checkequal(Named_val_get(inside3), 200, "Named_val_get(inside3)");
checkequal(Named_val_get(inside4), 400, "Named_val_get(inside4)");
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,31 @@
exec("swigtest.start", -1);
try
x = makeFoo();
catch
swigtesterror();
end
if fooCount() <> 1 then swigtesterror(); end
try
y = makeFoo();
catch
swigtesterror();
end
if fooCount() <> 2 then swigtesterror(); end
try
delete_Foo(x);
catch
swigtesterror();
end
if fooCount() <> 1 then swigtesterror(); end
try
delete_Foo(y);
catch
swigtesterror();
end
if fooCount() <> 0 then swigtesterror(); end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,7 @@
exec("swigtest.start", -1);
p = getnull();
checkequal(SWIG_this(p), 0, "SWIG_this(p)");
checkequal(func(p), %T, "func(p)");
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,82 @@
exec("swigtest.start", -1);
function checktrue(value, msg)
checkequal(value, %T, msg)
endfunction
a = new_Op();
b = new_Op(5);
c = new_Op(b);
d = new_Op(2);
dd = new_Op();
// Assignment operator
Op_Equal(dd, d);
// Comparison operator
checktrue(Op_NotEqual(a, b), "Op_NotEqual(a, b)");
checktrue(Op_EqualEqual(b, c), "Op_EqualEqual(b, c)");
checktrue(Op_NotEqual(a, d), "Op_NotEqual(a, d)");
checktrue(Op_EqualEqual(d, dd), "Op_EqualEqual(d, dd)");
checktrue(Op_LessThan(a, b), "Op_LessThan(a, b)");
checktrue(Op_LessThanEqual(a, b), "Op_LessThanEqual(a, b)");
checktrue(Op_LessThanEqual(b, c), "Op_LessThanEqual(b, c)");
checktrue(Op_GreaterThanEqual(b, c), "Op_GreaterThanEqual(b, c)");
checktrue(Op_GreaterThan(b, d), "Op_GreaterThan(b, d)");
checktrue(Op_GreaterThanEqual(b, d), "Op_GreaterThanEqual(b, d)");
delete_Op(a);
delete_Op(b);
delete_Op(c);
delete_Op(d);
delete_Op(dd);
f = new_Op(1);
g = new_Op(1);
expop = new_Op();
op = Op_Plus(f, g);
Op_i_set(expop, 2);
checktrue(Op_EqualEqual(op, expop), "Op_Plus(f, g) <> Op(2)");
delete_Op(op);
op = Op_Minus(f, g);
Op_i_set(expop, 0);
checktrue(Op_EqualEqual(op, expop), "Op_Minus(f, g) <> Op(0)");
delete_Op(op);
op = Op_Multiply(f, g);
Op_i_set(expop, 1);
checktrue(Op_EqualEqual(op, expop), "Op_Multiply(f, g) <> Op(1)");
delete_Op(op);
op = Op_Divide(f, g);
Op_i_set(expop, 1);
checktrue(Op_EqualEqual(op, expop), "Op_Divide(f, g) <> Op(1)");
delete_Op(op);
// Unary operator
op = Op_PlusPlusPrefix(new_Op(3));
Op_i_set(expop, 4);
checktrue(Op_EqualEqual(op, expop), "Op_PlusPlusPrefix(op) <> Op(4)");
// Square bracket operator
checkequal(Op_IndexIntoConst(op, uint32(0)), 4, "Op_IndexIntoConst(op, 0) <> 4");
checkequal(Op_IndexIntoConst(op, uint32(1)), 0, "Op_IndexIntoConst(op, 1) <> 0");
// Functor
i = new_Op(3);
checkequal(Op_Functor(i), 3, "Op_Functor(i)");
checkequal(Op_Functor(i, 1), 4, "Op_Functor(i, 1)");
delete_Op(f);
delete_Op(g);
delete_Op(i);
delete_Op(expop);
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,46 @@
exec("swigtest.start", -1);
// Functions
checkequal(foo(int32([1, 2, 3])), "foo:int[SIZE]", "foo(int[SIZE])");
checkequal(foo([1, 2, 3]), "foo:double[SIZE]", "foo(double[SIZE])");
checkequal(foo(["1" "2" "3"]), "foo:char *[SIZE]", "foo(char *[SIZE])");
// Class methods
s = new_Spam();
checkequal(Spam_foo(s, int32([1, 2, 3])), "foo:int[SIZE]", "Spam::foo(int[SIZE])");
checkequal(Spam_foo(s, [1, 2, 3]), "foo:double[SIZE]", "Spam::foo(double[SIZE])");
checkequal(Spam_foo(s, ["1" "2" "3"]), "foo:char *[SIZE]", "Spam::foo(char *[SIZE])");
delete_Spam(s);
// Static class methods
checkequal(Spam_bar(int32([1, 2, 3])), "bar:int[SIZE]", "Spam::bar(int[SIZE])");
checkequal(Spam_bar([1, 2, 3]), "bar:double[SIZE]", "Spam::bar(double[SIZE])");
checkequal(Spam_bar("hello"), "bar:char *[SIZE]", "Spam::bar(char *[SIZE])");
// Constructors
s = new_Spam();
checkequal(Spam_type_get(s), "none", "Spam::Spam()");
delete_Spam(s);
s = new_Spam(int32([1, 2, 3]));
checkequal(Spam_type_get(s), "int[SIZE]", "Spam::Spam(int[SIZE])");
delete_Spam(s);
s = new_Spam([1, 2, 3]);
checkequal(Spam_type_get(s), "double[SIZE]", "Spam::Spam(double[SIZE])");
delete_Spam(s);
s = new_Spam(["1" "2" "3"]);
checkequal(Spam_type_get(s), "char *[SIZE]", "Spam::Spam(char *[SIZE])");
delete_Spam(s);
a = new_ClassA();
b = ClassA_method1(a, [1 2 3]);
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,25 @@
exec("swigtest.start", -1);
NULL = SWIG_ptr(0);
p = new_Pop(NULL);
p = new_Pop(NULL, %T);
checkequal(Pop_hip(p, %T), 701, "Pop_hip(%T)");
checkequal(Pop_hip(p, NULL), 702, "Pop_hip(NULL)");
checkequal(Pop_hop(p, %T), 801, "Pop_hop(%T)");
checkequal(Pop_hop(p, NULL), 805, "Pop_hop(NULL)");
checkequal(Pop_pop(p, %T), 901, "Pop_pop(%T)");
checkequal(Pop_pop(p, NULL), 904, "Pop_pop(NULL)");
checkequal(Pop_pop(p), 905, "Pop_pop()");
checkequal(Pop_bop(p, NULL), 1001, "Pop_bop(NULL)");
checkequal(Pop_bip(p, NULL), 2002, "Pop_bip(%T)");
checkequal(muzak(%T), 3001, "muzak(%T)");
checkequal(muzak(NULL), 3002, "muzak(%T)");
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,10 @@
exec("swigtest.start", -1);
f = new_Foo();
g = new_Foo(f);
delete_Foo(f);
delete_Foo(g);
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,15 @@
exec("swigtest.start", -1);
try
x = new_Foo();
catch
swigtesterror();
end
if Foo_test(x, 1) <> 1 then swigtesterror(); end
if Foo_test(x, "Hello swig!") <> 2 then swigtesterror(); end
if Foo_test(x, 2, 3) <> 3 then swigtesterror(); end
if Foo_test(x, x) <> 30 then swigtesterror(); end
if Foo_test(x, x, 4) <> 24 then swigtesterror(); end
if Foo_test(x, x, 4, 5) <> 9 then swigtesterror(); end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,13 @@
exec("swigtest.start", -1);
//try
// x = new_Foo();
//catch
// swigtesterror();
//end
//if Foo_test(x) <> 0 then swigtesterror(); end
//if Foo_test(x, 1) <> 1 then swigtesterror(); end
//if Foo_test(x, 2, 3) <> 5 then swigtesterror(); end
//if Foo_test(x, "Hello, swig!") <> 2 then swigtesterror(); end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,13 @@
exec("swigtest.start", -1);
//try
// x = new_Foo();
//catch
// swigtesterror();
//end
//if Foo_test(x) <> 0 then swigtesterror(); end
//if Foo_test(x, 1) <> 1 then swigtesterror(); end
//if Foo_test(x, 2, 3) <> 5 then swigtesterror(); end
//if Foo_test(x, "Hello, swig!") <> 2 then swigtesterror(); end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,16 @@
exec("swigtest.start", -1);
nums = new_Nums();
// In overloading in Scilab, double has priority over all other numeric types
checkequal(Nums_over(nums, 0), "double", "Nums_over(nums, 0)");
// Just checkequal if the following are accepted without exceptions being thrown
Nums_doublebounce(nums, %inf);
Nums_doublebounce(nums, -%inf);
Nums_doublebounce(nums, %nan);
delete_Nums(nums);
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,11 @@
exec("swigtest.start", -1);
derived = new_Derived();
checkequal(test(derived), 0, "test(derived)");
checkequal(test2(derived), 1, "test2(derived)");
delete_Derived(derived);
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,75 @@
exec("swigtest.start", -1);
f = new_Foo();
b = new_Bar();
v = malloc_void(32);
// Functions
checkequal(foo(int32(3)), "foo:int", "foo(int)");
checkequal(foo(3), "foo:double", "foo(double)");
checkequal(foo("hello"), "foo:char *", "foo(char* )");
checkequal(foo(f), "foo:Foo *", "foo(Foo *)");
checkequal(foo(b), "foo:Bar *", "foo(Bar *)");
checkequal(foo(v), "foo:void *", "foo(void *)");
// Class methods
s = new_Spam();
checkequal(Spam_foo(s, int32(3)), "foo:int", "Spam::foo(int)");
checkequal(Spam_foo(s, 3), "foo:double", "Spam::foo(double)");
checkequal(Spam_foo(s, "hello"), "foo:char *", "Spam::foo(char *)");
checkequal(Spam_foo(s, f), "foo:Foo *", "Spam::foo(Foo *)");
checkequal(Spam_foo(s, b), "foo:Bar *", "Spam::foo(Bar *)");
checkequal(Spam_foo(s, v), "foo:void *", "Spam::foo(void *)");
delete_Spam(s);
// Static class methods
checkequal(Spam_bar(int32(3)), "bar:int", "Spam::bar(int)");
checkequal(Spam_bar(3.1), "bar:double", "Spam::bar(double)");
checkequal(Spam_bar("hello"), "bar:char *", "Spam::bar(char *)");
checkequal(Spam_bar(f), "bar:Foo *", "Spam::bar(Foo *)");
checkequal(Spam_bar(b), "bar:Bar *", "Spam::bar(Bar *)");
checkequal(Spam_bar(v), "bar:void *", "Spam::bar(void *)");
// Constructors
s = new_Spam();
checkequal(Spam_type_get(s), "none", "Spam::Spam()");
delete_Spam(s);
s = new_Spam(int32(3));
checkequal(Spam_type_get(s), "int", "Spam::Spam(int)");
delete_Spam(s);
s = new_Spam(3.1);
checkequal(Spam_type_get(s), "double", "Spam::Spam(double)");
delete_Spam(s);
s = new_Spam("hello");
checkequal(Spam_type_get(s), "char *", "Spam::Spam(char *)");
delete_Spam(s);
s = new_Spam(f);
checkequal(Spam_type_get(s), "Foo *", "Spam::Spam(Foo *)");
delete_Spam(s);
s = new_Spam(b);
checkequal(Spam_type_get(s), "Bar *", "Spam::Spam(Bar *)");
delete_Spam(s);
s = new_Spam(v);
checkequal(Spam_type_get(s), "void *", "Spam::Spam(void *)");
delete_Spam(s);
delete_Foo(f);
delete_Bar(b);
free_void(v);
a = new_ClassA();
b = ClassA_method1(a, 1);
delete_ClassA(a);
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,13 @@
exec("swigtest.start", -1);
f = new_Foo();
b = new_Bar();
checkequal(spam(f), 1, "spam(f)");
checkequal(spam(b), 2, "spam(b)");
delete_Foo(f);
delete_Bar(b);
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,30 @@
exec("swigtest.start", -1);
checkequal(CONST_INT1_get(), 10, "CONST_INT1");
checkequal(CONST_DOUBLE3_get(), 12.3, "CONST_DOUBLE3");
checkequal(CONST_BOOL1_get(), %T, "CONST_BOOL1");
checkequal(CONST_CHAR_get(), 'x', "CONST_CHAR");
checkequal(CONST_STRING1_get(), "const string", "CONST_STRING1");
// Test global constants can be seen within functions
function test_global()
global CONST_INT1
global CONST_DOUBLE3
global CONST_BOOL1
global CONST_CHAR
global CONST_STRING1
checkequal(CONST_INT1_get(), 10, "CONST_INT1");
checkequal(CONST_DOUBLE3_get(), 12.3, "CONST_DOUBLE3");
checkequal(CONST_BOOL1_get(), %T, "CONST_BOOL1");
checkequal(CONST_CHAR_get(), 'x', "CONST_CHAR");
checkequal(CONST_STRING1_get(), "const string", "CONST_STRING1");
endfunction
test_global();
// Test assignement in enums
checkequal(kValue_get(), 4, "kValue");
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,8 @@
exec("swigtest.start", -1);
if endif_get() <> 1 then swigtesterror(); end
if define_get() <> 1 then swigtesterror(); end
if defined_get() <> 1 then swigtesterror(); end
if 2 * one_get() <> two_get() then swigtesterror(); end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,24 @@
exec("swigtest.start", -1);
checkequal(ref_int(3), 3, "ref_int() test fails.");
checkequal(ref_uint(uint32(3)), 3, "ref_uint() test fails.");
checkequal(ref_short(3), 3, "ref_short() test fails.");
checkequal(ref_ushort(uint16(3)), 3, "ref_ushort() test fails.");
checkequal(ref_long(3), 3, "ref_long() test fails.");
checkequal(ref_ulong(uint32(3)), 3, "ref_ulong() test fails.");
checkequal(ref_schar(3), 3, "ref_schar() test fails.");
checkequal(ref_uchar(uint8(3)), 3, "ref_uchar() test fails.");
checkequal(ref_float(3), 3, "ref_float() test fails.");
checkequal(ref_double(3), 3, "ref_double() test fails.");
checkequal(ref_bool(%T), %T, "ref_bool() test fails.");
checkequal(ref_char('x'), 'x', "ref_char() test fails.");
checkequal(ref_over(0), 0, "ref_over() test fails.");
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,57 @@
exec("swigtest.start", -1);
// Check passing by value
checkequal(val_double(42), 42, "val_double() test fails.");
checkequal(val_float(42), 42, "val_float() test fails.");
checkequal(val_char('a'), 'a', "val_char() test fails.");
checkequal(val_schar(42), 42, "val_schar() test fails.");
checkequal(val_schar(int8(42)), 42, "val_schar() test fails.");
checkequal(val_uchar(uint8(42)), 42, "val_uchar() test fails.");
checkequal(val_short(42), 42, "val_short() test fails.");
checkequal(val_short(int16(42)), 42, "val_short() test fails.");
checkequal(val_ushort(uint16(42)), 42, "val_ushort() test fails.");
checkequal(val_int(42), 42, "val_int() test fails.");
checkequal(val_int(int32(42)), 42, "val_int() test fails.");
checkequal(val_uint(uint32(42)), 42, "val_uint() test fails.");
checkequal(val_long(42), 42, "val_long() test fails.");
checkequal(val_long(int32(42)), 42, "val_long() test fails.");
checkequal(val_ulong(uint32(42)), 42, "val_long() test fails.");
checkequal(val_bool(%t), %t, "val_bool() test fails.");
// longlong is not supported in Scilab 5.x
//checkequal(val_llong(42), 42, "val_llong() test fails.");
//checkequal(val_llong(int64(42)), 42, "val_llong() test fails.");
//checkequal(val_ullong(uint64(42)), 42, "val_ullong() test fails.");
// Check passing by reference
checkequal(ref_char('a'), 'a', "ref_char() test fails.");
checkequal(ref_schar(42), 42, "ref_schar() test fails.");
checkequal(ref_schar(int8(42)), 42, "ref_schar() test fails.");
checkequal(ref_uchar(uint8(42)), 42, "ref_uchar() test fails.");
checkequal(ref_short(42), 42, "ref_short() test fails.")
checkequal(ref_short(int16(42)), 42, "ref_short() test fails.")
checkequal(ref_ushort(uint16(42)), 42, "ref_ushort() test fails.")
checkequal(ref_int(42), 42, "ref_int() test fails.");
checkequal(ref_int(int32(42)), 42, "ref_int() test fails.");
checkequal(ref_uint(uint32(42)), 42, "ref_uint() test fails.");
checkequal(ref_long(42), 42, "ref_long() test fails.");
checkequal(ref_long(int32(42)), 42, "ref_long() test fails.");
checkequal(ref_ulong(uint32(42)), 42, "ref_ulong() test fails.");
checkequal(ref_bool(%t), %t, "ref_bool() test fails.");
// long long is not supported in Scilab 5.x
//checkequal(ref_llong(42), 42, "ref_llong() test fails.");
//checkequal(ref_llong(int64(42)), 42, "ref_llong() test fails.");
//checkequal(ref_ullong(uint64(42)), 42, "ref_ullong() test fails.");
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,28 @@
exec("swigtest.start", -1);
try
a = get_test();
catch
swigtesterror();
end
// Test default values
checkequal(test_myInt_get(a), 100, "test_myInt_get() test fails.");
checkequal(test_myShort_get(a), 200, "test_myShort_get() test fails.");
// Write new values
try
test_myInt_set(a, 42)
test_myShort_set(a, 12)
catch
swigtesterror();
end
// Read new values
checkequal(test_myInt_get(a), 42, "test_myInt_get() test fails.");
checkequal(test_myShort_get(a), 12, "test_myShort_get() test fails.");
// Destroy pointer
delete_test(a);
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,11 @@
exec("swigtest.start", -1);
foo_ptr = Foo_ptr_getPtr();
foo = Foo_ptr___deref__(foo_ptr);
checkequal(Foo_getVal(foo), 17, "Foo_getVal(p)");
foo_ptr = Foo_ptr_getConstPtr();
foo = Foo_ptr___deref__(foo_ptr);
checkequal(Foo_getVal(foo), 17, "Foo_getVal(p)");
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,35 @@
exec("swigtest.start", -1);
checkequal(ICONST0_get(), 42, "ICONST0_get()");
checkequal(FCONST0_get(), 2.1828, "FCONST0_get()");
checkequal(CCONST0_get(), "x", "CCONST0_get()");
//checkequal(CCONST0_2_get(), "\n", "CCONST0_2_get()");
checkequal(SCONST0_get(), "Hello World", "SCONST0_get()");
checkequal(SCONST0_2_get(), """Hello World""", "SCONST0_2_get()");
checkequal(EXPR0_get(), 48.5484, "EXPR0_get()");
checkequal(iconst0_get(), 37, "iconst0_get()");
checkequal(fconst0_get(), 42.2, "fconst0_get()");
checkequal(UNSIGNED0_get(), hex2dec("5FFF"), "UNSIGNED0_get()");
checkequal(LONG0_get(), hex2dec("3FFF0000"), "LONG0_get()");
checkequal(ULONG0_get(), hex2dec("5FF0000"), "ULONG0_get()");
if isdef('BAR0') then swigtesterror("BAR0"); end
checkequal(ICONST1, int32(42), "ICONST1");
checkequal(FCONST1, 2.1828, "FCONST1");
checkequal(CCONST1, "x", "CCONST1");
//checkequal(CCONST1_2, "\n", "CCONST1_2");
checkequal(SCONST1, "Hello World", "SCONST1");
checkequal(SCONST1_2, """Hello World""", "SCONST1_2");
checkequal(EXPR1, 48.5484, "EXPR1");
checkequal(iconst1, int32(37), "iconst1");
checkequal(fconst1, 42.2, "fconst1");
checkequal(UNSIGNED1, uint32(hex2dec("5FFF")), "UNSIGNED1");
checkequal(LONG1, int32(hex2dec("3FFF0000")), "LONG1");
checkequal(ULONG1, uint32(hex2dec("5FF0000")), "ULONG1");
if isdef('BAR1') then swigtesterror("BAR1"); end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,36 @@
exec("swigtest.start", -1);
function checkEnum(enum_val, expected_enum_val)
if typeof(enum_val) <> "constant" then swigtesterror(); end
if enum_val <> expected_enum_val then swigtesterror(); end
endfunction
checkEnum(ENUM_1, 0);
checkEnum(ENUM_2, 1);
checkEnum(ENUM_EXPLICIT_1_1, 5);
checkEnum(ENUM_EXPLICIT_1_2, 6);
checkEnum(ENUM_EXPLICIT_2_1, 0);
checkEnum(ENUM_EXPLICIT_2_2, 10);
checkEnum(ENUM_EXPLICIT_3_1, 2);
checkEnum(ENUM_EXPLICIT_3_2, 5);
checkEnum(ENUM_EXPLICIT_3_3, 8);
checkEnum(TYPEDEF_ENUM_1_1, 21);
checkEnum(TYPEDEF_ENUM_1_2, 22);
checkEnum(TYPEDEF_ENUM_2_1, 31);
checkEnum(TYPEDEF_ENUM_2_2, 32);
checkEnum(ENUM_REF_1, 1);
checkEnum(ENUM_REF_2, 10);
checkEnum(clsEnum_CLS_ENUM_1, 100);
checkEnum(clsEnum_CLS_ENUM_2, 101);
checkEnum(clsEnum_CLS_ENUM_REF_1, 101);
checkEnum(clsEnum_CLS_ENUM_REF_2, 110);
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,29 @@
exec("swigtest.start", -1);
// Test truncating variables, constants, functions identifier names
// not truncated
gvar_identifier_name_set(-101);
checkequal(gvar_identifier_name_get(), -101, "gvar_identifier_name_get()");
checkequal(CONS_IDENTIFIER_NAME_get(), -11, "CONS_IDENTIFIER_NAME_get()");
checkequal(function_identifier_name(), -21, "function_identifier_name()");
// truncated
too_long_gvar_identi_set(101);
checkequal(too_long_gvar_identi_get(), 101, "too_long_variable_id_get()");
checkequal(TOO_LONG_CONST_IDENT_get(), 11, "TOO_LONG_CONST_IDENT_get()");
checkequal(too_long_function_identi(), 21, "too_long_function_identi()");
// Test truncating when %scilabconst mode is activated
checkequal(SC_CONST_IDENTIFIER_NAME, int32(-12), "SC_TOO_LONG_IDENTIF");
checkequal(SC_TOO_LONG_CONST_IDENTI, int32(14), "SC_TOO_LONG_IDENTIF");
// Test truncating in the case of struct
st = new_st();
st_m_identifier_name_set(st, 15);
checkequal(st_m_identifier_name_get(st), 15, "st_m_identifier_name_get(st)");
st_too_long_member_i_set(st, 25);
checkequal(st_too_long_member_i_get(st), 25, "st_too_long_member_i_get(st)");
delete_st(st);
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,67 @@
// test matrix.i library
exec("swigtest.start", -1);
// test matrix passed as output argument from fonction
function test_outMatrix(func, valueType, expectedOutMatrix)
funcName = msprintf("out%s%s", valueType, func);
cmd = msprintf("outMatrix = %s();", funcName);
ierr = execstr(cmd, "errcatch");
if ierr <> 0 then
swigtesterror(msprintf("Error %d in %s", ierr, funcName));
end
checkequal(outMatrix, expectedOutMatrix, funcName);
endfunction
// test matrix passed as input argument of fonction
function test_inMatrix(func, valueType, inMatrix, expectedInValue)
funcName = msprintf("in%s%s", valueType, func);
cmd = msprintf("inValue = %s(inMatrix);", funcName);
ierr = execstr(cmd, "errcatch");
if ierr <> 0 then
swigtesterror(msprintf("Error %d in %s", ierr, funcName));
end
checkequal(inValue, expectedInValue, funcName);
endfunction
// test matrixes passed as input and output arguments of fonction
function test_inoutMatrix(func, valueType, inoutMatrix, expectedInoutMatrix)
funcName = msprintf("inout%s%s", valueType, func);
cmd = msprintf("inoutMatrix = %s(inoutMatrix);", funcName);
ierr = execstr(cmd, "errcatch");
if ierr <> 0 then
swigtesterror(msprintf("Error %d in %s", ierr, funcName));
end
checkequal(inoutMatrix, expectedInoutMatrix, funcName);
endfunction
function test_matrix_typemaps(valueType, ..
expectedOutMatrixDims, expectedOutMatrixSize, ..
expectedInValue, ..
expectedInoutMatrixDims, expectedInoutMatrixSize)
test_outMatrix("MatrixDims", valueType, expectedOutMatrixDims);
test_outMatrix("MatrixSize", valueType, expectedOutMatrixSize);
matrixDims = expectedOutMatrixDims;
matrixSize = expectedOutMatrixSize;
test_inMatrix("MatrixDims", valueType, matrixDims, expectedInValue);
test_inMatrix("MatrixSize", valueType, matrixSize, expectedInValue);
test_inoutMatrix("MatrixDims", valueType, matrixDims, expectedInoutMatrixDims);
test_inoutMatrix("MatrixSize", valueType, matrixSize, expectedInoutMatrixSize);
endfunction
m = [0 3; 1 4; 2 5];
v = [0 1 2 3 4 5];
test_matrix_typemaps("Int", m, v, sum(m), m .* m, v .* v);
test_matrix_typemaps("Double", m, v, sum(m), m .* m, v .* v);
m = ["A" "D"; "B" "E"; "C" "F"];
v = ["A" "B" "C" "D" "E" "F"];
test_matrix_typemaps("CharPtr", m, v, strcat(m), m + m, v + v);
m = [%T %F; %F %T; %T %F];
v = [%T %F %T %F %T %F];
test_matrix_typemaps("Bool", m, v, %T, ~m, ~v);
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,87 @@
exec("swigtest.start", -1);
// OUTPUT
[a, b] = output2();
checkequal(a, 1, "[a, b] = output2(): a");
checkequal(b, 2, "[a, b] = output2(): b");
[ret, a, b] = output2Ret();
checkequal(ret, 3, "[a, b] = output2Ret(): b");
checkequal(a, 1, "[a, b] = output2Ret(): a");
checkequal(b, 2, "[a, b] = output2Ret(): b");
[c, d] = output2Input2(1, 2);
checkequal(c, 2, "[c, d] = output2Input2(1, 2): c");
checkequal(d, 4, "[c, d] = output2Input2(1, 2): d");
[ret, c, d] = output2Input2Ret(1, 2);
checkequal(ret, 6, "[ret, c, d] = output2Input2Ret(1, 2): ret");
checkequal(c, 2, "[ret, c, d] = output2Input2Ret(1, 2): c");
checkequal(d, 4, "[ret, c, d = output2Input2Ret(1, 2): d");
[ret, a, b, c] = output3Input1Ret(10);
checkequal(ret, 10, "[ret, a, b, c] = output3Input1Ret(10): ret");
checkequal(a, 11, "[ret, a, b, c] = output3Input1Ret(10): a");
checkequal(b, 12, "[ret, a, b, c] = output3Input1Ret(10): b");
checkequal(c, 13, "[ret, a, b, c] = output3Input1Ret(10): c");
[ret, a, b, c] = output3Input3Ret(10, 20, 30);
checkequal(ret, 66, "[ret, a, b, c] = output3Input1Ret(10, 20, 30): ret");
checkequal(a, 11, "[ret, a, b, c] = output3Input1Ret(10, 20, 30): a");
checkequal(b, 22, "[ret, a, b, c] = output3Input1Ret(10, 20, 30): b");
checkequal(c, 33, "[ret, a, b, c] = output3Input1Ret(10, 20, 30): c");
// INOUT
[a, b] = inout2(1, 2);
checkequal(a, 2, "[a, b] = output2(1, 2): a");
checkequal(b, 4, "[a, b] = output2(1, 2): b");
[ret, a, b] = inout2Ret(1, 2);
checkequal(ret, 6, "[a, b] = inout2Ret(1, 2): b");
checkequal(a, 2, "[a, b] = inout2Ret(1, 2): a");
checkequal(b, 4, "[a, b] = inout2Ret(1, 2): b");
[c, d] = inout2Input2(1, 2, 1, 1);
checkequal(c, 2, "[c, d] = inout2Input2(1, 2): c");
checkequal(d, 3, "[c, d] = inout2Input2(1, 2): d");
[ret, c, d] = inout2Input2Ret(1, 2, 1, 1);
checkequal(ret, 5, "[c, d] = inout2Input2Ret(1, 2): ret");
checkequal(c, 2, "[c, d] = inout2Input2Ret(1, 2): c");
checkequal(d, 3, "[c, d] = inout2Input2Ret(1, 4): d");
[ret, a, b, c] = inout3Input1Ret(10, 1, 2, 3);
checkequal(ret, 10, "[ret, a, b, c] = output3Input1Ret(ret, 1, 2, 3): ret");
checkequal(a, 11, "[ret, a, b, c] = output3Input1Ret(ret, 1, 2, 3): a");
checkequal(b, 12, "[ret, a, b, c] = output3Input1Ret(ret, 1, 2, 3): b");
checkequal(c, 13, "[ret, a, b, c] = output3Input1Ret(ret, 1, 2, 3): c");
[ret, a, b, c] = inout3Input3Ret(10, 1, 20, 2, 30, 3);
checkequal(ret, 66, "[ret, a, b, c] = output3Input1Ret(10, 20, 30): ret");
checkequal(a, 11, "[ret, a, b, c] = inout3Input1Ret(10, 1, 20, 2, 30, 3): a");
checkequal(b, 22, "[ret, a, b, c] = inout3Input1Ret(10, 1, 20, 2, 30, 3): b");
checkequal(c, 33, "[ret, a, b, c] = inout3Input1Ret(10, 1, 20, 2, 30, 3): c");
// CLASS
a = new_ClassA();
[ret, c, d] = ClassA_output2Input2Ret(a, 1, 2);
checkequal(ret, 6, "[ret, c, d] = ClassA_output2Input2Ret(a, 1, 2): ret");
checkequal(c, 2, "[c, d] = ClassA_output2Input2Ret(a, 1, 2): c");
checkequal(d, 4, "[c, d] = ClassA_output2Input2Ret(a, 1, 2): d");
[ret, c, d] = ClassA_inout2Input2Ret(a, 1, 2, 1, 1);
checkequal(ret, 5, "[ret, c, d] = ClassA_inout2Input2Ret(a, 1, 2): ret");
checkequal(c, 2, "[c, d] = ClassA_inout2Input2(a, 1, 2): c");
checkequal(d, 3, "[c, d] = ClassA_inout2Input2(a, 1, 2): d");
delete_ClassA(a);
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,24 @@
exec("swigtest.start", -1);
// Test on NULL
null = getNull();
checkequal(SWIG_this(null), 0, "SWIG_this(null)");
null = SWIG_ptr(0);
checkequal(isNull(null), %T, "func(null)");
// Test on variable
expected_foo_addr = getFooAddress();
foo_addr = SWIG_this(pfoo_get());
checkequal(foo_addr, expected_foo_addr, "SWIG_this(pfoo_get())");
pfoo = SWIG_ptr(foo_addr);
checkequal(equalFooPointer(pfoo), %T, "equalFooPointer(pfoo)");
// Test conversion of mlist type pointers
stA = new_structA();
checkequal(typeof(stA), "_p_structA");
p = SWIG_ptr(stA);
checkequal(typeof(p), "pointer");
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,12 @@
exec("swigtest.start", -1);
try
initArray();
catch
swigtesterror();
end
if x_get() <> int32([0,1,2,3,4,5,6,7,8,9]) then swigtesterror(); end
if y_get() <> [0/7,1/7,2/7,3/7,4/7,5/7,6/7] then swigtesterror(); end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,11 @@
exec("swigtest.start", -1);
s = 2000;
s = test1(s+1);
s = test2(s+1);
s = test3(s+1);
s = test4(s+1);
if s <> 2004 then swigtesterror(); end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,13 @@
exec("swigtest.start", -1);
f = new_Foo();
b = new_Bar(f);
Bar_x_set(b, 3);
if Bar_x_get(b) <> 3 then swigtesterror(); end
fp = Bar___deref__(b);
Bar_x_set(b, 4);
if Bar_x_get(b) <> 4 then swigtesterror(); end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,31 @@
exec("swigtest.start", -1);
try
x = add(3, 4);
catch
swigtesterror();
end
if x <> 7 then swigtesterror(); end
try
y = subtract(3,4);
catch
swigtesterror();
end
if y <> -1 then swigtesterror(); end
try
z = mul(3,4);
catch
swigtesterror();
end
if z <> 12 then swigtesterror(); end
try
w = divide(3,4);
catch
swigtesterror();
end
if w <> 0 then swigtesterror(); end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,15 @@
exec("swigtest.start", -1);
if StructC_x_get(instanceC1_get()) <> 10 then swigtesterror(); end
if StructD_x_get(instanceD1_get()) <> 10 then swigtesterror(); end
if StructD_x_get(instanceD2_get()) <> 20 then swigtesterror(); end
if StructD_x_get(instanceD3_get()) <> 30 then swigtesterror(); end
if StructE_x_get(instanceE1_get()) <> 1 then swigtesterror(); end
if StructF_x_get(instanceF1_get()) <> 1 then swigtesterror(); end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,11 @@
exec("swigtest.start", -1);
try
a = new_Bar();
Bar_x_set(a,100);
catch
swigtesterror();
end
if Bar_x_get(a) <> 100 then swigtesterror(); end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,16 @@
exec("swigtest.start", -1);
foo = new_Foo();
Foo_x_set(foo, 1);
if Foo_x_get(foo) <> 1 then swigtesterror(); end
bar = new_Bar();
Bar_a_set(bar, foo);
a = Bar_a_get(bar);
if Foo_x_get(a) <> 1 then swigtesterror(); end
Bar_b_set(bar, foo);
b = Bar_b_get(bar);
if Foo_x_get(b) <> 1 then swigtesterror(); end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,2 @@
// Exit from Scilab
exit

View File

@@ -0,0 +1,57 @@
lines(0);
warning('off');
ilib_verbose(0);
// Get test name (used in swigtest.quit file)
[units, typ, names] = file(1);
swigtestname = strsubst(fileparts(names, "fname"), "_runme", "");
// Does the library exists? If not then exit!
libname = "lib" + swigtestname + getdynlibext();
if ~isfile(libname) then
mfprintf(0, "*** LIBRARY NOT FOUND: %s ***\n", libname);
exit(1)
end
// Load library
try
exec("loader.sce", -1);
catch
mfprintf(0, "*** LOADER EXECUTION FAILED ***\n");
exit(1)
end
// Module initialization
try
moduleInit = sprintf("%s_Init()", swigtestname);
execstr(moduleInit);
catch
mfprintf(0, "*** MODULE INIT FAILED ***\n");
exit(1)
end
// Error management function
function swigtesterror(msg)
[lines, names] = where();
if size(lines, '*') > 0
mfprintf(0, "*** TEST FAILED (at line %d) ***\n", lines($));
if argn(2) >= 1 then disp(msg); end
else
mfprintf(0, "*** TEST FAILED ***\n");
end;
exit(1)
endfunction
// Check equal function
function checkequal(returned, expected, message)
if typeof(returned) <> typeof(expected) then
returned_type_msg = ["returned type:"; typeof(returned)];
expected_type_msg = ["expected type:"; typeof(expected)];
swigtesterror([message; returned_type_msg; expected_type_msg]);
end
if ~isequal(returned, expected) then
returned_value_msg = ["returned value:"; string(returned)];
expected_value_msg = ["expected value:"; string(expected)];
swigtesterror([message; returned_value_msg; expected_value_msg]);
end
endfunction

View File

@@ -0,0 +1,8 @@
exec("swigtest.start", -1);
ri = new_RectangleInt();
pi = RectangleInt_getPoint(ri);
x = PointInt_getX(pi);
delete_RectangleInt(ri);
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,15 @@
exec("swigtest.start", -1);
p1 = new_pairii(2, 3);
p2 = new_pairii(p1);
checkequal(pairii_first_get(p2), 2, "pairii_first(p2) test fails.");
checkequal(pairii_second_get(p2), 3, "pairii_second(p2) test fails.");
p3 = new_pairdd(0.5, 2.5);
p4 = new_pairdd(p3);
checkequal(pairdd_first_get(p4), 0.5, "pairdd_first(p4) test fails.");
checkequal(pairdd_second_get(p4), 2.5, "pairdd_second(p4) test fails.");
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,15 @@
exec("swigtest.start", -1);
i = new_iFoo();
checkequal(iFoo_blah_test(i, 4), 4, "iFoo_blah_test(i, 4) test fails");
checkequal(iFoo_spam_test(i, 5), 5, "iFoo_spam_test(i, 5) test fails");
checkequal(iFoo_groki_test(i, 6), 6, "iFoo_groki_test(i, 6) test fails");
delete_iFoo(i);
d = new_dFoo();
checkequal(dFoo_blah_test(d, 4), 4, "dFoo_blah_test(d, 4) test fails");
checkequal(dFoo_spam(d, 5), 5, "dFoo_spam_test(d, 5) test fails");
checkequal(dFoo_grok_test(d, 6), 6, "dFoo_groki_test(d, 6) test fails");
delete_dFoo(d);
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,8 @@
exec("swigtest.start", -1);
checkequal(foo_i_test_get(), 0, "foo_i_test_get() test fails.");
checkequal(foo_d_test_get(), 0, "foo_i_test_get() test fails.");
checkequal(Foo_bar_double(0), 1, "Foo_bar_double() test fails");
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,23 @@
exec("swigtest.start", -1);
function checkException(cmd, expected_error_msg)
ierr = execstr(cmd, 'errcatch');
checkequal(ierr, 20000, cmd + ': ierr');
checkequal(lasterror(), 'SWIG/Scilab: ' + expected_error_msg, cmd + ': msg');
endfunction
foo = new_Foo();
checkException('Foo_test_int(foo)', 'Exception (int) occured: 37');
checkException('Foo_test_msg(foo)', 'Exception (char const *) occured: Dead');
checkException('Foo_test_multi(foo, 1)', 'Exception (int) occured: 37');
checkException('Foo_test_multi(foo, 2)', 'Exception (char const *) occured: Dead');
checkException('Foo_test_cls(foo)', 'Exception (CError) occured.');
delete_Foo(foo);
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,29 @@
exec("swigtest.start", -1);
try
x = new_LineObj();
LineObj_numpoints_set(x, 100);
catch
swigtesterror();
end
if LineObj_numpoints_get(x) <> 100 then swigtesterror(); end
if MS_NOOVERRIDE_get() <> -1111 then swigtesterror(); end
try
y = make_a();
A_t_a_set(y, 200);
catch
swigtesterror();
end
if A_t_a_get(y) <> 200 then swigtesterror(); end
try
A_t_b_set(y, 300);
catch
swigtesterror();
end
if A_t_b_get(y) <> 300 then swigtesterror(); end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,29 @@
exec("swigtest.start", -1);
try
x = new_LineObj();
LineObj_numpoints_set(x, 100);
catch
swigtesterror();
end
if LineObj_numpoints_get(x) <> 100 then swigtesterror(); end
if MS_NOOVERRIDE_get() <> -1111 then swigtesterror(); end
try
y = make_a();
A_t_a_set(y, 200);
catch
swigtesterror();
end
if A_t_a_get(y) <> 200 then swigtesterror(); end
try
A_t_b_set(y, 300);
catch
swigtesterror();
end
if A_t_b_get(y) <> 300 then swigtesterror(); end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,35 @@
// Some lines are commented out because of too long identifiers...
exec("swigtest.start", -1);
event = new_SDL_Event();
for i=1:2
evAvailable = SDL_PollEvent(event);
evType = SDL_Event_type_get(event);
if evType==1 then
specEvent = SDL_Event_active_get(event);
_type = SDL_ActiveEvent_type_get(specEvent);
if _type <> evType then swigtesterror(); end
gain = SDL_ActiveEvent_gain_get(specEvent);
//state = SDL_ActiveEvent_state_get(specEvent);
end
if evType==2 then
specEvent = SDL_Event_key_get(event);
//_type = SDL_KeyboardEvent_type_get(specEvent);
//if _type <> evType then swigtesterror(); end
//_which = SDL_KeyboardEvent_which_get(specEvent);
//state = SDL_KeyboardEvent_state_get(specEvent);
end
end
delete_SDL_Event(event);
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,23 @@
exec("swigtest.start", -1);
try
small = new_SmallStruct();
SmallStruct_jill_set(small, 200);
big = new_BigStruct();
BigStruct_jack_set(big, 300);
Jill = SmallStruct_jill_get(small);
catch
swigtesterror();
end
if Jill <> 200 then swigtesterror(); end
try
Jack = BigStruct_jack_get(big);
catch
swigtesterror();
end
if Jack <> 300 then swigtesterror(); end
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,21 @@
exec("swigtest.start", -1);
checkequal(vararg_over1("Hello"), "Hello", "vararg_over1(""Hello"")");
checkequal(vararg_over1(2), "2", "vararg_over1(2)");
checkequal(vararg_over2("Hello"), "Hello", "vararg_over1(""Hello"")");
checkequal(vararg_over2(2, 2.2), "2 2.2", "vararg_over2(2, 2.2)")
checkequal(vararg_over3("Hello"), "Hello", "vararg_over3(""Hello"")");
checkequal(vararg_over3(2, 2.2, "hey"), "2 2.2 hey", "vararg_over3(2, 2.2, ""hey"")");
checkequal(vararg_over4("Hello"), "Hello", "vararg_over4(""Hello"")");
checkequal(vararg_over4(123), "123", "vararg_over4(123)");
checkequal(vararg_over4("Hello", 123), "Hello", "vararg_over4(""Hello"", 123)");
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,17 @@
exec("swigtest.start", -1);
checkequal(test("Hello"), "Hello", "test(""Hello"")");
f = new_Foo("Greetings");
checkequal(Foo_str_get(f), "Greetings", "new_Foo(""Greetings"")");
checkequal(Foo_test(f, "Hello"), "Hello", "Foo_test(f)");
delete_Foo(f);
checkequal(Foo_statictest("Hello", 1), "Hello", "Foo_statictest(""Hello"", 1)");
checkequal(test_def("Hello", 1), "Hello", "test_def(""Hello"", 1)");
checkequal(test_def("Hello"), "Hello", "test_def(""Hello"")");
exec("swigtest.quit", -1);

View File

@@ -0,0 +1,22 @@
exec("swigtest.start", -1);
globalfunc();
f = new_Foo();
Foo_memberfunc(f);
Foo_staticmemberfunc();
v1 = vfunc1(f);
checkequal(SWIG_this(v1), SWIG_this(f), "vfunc1(f) <> f");
v2 = vfunc2(f);
checkequal(SWIG_this(v2), SWIG_this(f), "vfunc2(f) <> f");
v3 = vfunc3(v1);
checkequal(SWIG_this(v3), SWIG_this(f), "vfunc3(f) <> f");
Foo_memberfunc(v3);
exec("swigtest.quit", -1);