PageRenderTime 8ms CodeModel.GetById 2ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/lua/li_typemaps_runme.lua

#
Lua | 40 lines | 38 code | 1 blank | 1 comment | 0 complexity | 38306dd2bcd908eac4941edbb198df57 MD5 | raw file
 1require("import")	-- the import fn
 2import("li_typemaps")	-- import code
 3
 4-- catch "undefined" global variables
 5setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
 6
 7-- Check double INPUT typemaps
 8assert(li_typemaps.in_double(22.22) == 22.22)
 9assert(li_typemaps.inr_double(22.22) == 22.22)
10
11-- Check double OUTPUT typemaps
12assert(li_typemaps.out_double(22.22) == 22.22)
13assert(li_typemaps.outr_double(22.22) == 22.22)
14
15-- Check double INOUT typemaps
16assert(li_typemaps.inout_double(22.22) == 22.22)
17assert(li_typemaps.inoutr_double(22.22) == 22.22)
18
19-- check long long
20assert(li_typemaps.in_ulonglong(20)==20)
21assert(li_typemaps.inr_ulonglong(20)==20)
22assert(li_typemaps.out_ulonglong(20)==20)
23assert(li_typemaps.outr_ulonglong(20)==20)
24assert(li_typemaps.inout_ulonglong(20)==20)
25assert(li_typemaps.inoutr_ulonglong(20)==20)
26
27-- check bools
28assert(li_typemaps.in_bool(true)==true)
29assert(li_typemaps.inr_bool(false)==false)
30assert(li_typemaps.out_bool(true)==true)
31assert(li_typemaps.outr_bool(false)==false)
32assert(li_typemaps.inout_bool(true)==true)
33assert(li_typemaps.inoutr_bool(false)==false)
34
35-- the others
36a,b=li_typemaps.inoutr_int2(1,2)
37assert(a==1 and b==2)
38
39f,i=li_typemaps.out_foo(10)
40assert(f.a==10 and i==20)