scilab: use checkequal() in tests

This commit is contained in:
Simon Marchetto 2014-06-16 10:04:53 +02:00
commit 4ba4591dba
2 changed files with 40 additions and 41 deletions

View file

@ -2,57 +2,56 @@ exec("swigtest.start", -1);
// Check passing by value
if (val_double(42) <> 42) then swigtesterror(); end
if (val_float(42) <> 42) then swigtesterror(); end
checkequal(val_double(42), 42, "val_double() test fails.");
checkequal(val_float(42), 42, "val_float() test fails.");
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
if (val_uchar(uint8(42)) <> uint8(42)) then swigtesterror(); end
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)), uint8(42), "val_uchar() test fails.");
if (val_short(42) <> 42) then swigtesterror(); end
if (val_short(int16(42)) <> 42) then swigtesterror(); end
if (val_ushort(uint16(42)) <> uint16(42)) then swigtesterror(); end
checkequal(val_short(42), 42, "val_short() test fails.");
checkequal(val_short(int16(42)), 42, "val_short() test fails.");
checkequal(val_ushort(uint16(42)), uint16(42), "val_ushort() test fails.");
if (val_int(42) <> 42) then swigtesterror(); end
if (val_int(int32(42)) <> 42) then swigtesterror(); end
if (val_uint(uint32(42)) <> uint32(42)) then swigtesterror(); end
checkequal(val_int(42), 42, "val_int() test fails.");
checkequal(val_int(int32(42)), 42, "val_int() test fails.");
checkequal(val_uint(uint32(42)), uint32(42), "val_uint() test fails.");
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
checkequal(val_long(42), 42, "val_long() test fails.");
checkequal(val_long(int32(42)), 42, "val_long() test fails.");
checkequal(val_ulong(uint32(42)), uint32(42), "val_long() test fails.");
if (val_bool(%t) <> %t) then swigtesterror(); end
checkequal(val_bool(%t), %t, "val_bool() test fails.");
// longlong is not supported in Scilab 5.x
//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
//checkequal(val_llong(42), 42, "val_llong() test fails.");
//checkequal(val_llong(int64(42)), 42, "val_llong() test fails.");
//checkequal(val_ullong(uint64(42)), uint64(42), "val_ullong() test fails.");
// Check passing by reference
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
if (ref_uchar(uint8(42)) <> uint8(42)) then swigtesterror(); end
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)), uint8(42), "ref_uchar() test fails.");
if (ref_short(42) <> 42) then swigtesterror(); end
if (ref_short(int16(42)) <> 42) then swigtesterror(); end
if (ref_ushort(uint16(42)) <> uint16(42)) then swigtesterror(); end
checkequal(ref_short(42), 42, "ref_short() test fails.")
checkequal(ref_short(int16(42)), 42, "ref_short() test fails.")
checkequal(ref_ushort(uint16(42)), uint16(42), "ref_ushort() test fails.")
if (ref_int(42) <> 42) then swigtesterror(); end
if (ref_int(int32(42)) <> 42) then swigtesterror(); end
if (ref_uint(uint32(42)) <> uint32(42)) then swigtesterror(); end
checkequal(ref_int(42), 42, "ref_int() test fails.");
checkequal(ref_int(int32(42)), 42, "ref_int() test fails.");
checkequal(ref_uint(uint32(42)), uint32(42), "ref_uint() test fails.");
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
checkequal(ref_long(42), 42, "ref_long() test fails.");
checkequal(ref_long(int32(42)), 42, "ref_long() test fails.");
checkequal(ref_ulong(uint32(42)), uint32(42), "ref_ulong() test fails.");
if (ref_bool(%t) <> %t) then swigtesterror(); end
checkequal(ref_bool(%t), %t, "ref_bool() test fails.");
// long long is not supported in Scilab 5.x
//if (ref_llong(42) <> 42) then swigtesterror(); end
//if (ref_llong(int64(42)) <> 42) then swigtesterror(); end
//if (ref_ullong(uint64(42)) <> uint64(42)) then swigtesterror(); end
//checkequal(ref_llong(42), 42, "ref_llong() test fails.");
//checkequal(ref_llong(int64(42)), 42, "ref_llong() test fails.");
//checkequal(ref_ullong(uint64(42)), uint64(42), "ref_ullong() test fails.");
exec("swigtest.quit", -1);

View file

@ -7,8 +7,8 @@ catch
end
// Test default values
if test_myInt_get(a) <> 100 then swigtesterror(); end
if test_myShort_get(a) <> 200 then swigtesterror(); end
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
@ -19,8 +19,8 @@ catch
end
// Read new values
if test_myInt_get(a) <> 42 then swigtesterror(); end
if test_myShort_get(a) <> 12 then swigtesterror(); end
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);