]> git.uio.no Git - u/mrichter/AliRoot.git/blame - SHUTTLE/test/TestAliSimpleValue.C
small fix
[u/mrichter/AliRoot.git] / SHUTTLE / test / TestAliSimpleValue.C
CommitLineData
73abe331 1void TestAliSimpleValue() {
2
3 gSystem->Load("libSHUTTLE");
4
5 // Bool
6 AliSimpleValue a(AliSimpleValue::kBool);
7 Assert(a.GetType() == AliSimpleValue::kBool);
8 a.SetBool(kTRUE);
9 Assert(a.GetBool() == kTRUE);
10
11 // equal
12 AliSimpleValue b(kTRUE);
13 Assert(a == b);
14
15 // copy constructor
16 AliSimpleValue c(a);
17 Assert(b == c);
18
19 // set
20 a = AliSimpleValue(kFALSE);
21 Assert(a.GetBool() == kFALSE);
22
23
24 // Byte
25 AliSimpleValue a(AliSimpleValue::kByte);
26 Assert(a.GetType() == AliSimpleValue::kByte);
27 a.SetByte(30);
28 Assert(a.GetByte() == 30);
29
30 // equal
31 AliSimpleValue b((Char_t) 30);
32 Assert(b.GetType() == AliSimpleValue::kByte);
33 Assert(a == b);
34
35 // copy constructor
36 AliSimpleValue c(a);
37 Assert(b == c);
38
39 // set
40 a = AliSimpleValue((Char_t) 60);
41 Assert(a.GetByte() == 60);
42
43
44 // Int
45 AliSimpleValue a(AliSimpleValue::kInt);
46 Assert(a.GetType() == AliSimpleValue::kInt);
47 a.SetInt(30);
48 Assert(a.GetInt() == 30);
49
50 // equal
51 AliSimpleValue b(30);
52 Assert(b.GetType() == AliSimpleValue::kInt);
53 Assert(a == b);
54
55 // copy constructor
56 AliSimpleValue c(a);
57 Assert(b == c);
58
59 // set
60 a = AliSimpleValue(60);
61 Assert(a.GetInt() == 60);
62
63
64 // UInt
65 AliSimpleValue a(AliSimpleValue::kUInt);
66 Assert(a.GetType() == AliSimpleValue::kUInt);
67 a.SetUInt(30000);
68 Assert(a.GetUInt() == 30000);
69
70 // equal
71 AliSimpleValue b((UInt_t) 30000);
72 Assert(b.GetType() == AliSimpleValue::kUInt);
73 Assert(a == b);
74
75 // copy constructor
76 AliSimpleValue c(a);
77 Assert(b == c);
78
79 // set
80 a = AliSimpleValue((UInt_t) 60);
81 Assert(a.GetUInt() == 60);
82
83
84 // Float
85 AliSimpleValue a(AliSimpleValue::kFloat);
86 Assert(a.GetType() == AliSimpleValue::kFloat);
87 a.SetFloat(100.53);
88 Float_t delta = 1e-38;
89 Assert((a.GetFloat() <= 100.53 + delta) || (a.GetFloat() >= 100.53 - delta));
90
91 // equal
92 AliSimpleValue b((Float_t) 100.53);
93 Assert(b.GetType() == AliSimpleValue::kFloat);
94 Assert(a == b);
95
96 // copy constructor
97 AliSimpleValue c(a);
98 Assert(b == c);
99
100 // set
101 a = AliSimpleValue((Float_t) 666.666);
102 Assert(a.GetFloat() <= 666.666 + delta || a.GetFloat() >= 666.666 - delta);
103
104
105 // DynBool
106 Bool_t buf[] = {kTRUE, kFALSE, kTRUE};
107 AliSimpleValue a(3, buf);
108 Assert(a.GetType() == AliSimpleValue::kDynBool);
109 Assert(a.GetDynamicSize() == 3);
110 Assert(a.GetDynBool(0) == kTRUE);
111 Assert(a.GetDynBool(1) == kFALSE);
112 Assert(a.GetDynBool(2) == kTRUE);
113
114 a.SetDynBool(1, kTRUE);
115 Assert(a.GetDynBool(1) == kTRUE);
116 a.SetDynBool(1, kFALSE);
117
118 // equal
119 AliSimpleValue b(3, buf);
120 Assert(a == b);
121
122 // copy constructor
123 AliSimpleValue c(b);
124 Assert(c == b);
125
126 // set
127 a.SetDynBool(1, kTRUE);
128 a = c;
129 Assert(a == b);
130
131
132 // DynByte
133 Char_t cbuf[] = {10, 50, 60};
134 AliSimpleValue a(3, cbuf);
135 Assert(a.GetType() == AliSimpleValue::kDynByte);
136 Assert(a.GetDynamicSize() == 3);
137 Assert(a.GetDynByte(0) == 10);
138 Assert(a.GetDynByte(1) == 50);
139 Assert(a.GetDynByte(2) == 60);
140
141 a.SetDynByte(1, 100);
142 Assert(a.GetDynByte(1) == 100);
143 a.SetDynByte(1, 50);
144
145 // equal
146 AliSimpleValue b(3, cbuf);
147 Assert(a == b);
148
149 // copy constructor
150 AliSimpleValue c(b);
151 Assert(c == b);
152
153 // set
154 a.SetDynByte(1, 200);
155 a = c;
156 Assert(a == b);
157
158
159 // DynInt
160 Int_t ibuf[] = {100, 500, -60};
161 AliSimpleValue a(3, ibuf);
162 Assert(a.GetType() == AliSimpleValue::kDynInt);
163 Assert(a.GetDynamicSize() == 3);
164 Assert(a.GetDynInt(0) == 100);
165 Assert(a.GetDynInt(1) == 500);
166 Assert(a.GetDynInt(2) == -60);
167
168 a.SetDynInt(1, 100);
169 Assert(a.GetDynInt(1) == 100);
170 a.SetDynInt(1, 500);
171
172 // equal
173 AliSimpleValue b(3, ibuf);
174 Assert(a == b);
175
176 // copy constructor
177 AliSimpleValue c(b);
178 Assert(c == b);
179
180 // set
181 a.SetDynInt(1, 200);
182 a = c;
183 Assert(a == b);
184
185 // DynUInt
186 UInt_t ubuf[] = {100, 504, 7060};
187 AliSimpleValue a(3, ubuf);
188 Assert(a.GetType() == AliSimpleValue::kDynUInt);
189 Assert(a.GetDynamicSize() == 3);
190 Assert(a.GetDynUInt(0) == 100);
191 Assert(a.GetDynUInt(1) == 504);
192 Assert(a.GetDynUInt(2) == 7060);
193
194 a.SetDynUInt(1, 100);
195 Assert(a.GetDynUInt(1) == 100);
196 a.SetDynUInt(1, 504);
197
198 // equal
199 AliSimpleValue b(3, ubuf);
200 Assert(a == b);
201
202 // copy constructor
203 AliSimpleValue c(b);
204 Assert(c == b);
205
206 // set
207 a.SetDynUInt(1, 200);
208 a = c;
209 Assert(a == b);
210
211
212 // DynFloat
213 Float_t fbuf[] = {100.1, 504.5, 7060};
214 AliSimpleValue a(3, fbuf);
215 Assert(a.GetType() == AliSimpleValue::kDynFloat);
216 Assert(a.GetDynamicSize() == 3);
217 Assert(a.GetDynFloat(0) <= 100.1 + delta || aGetDynFloat(0) >= 100.1 - delta);
218 Assert(a.GetDynFloat(1) <= 504.5 + delta || aGetDynFloat(1) >= 504.5 - delta);
219 Assert(a.GetDynFloat(2) <= 7060 + delta || aGetDynFloat(2) >= 7060 - delta);
220
221 a.SetDynFloat(1, -200.3);
222 Assert(a.GetDynFloat(1) <= -200.3 + delta || aGetDynFloat(1) >= -200.3 - delta);
223 a.SetDynFloat(1, 504.5);
224
225
226 // equal
227 AliSimpleValue b(3, fbuf);
228 Assert(a == b);
229
230 // copy constructor
231 AliSimpleValue c(b);
232 Assert(c == b);
233
234 // set
235 a.SetDynFloat(1, 200);
236 a = c;
237 Assert(a == b);
238
239
240}