scilab: check value and overflow errors in integer typemaps

This commit is contained in:
Simon Marchetto 2014-02-07 11:53:19 +01:00
commit ccab675c57
5 changed files with 97 additions and 42 deletions

View file

@ -1,6 +1,10 @@
exec("swigtest.start", -1);
// Check passing by value
if (val_double(42) <> 42) then swigtesterror(); end
if (val_float(42) <> 42) then swigtesterror(); end
if (val_char('a') <> 'a') then swigtesterror(); end
if (val_schar(42) <> 42) then swigtesterror(); end
if (val_schar(int8(42)) <> 42) then swigtesterror(); end
@ -18,18 +22,17 @@ if (val_long(42) <> 42) then swigtesterror(); end
if (val_long(int32(42)) <> 42) then swigtesterror(); end
if (val_ulong(uint32(42)) <> uint32(42)) then swigtesterror(); end
if (val_bool(%t) <> %t) then swigtesterror(); end
//if (val_bool(1) <> %t) then swigtesterror(); end
//if (val_llong(42) <> 42) then swigtesterror(); end
//if (val_llong(int64(42)) <> 42) then swigtesterror(); end
//if (val_ullong(uint64(42)) <> uint64(42)) then swigtesterror(); end
if (val_float(42) <> 42) then swigtesterror(); end
if (val_double(42) <> 42) then swigtesterror(); end
if (val_bool(%t) <> %t) then swigtesterror(); end
//if (val_bool(1) <> %t) then swigtesterror(); end
// Check passing by reference
//if (ref_float(42) <> 42) then swigtesterror(); end
//if (ref_double(42) <> 42) then swigtesterror(); end
if (ref_char('a') <> 'a') then swigtesterror(); end
if (ref_schar(42) <> 42) then swigtesterror(); end
if (ref_schar(int8(42)) <> 42) then swigtesterror(); end
@ -47,15 +50,31 @@ if (ref_long(42) <> 42) then swigtesterror(); end
if (ref_long(int32(42)) <> 42) then swigtesterror(); end
if (ref_ulong(uint32(42)) <> uint32(42)) then swigtesterror(); end
if (ref_bool(%t) <> %t) then swigtesterror(); end
//if (ref_bool(1) <> %t) then swigtesterror(); end
//if (ref_llong(42) <> 42) then swigtesterror(); end
//if (ref_llong(int64(42)) <> 42) then swigtesterror(); end
//if (ref_ullong(42) <> 42) then swigtesterror(); end
//if (ref_ullong(uint64(42)) <> uint64(42)) then swigtesterror(); end
//if (ref_float(42) <> 42) then swigtesterror(); end
//if (ref_double(42) <> 42) then swigtesterror(); end
// check errors
ierr = execstr('val_schar(2^9)', 'errcatch');
if ierr <> 999 then swigtesterror(); end
ierr = execstr('val_schar(100.2)', 'errcatch');
if ierr <> 999 then swigtesterror(); end
ierr = execstr('val_short(2^17)', 'errcatch');
if ierr <> 999 then swigtesterror(); end
ierr = execstr('val_short(100.2)', 'errcatch');
if ierr <> 999 then swigtesterror(); end
ierr = execstr('val_int(2^33)', 'errcatch');
if ierr <> 999 then swigtesterror(); end
ierr = execstr('val_int(100.2)', 'errcatch');
if ierr <> 999 then swigtesterror(); end
ierr = execstr('val_long(2^65)', 'errcatch');
if ierr <> 999 then swigtesterror(); end
ierr = execstr('val_long(100.2)', 'errcatch');
if ierr <> 999 then swigtesterror(); end
if (ref_bool(%t) <> %t) then swigtesterror(); end
//if (ref_bool(1) <> %t) then swigtesterror(); end
exec("swigtest.quit", -1);