PageRenderTime 30ms CodeModel.GetById 2ms app.highlight 22ms RepoModel.GetById 2ms app.codeStats 0ms

/trunk/Examples/test-suite/d/li_typemaps_runme.1.d

#
D | 94 lines | 73 code | 11 blank | 10 comment | 36 complexity | e4abac65e1b41304d83bfaced3593fac MD5 | raw file
 1/// Tests correct handling of a few INPUT/OUTPUT/INOUT-typemapped functions.
 2module li_typemaps_runme;
 3
 4import li_typemaps.li_typemaps;
 5
 6void main() {
 7  // Check double INPUT typemaps
 8  if (in_double(22.22) != 22.22) raiseError("in_double");
 9  if (inr_double(22.22) != 22.22) raiseError("inr_double");
10
11  // Check double OUTPUT typemaps
12  {
13    double var = 44.44;
14    out_double(22.22, var);
15    if (var != 22.22) raiseError("out_double");
16  }
17  {
18    double var = 44.44;
19    outr_double(22.22, var);
20    if (var != 22.22) raiseError("outr_double");
21  }
22
23  // Check double INOUT typemaps
24  {
25    double var = 44.44;
26    inout_double(var);
27    if (var != 44.44) raiseError("inout_double");
28  }
29  {
30    double var = 44.44;
31    inoutr_double(var);
32    if (var != 44.44) raiseError("inoutr_double");
33  }
34
35  // Check unsigned long long INPUT typemaps
36  if (in_ulonglong(20) != 20) raiseError("in_ulonglong");
37  if (inr_ulonglong(20) != 20) raiseError("inr_ulonglong");
38
39  // Check unsigned long long OUTPUT typemaps
40  {
41    ulong var = 40;
42    out_ulonglong(20, var);
43    if (var != 20) raiseError("out_ulonglong");
44  }
45  {
46    ulong var = 40;
47    outr_ulonglong(20, var);
48    if (var != 20) raiseError("outr_ulonglong");
49  }
50
51  // Check unsigned long long INOUT typemaps
52  {
53    ulong var = 40;
54    inout_ulonglong(var);
55    if (var != 40) raiseError("inout_ulonglong");
56  }
57  {
58    ulong var = 40;
59    inoutr_ulonglong(var);
60    if (var != 40) raiseError("inoutr_ulonglong");
61  }
62
63  // Check unsigned bool INPUT typemaps
64  if (in_bool(false) != false) raiseError("in_bool");
65  if (inr_bool(false) != false) raiseError("inr_bool");
66
67  // Check unsigned bool OUTPUT typemaps
68  {
69    bool var = false;
70    out_bool(true, var);
71    if (var != true) raiseError("out_bool");
72  }
73  {
74    bool var = false;
75    outr_bool(true, var);
76    if (var != true) raiseError("outr_bool");
77  }
78
79  // Check unsigned bool INOUT typemaps
80  {
81    bool var = false;
82    inout_bool(var);
83    if (var != false) raiseError("inout_bool");
84  }
85  {
86    bool var = false;
87    inoutr_bool(var);
88    if (var != false) raiseError("inoutr_bool");
89  }
90}
91
92void raiseError(char[] funcName) {
93  throw new Exception("Test FAILED for function " ~ funcName);
94}