PageRenderTime 9ms CodeModel.GetById 2ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

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

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