|
1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // TBITFLAGS.CPP |
|
15 // |
|
16 // |
|
17 |
|
18 #include "T_BitFlags.h" |
|
19 |
|
20 // System includes |
|
21 #include <e32test.h> |
|
22 |
|
23 // Literal constants |
|
24 _LIT(KTestTitle, "TestBitFlags"); |
|
25 |
|
26 RTest TheTest(KTestTitle); |
|
27 |
|
28 |
|
29 void TestBitFlags::TestSetAll() |
|
30 { |
|
31 iTestFlags.SetAll(); |
|
32 } |
|
33 |
|
34 void TestBitFlags::TestClearAll() |
|
35 { |
|
36 iTestFlags.ClearAll(); |
|
37 } |
|
38 |
|
39 void TestBitFlags::TestSetL(TInt aColor) |
|
40 { |
|
41 iTestFlags.Set(aColor); |
|
42 if (!(iTestFlags.IsSet(aColor))) |
|
43 User::Leave(KErrGeneral); |
|
44 } |
|
45 |
|
46 void TestBitFlags::TestClearL(TInt aColor) |
|
47 { |
|
48 iTestFlags.Clear(aColor); |
|
49 if (iTestFlags.IsSet(aColor)) |
|
50 User::Leave(KErrGeneral); |
|
51 } |
|
52 |
|
53 void TestBitFlags::TestAssign(TInt aColor, TBool aSetOrClear) |
|
54 { |
|
55 iTestFlags.Assign(aColor, aSetOrClear); |
|
56 } |
|
57 |
|
58 void TestBitFlags::TestToggleL(TInt aColor) |
|
59 { |
|
60 TBool isSet = iTestFlags.IsSet(aColor); |
|
61 iTestFlags.Toggle(aColor); |
|
62 if (isSet == iTestFlags.IsSet(aColor)) |
|
63 User::Leave(KErrGeneral); |
|
64 } |
|
65 |
|
66 TBool TestBitFlags::TestOperator1(TInt aColor) //testing operator [] |
|
67 { |
|
68 return iTestFlags.operator[](aColor); |
|
69 } |
|
70 |
|
71 void TestBitFlags::TestOperator2() // test operator = |
|
72 { |
|
73 iFlagA.Set(TestBitFlags::EBlue); |
|
74 iFlagB = iFlagA; |
|
75 TheTest(iFlagB == iFlagA); |
|
76 |
|
77 iFlagB.Set(TestBitFlags::ERed); |
|
78 TheTest(!(iFlagB == iFlagA)); |
|
79 } |
|
80 |
|
81 void TestBitFlags::TestOperator3() //test operator == |
|
82 { |
|
83 iFlagA.Set(TestBitFlags::EBlue); |
|
84 iFlagB.Set(TestBitFlags::EBlue); |
|
85 TheTest(iFlagA == iFlagB); |
|
86 |
|
87 iFlagB.Set(TestBitFlags::ERed); |
|
88 TheTest(!(iFlagB == iFlagA)); |
|
89 } |
|
90 |
|
91 TBool TestBitFlags::TestIsSet(TInt aColor) |
|
92 { |
|
93 return iTestFlags.IsSet(aColor); |
|
94 } |
|
95 |
|
96 TBool TestBitFlags::TestIsClear(TInt aColor) |
|
97 { |
|
98 return iTestFlags.IsClear(aColor); |
|
99 } |
|
100 |
|
101 TInt TestBitFlags::TestValue() |
|
102 { |
|
103 return iTestFlags.Value(); |
|
104 } |
|
105 |
|
106 /** |
|
107 @SYMTestCaseID SYSLIB-BAFL-CT-0468 |
|
108 @SYMTestCaseDesc Tests the behaviour of bits |
|
109 @SYMTestPriority High |
|
110 @SYMTestActions Tests for bits by setting and clearing |
|
111 @SYMTestExpectedResults Test must not fail |
|
112 @SYMREQ REQ0000 |
|
113 */ |
|
114 void DoTest1() |
|
115 { |
|
116 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0468 Pure Set and Clear and related functions only ")); |
|
117 TestBitFlags test; |
|
118 TBool checkTestFlags; |
|
119 TInt checkValue; |
|
120 |
|
121 TRAPD(errCode, test.TestSetL(TestBitFlags::EBlue)); |
|
122 TheTest(errCode==KErrNone); |
|
123 |
|
124 checkTestFlags = test.TestIsSet(TestBitFlags::EBlue); //expect 1 |
|
125 checkValue = test.TestValue(); //expect 1 (hex) |
|
126 TheTest(checkTestFlags == 1); |
|
127 TheTest(checkValue == 1); |
|
128 |
|
129 TRAP(errCode, test.TestSetL(TestBitFlags::EGreen)); |
|
130 TheTest(errCode==KErrNone); |
|
131 checkTestFlags = test.TestIsSet(TestBitFlags::EGreen); //expect 4 |
|
132 TheTest(checkTestFlags == 4); |
|
133 checkTestFlags = test.TestIsClear(TestBitFlags::EGreen); //expect 0 - means it hasnt been cleared |
|
134 checkValue = test.TestValue(); //expect 5 (hex) |
|
135 TheTest(checkTestFlags == 0); |
|
136 TheTest(checkValue == 5); |
|
137 |
|
138 TRAP(errCode, test.TestSetL(TestBitFlags::EYellow)); |
|
139 TheTest(errCode==KErrNone); |
|
140 checkTestFlags = test.TestIsSet(TestBitFlags::EYellow); //expect 8 |
|
141 checkValue = test.TestValue(); //expect d (hex) |
|
142 TheTest(checkTestFlags == 8); |
|
143 TheTest(checkValue == 13); |
|
144 |
|
145 test.TestClearL(TestBitFlags::EGreen); |
|
146 checkTestFlags = test.TestIsClear(TestBitFlags::EGreen); //expect 1 |
|
147 checkValue = test.TestValue(); //expect 9 (hex) |
|
148 TheTest(checkTestFlags == 1); |
|
149 TheTest(checkValue == 9); |
|
150 |
|
151 checkTestFlags = test.TestIsClear(TestBitFlags::ERed); //expect 1 - means it has been cleared |
|
152 checkValue = test.TestValue(); //expect 9 (hex) |
|
153 TheTest(checkTestFlags == 1); |
|
154 TheTest(checkValue == 9); |
|
155 |
|
156 test.TestSetAll(); |
|
157 checkTestFlags = test.TestIsSet(TestBitFlags::EBlue); |
|
158 TheTest(checkTestFlags == 1); |
|
159 checkTestFlags = test.TestIsSet(TestBitFlags::ERed); |
|
160 TheTest(checkTestFlags == 2); |
|
161 checkTestFlags = test.TestIsSet(TestBitFlags::EGreen); |
|
162 TheTest(checkTestFlags == 4); |
|
163 checkTestFlags = test.TestIsSet(TestBitFlags::EYellow); |
|
164 TheTest(checkTestFlags == 8); |
|
165 checkTestFlags = test.TestIsSet(TestBitFlags::EPurple); |
|
166 TheTest(checkTestFlags == 16); |
|
167 checkTestFlags = test.TestIsSet(TestBitFlags::EBlack); |
|
168 TheTest(checkTestFlags == 32); |
|
169 checkTestFlags = test.TestIsSet(TestBitFlags::EWhite); |
|
170 TheTest(checkTestFlags == 64); |
|
171 checkTestFlags = test.TestIsSet(TestBitFlags::EGrey); |
|
172 TheTest(checkTestFlags == 128); |
|
173 checkValue = test.TestValue(); //expect 0xffffffff (hex) |
|
174 TheTest(checkValue == -1); |
|
175 |
|
176 |
|
177 test.TestClearL(TestBitFlags::EBlue); |
|
178 checkTestFlags = test.TestIsClear(TestBitFlags::EBlue); |
|
179 TheTest(checkTestFlags == 1); |
|
180 test.TestClearL(TestBitFlags::ERed); |
|
181 checkTestFlags = test.TestIsClear(TestBitFlags::ERed); |
|
182 TheTest(checkTestFlags == 1); |
|
183 test.TestClearL(TestBitFlags::EGreen); |
|
184 checkTestFlags = test.TestIsClear(TestBitFlags::EGreen); |
|
185 TheTest(checkTestFlags == 1); |
|
186 test.TestClearL(TestBitFlags::EYellow); |
|
187 checkTestFlags = test.TestIsClear(TestBitFlags::EYellow); |
|
188 TheTest(checkTestFlags == 1); |
|
189 test.TestClearL(TestBitFlags::EPurple); |
|
190 checkTestFlags = test.TestIsClear(TestBitFlags::EPurple); |
|
191 TheTest(checkTestFlags == 1); |
|
192 test.TestClearL(TestBitFlags::EBlack); |
|
193 checkTestFlags = test.TestIsClear(TestBitFlags::EBlack); |
|
194 TheTest(checkTestFlags == 1); |
|
195 test.TestClearL(TestBitFlags::EWhite); |
|
196 checkTestFlags = test.TestIsClear(TestBitFlags::EWhite); |
|
197 TheTest(checkTestFlags == 1); |
|
198 test.TestClearL(TestBitFlags::EGrey); |
|
199 checkTestFlags = test.TestIsClear(TestBitFlags::EGrey); |
|
200 TheTest(checkTestFlags == 1); |
|
201 checkValue = test.TestValue(); //expect 0xffffff00 |
|
202 TheTest(checkValue == -256); |
|
203 |
|
204 test.TestClearAll(); |
|
205 checkValue = test.TestValue(); |
|
206 TheTest(checkValue ==0); |
|
207 } |
|
208 |
|
209 /** |
|
210 @SYMTestCaseID SYSLIB-BAFL-CT-0469 |
|
211 @SYMTestCaseDesc Tests the behaviour of bits |
|
212 @SYMTestPriority High |
|
213 @SYMTestActions Tests for bits by reading them back (assign function) |
|
214 @SYMTestExpectedResults Test must not fail |
|
215 @SYMREQ REQ0000 |
|
216 */ |
|
217 void DoTest2() |
|
218 { |
|
219 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0469 Assign function ")); |
|
220 TestBitFlags test; |
|
221 TBool checkTestFlags; |
|
222 TInt checkValue; |
|
223 |
|
224 test.TestAssign(TestBitFlags::ERed, 1); |
|
225 checkTestFlags = test.TestIsSet(TestBitFlags::ERed); //expect 2 |
|
226 checkValue = test.TestValue(); //expect 2 |
|
227 TheTest(checkTestFlags == 2); |
|
228 TheTest(checkValue == 2); |
|
229 |
|
230 test.TestAssign(TestBitFlags::EWhite, 1); |
|
231 checkTestFlags = test.TestIsSet(TestBitFlags::EWhite); //expect 64 |
|
232 checkValue = test.TestValue(); //expect 66 |
|
233 TheTest(checkTestFlags == 64); |
|
234 TheTest(checkValue == 66); |
|
235 |
|
236 test.TestAssign(TestBitFlags::ERed, 0); |
|
237 checkTestFlags = test.TestIsClear(TestBitFlags::ERed); //expect 1 |
|
238 checkValue = test.TestValue(); //expect 64 |
|
239 TheTest(checkTestFlags == 1); |
|
240 TheTest(checkValue == 64); |
|
241 |
|
242 test.TestAssign(TestBitFlags::ERed, 3); //test anything other than 1 will activate Set function |
|
243 checkTestFlags = test.TestIsSet(TestBitFlags::ERed); //expect 2 |
|
244 checkValue = test.TestValue(); //expect 66 |
|
245 TheTest(checkTestFlags == 2); |
|
246 TheTest(checkValue == 66); |
|
247 } |
|
248 |
|
249 /** |
|
250 @SYMTestCaseID SYSLIB-BAFL-CT-0470 |
|
251 @SYMTestCaseDesc Tests the behaviour of bits |
|
252 @SYMTestPriority High |
|
253 @SYMTestActions Tests for [] operator |
|
254 @SYMTestExpectedResults Test must not fail |
|
255 @SYMREQ REQ0000 |
|
256 */ |
|
257 void DoTest3() |
|
258 { |
|
259 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0470 operator [] ")); |
|
260 |
|
261 TestBitFlags test; |
|
262 TBool checkTestFlags; |
|
263 |
|
264 TRAPD(errCode, test.TestSetL(TestBitFlags::EBlue)); |
|
265 TheTest(errCode==KErrNone); |
|
266 |
|
267 checkTestFlags = test.TestOperator1(TestBitFlags::ERed); //0 |
|
268 TheTest(checkTestFlags == 0); |
|
269 |
|
270 TRAP(errCode, test.TestSetL(TestBitFlags::EYellow)); |
|
271 TheTest(errCode==KErrNone); |
|
272 |
|
273 checkTestFlags = test.TestOperator1(TestBitFlags::EGreen); //0 |
|
274 TheTest(checkTestFlags == 0); |
|
275 |
|
276 checkTestFlags = test.TestOperator1(TestBitFlags::EBlack); //0 |
|
277 TheTest(checkTestFlags == 0); |
|
278 |
|
279 checkTestFlags = test.TestOperator1(TestBitFlags::EYellow); //8 |
|
280 TheTest(checkTestFlags == 8); |
|
281 |
|
282 checkTestFlags = test.TestOperator1(TestBitFlags::EBlue); //1 |
|
283 TheTest(checkTestFlags == 1); |
|
284 } |
|
285 |
|
286 /** |
|
287 @SYMTestCaseID SYSLIB-BAFL-CT-0471 |
|
288 @SYMTestCaseDesc Tests the behaviour of bits |
|
289 @SYMTestPriority High |
|
290 @SYMTestActions Tests for == operator |
|
291 @SYMTestExpectedResults Test must not fail |
|
292 @SYMREQ REQ0000 |
|
293 */ |
|
294 void DoTest4() |
|
295 { |
|
296 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0471 Operator== ")); |
|
297 TestBitFlags test; |
|
298 test.TestOperator3(); |
|
299 } |
|
300 |
|
301 /** |
|
302 @SYMTestCaseID SYSLIB-BAFL-CT-0472 |
|
303 @SYMTestCaseDesc Tests the behaviour of bits |
|
304 @SYMTestPriority High |
|
305 @SYMTestActions Tests for toggling the value |
|
306 @SYMTestExpectedResults Test must not fail |
|
307 @SYMREQ REQ0000 |
|
308 */ |
|
309 void DoTest5() |
|
310 { |
|
311 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0472 Toggle ")); |
|
312 TestBitFlags test; |
|
313 TInt checkTestFlags; |
|
314 |
|
315 test.TestToggleL(TestBitFlags::EBlue); |
|
316 checkTestFlags = test.TestValue(); |
|
317 TheTest(checkTestFlags == 1); |
|
318 |
|
319 test.TestToggleL(TestBitFlags::ERed); |
|
320 checkTestFlags = test.TestValue(); |
|
321 TheTest(checkTestFlags == 3); |
|
322 |
|
323 test.TestToggleL(TestBitFlags::EBlue); |
|
324 checkTestFlags = test.TestValue(); |
|
325 TheTest(checkTestFlags == 2); |
|
326 |
|
327 test.TestToggleL(TestBitFlags::EGreen); |
|
328 checkTestFlags = test.TestValue(); |
|
329 TheTest(checkTestFlags == 6); |
|
330 |
|
331 test.TestToggleL(TestBitFlags::ERed); |
|
332 checkTestFlags = test.TestValue(); |
|
333 TheTest(checkTestFlags == 4); |
|
334 |
|
335 test.TestToggleL(TestBitFlags::EGreen); |
|
336 checkTestFlags = test.TestValue(); |
|
337 TheTest(checkTestFlags == 0); |
|
338 |
|
339 test.TestToggleL(TestBitFlags::EYellow); |
|
340 checkTestFlags = test.TestValue(); |
|
341 TheTest(checkTestFlags == 8); |
|
342 } |
|
343 |
|
344 /** |
|
345 @SYMTestCaseID SYSLIB-BAFL-CT-0473 |
|
346 @SYMTestCaseDesc Tests the behaviour of bits |
|
347 @SYMTestPriority High |
|
348 @SYMTestActions Tests for assignment operator |
|
349 @SYMTestExpectedResults Test must not fail |
|
350 @SYMREQ REQ0000 |
|
351 */ |
|
352 void DoTest6() |
|
353 { |
|
354 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0473 Operator= ")); |
|
355 TestBitFlags test; |
|
356 test.TestOperator2(); |
|
357 } |
|
358 |
|
359 // TestData |
|
360 |
|
361 TTestEnum KEnumArray[] = |
|
362 { |
|
363 ETest1, ETest2, ETest3, ETest4, ETest5, ETest6, ETest7, ETest8, |
|
364 ETest9, ETest10, ETest11, ETest12, ETest13, ETest14, ETest15, ETest16, |
|
365 ETest17, ETest18, ETest19, ETest20, ETest21, ETest22, ETest23, ETest24, |
|
366 ETest25, ETest26, ETest27, ETest28, ETest29, ETest30, ETest31, ETest32 |
|
367 }; |
|
368 |
|
369 /** |
|
370 @SYMTestCaseID SYSLIB-BAFL-CT-3387 |
|
371 @SYMTestCaseDesc Tests the behaviour of template class when type is an enum. |
|
372 @SYMTestPriority High |
|
373 @SYMTestActions For each bit test each function in class for when T is an enum. |
|
374 It is important that this test includes the MSB bit because enums |
|
375 are stored as an unsigned int and the MSB is the signed bit. |
|
376 @SYMTestExpectedResults Flags must be set and reset to the expected values |
|
377 @SYMDEF DEF102233 |
|
378 */ |
|
379 void DEF102233() |
|
380 { |
|
381 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-3387 Tests for DEF102233 ")); |
|
382 |
|
383 TInt arrayPos; |
|
384 TInt bitPos; |
|
385 for(TInt x = 0; x <= 31; x++) |
|
386 { |
|
387 arrayPos = x; |
|
388 bitPos = x; |
|
389 |
|
390 // Constructor |
|
391 TBitFlagsT<TTestEnum> myBitFlagMSB1(KEnumArray[arrayPos]); |
|
392 TheTest(myBitFlagMSB1.IsSet(bitPos)); |
|
393 |
|
394 // Copy Constructor |
|
395 TBitFlagsT<TTestEnum> myBitFlagMSB2(myBitFlagMSB1); |
|
396 TheTest(myBitFlagMSB2.IsSet(bitPos)); |
|
397 |
|
398 // SetAll |
|
399 myBitFlagMSB1.SetAll(); |
|
400 TheTest(myBitFlagMSB1.IsSet(bitPos)); |
|
401 |
|
402 // ClearAll |
|
403 myBitFlagMSB1.ClearAll(); |
|
404 TheTest(!myBitFlagMSB1.IsSet(bitPos)); |
|
405 |
|
406 // Set and Clear |
|
407 myBitFlagMSB1.Set(bitPos); |
|
408 TheTest(myBitFlagMSB1.IsSet(bitPos)); |
|
409 myBitFlagMSB1.Clear(bitPos); |
|
410 TheTest(!myBitFlagMSB1.IsSet(bitPos)); |
|
411 |
|
412 // Assign |
|
413 myBitFlagMSB1.Assign(bitPos, ETrue); |
|
414 TheTest(myBitFlagMSB1.IsSet(bitPos)); |
|
415 myBitFlagMSB1.Assign(bitPos, EFalse); |
|
416 TheTest(!myBitFlagMSB1.IsSet(bitPos)); |
|
417 |
|
418 // Toggle |
|
419 myBitFlagMSB1.Toggle(bitPos); |
|
420 TheTest(myBitFlagMSB1.IsSet(bitPos)); |
|
421 myBitFlagMSB1.Toggle(bitPos); |
|
422 TheTest(!myBitFlagMSB1.IsSet(bitPos)); |
|
423 |
|
424 // operator[] |
|
425 TheTest(!myBitFlagMSB1[arrayPos]); |
|
426 myBitFlagMSB1.Set(bitPos); |
|
427 TheTest(myBitFlagMSB1[arrayPos]); |
|
428 |
|
429 // operator= |
|
430 myBitFlagMSB2 = myBitFlagMSB1; |
|
431 TheTest(myBitFlagMSB2[arrayPos]); |
|
432 myBitFlagMSB1.Toggle(bitPos); |
|
433 myBitFlagMSB2 = myBitFlagMSB1; |
|
434 TheTest(!myBitFlagMSB2[arrayPos]); |
|
435 |
|
436 // operator== |
|
437 TheTest(myBitFlagMSB1 == myBitFlagMSB2); |
|
438 myBitFlagMSB1.Toggle(bitPos); |
|
439 myBitFlagMSB2.Toggle(bitPos); |
|
440 TheTest(myBitFlagMSB1 == myBitFlagMSB2); |
|
441 myBitFlagMSB1.Toggle(bitPos); |
|
442 TheTest(!(myBitFlagMSB1 == myBitFlagMSB2)); |
|
443 |
|
444 // IsSet and IsClear |
|
445 TheTest(myBitFlagMSB1.IsClear(bitPos)); |
|
446 myBitFlagMSB1.Toggle(bitPos); |
|
447 TheTest(myBitFlagMSB1.IsSet(bitPos)); |
|
448 |
|
449 // Value and SetValue |
|
450 myBitFlagMSB1.ClearAll(); |
|
451 myBitFlagMSB1.SetValue(KEnumArray[arrayPos]); |
|
452 TheTest(myBitFlagMSB1.Value() == KEnumArray[arrayPos]); |
|
453 |
|
454 // Value against a signed integer |
|
455 TInt signedInteger = KEnumArray[arrayPos]; |
|
456 TheTest(myBitFlagMSB1.Value() == signedInteger); |
|
457 |
|
458 // Value against an unsigned integer |
|
459 TUint unsignedInteger = KEnumArray[arrayPos]; |
|
460 TheTest(myBitFlagMSB1.Value() == unsignedInteger); |
|
461 |
|
462 // iFlags |
|
463 myBitFlagMSB1.ClearAll(); |
|
464 myBitFlagMSB1.iFlags = KEnumArray[arrayPos]; |
|
465 TheTest(myBitFlagMSB1.Value() == KEnumArray[arrayPos]); |
|
466 } |
|
467 // check MSB was tested |
|
468 TheTest(KEnumArray[arrayPos] == ETest32); |
|
469 TheTest(bitPos == 31); |
|
470 } |
|
471 |
|
472 /** |
|
473 @SYMTestCaseID BASESRVCS-BAFL-CT-4078 |
|
474 @SYMTestCaseDesc tests the IsSet API for out of bounds index values. |
|
475 @SYMTestPriority High |
|
476 @SYMTestActions query flag state statinig an index that is out of bound |
|
477 @SYMTestExpectedResults should return EFalse for out of bound values |
|
478 @SYMDEF DEF130663 |
|
479 */ |
|
480 void DEF130663() |
|
481 { |
|
482 // type is considered as an enum here |
|
483 TheTest.Next(_L(" @SYMTestCaseID:BASESRVCS-BAFL-CT-4078 Tests for DEF130663 ")); |
|
484 |
|
485 TInt arrayPos; |
|
486 TInt bitPos; |
|
487 for(TInt x = 0; x <= 31; x++) |
|
488 { |
|
489 arrayPos = x; |
|
490 bitPos = x; |
|
491 |
|
492 // Constructor |
|
493 TBitFlagsT<TTestEnum> myBitFlag(KEnumArray[arrayPos]); |
|
494 TheTest(myBitFlag.IsSet(bitPos)); |
|
495 |
|
496 //clear all and set one paricular bit |
|
497 myBitFlag.ClearAll(); |
|
498 myBitFlag.Set(bitPos); |
|
499 |
|
500 // check "out of bounds" values as well |
|
501 // expected behavior is that for all out of bound values the |
|
502 // result should be EFalse for IsSet("out of bounds") call. |
|
503 // IsSet and all the functions directly calling IsSet are being tested here |
|
504 // this test in conjuction with the other cts listed here |
|
505 // should be sufficient to validate the fix |
|
506 for(TInt i = 0; i < 64; i++) |
|
507 { |
|
508 if(i==x) |
|
509 { |
|
510 TheTest(myBitFlag.IsSet(i)); |
|
511 TheTest(!myBitFlag.IsClear(i)); |
|
512 TheTest(myBitFlag[i]); |
|
513 } |
|
514 else |
|
515 { |
|
516 TheTest(!myBitFlag.IsSet(i)); |
|
517 TheTest(myBitFlag.IsClear(i)); |
|
518 TheTest(!myBitFlag[i]); |
|
519 } |
|
520 } |
|
521 } |
|
522 // check MSB was tested |
|
523 TheTest(KEnumArray[arrayPos] == ETest32); |
|
524 TheTest(bitPos == 31); |
|
525 } |
|
526 |
|
527 void RunTestsL() |
|
528 { |
|
529 DoTest1(); |
|
530 DoTest2(); |
|
531 DoTest3(); |
|
532 DoTest4(); |
|
533 DoTest5(); |
|
534 DoTest6(); |
|
535 DEF102233(); |
|
536 DEF130663(); |
|
537 } |
|
538 |
|
539 TInt E32Main() |
|
540 { |
|
541 __UHEAP_MARK; |
|
542 |
|
543 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
544 if (!cleanup) |
|
545 return KErrNoMemory; |
|
546 |
|
547 TheTest.Start(_L("TBITFLAGS ")); |
|
548 TheTest.Title(); |
|
549 |
|
550 TRAPD(err, RunTestsL()); |
|
551 TheTest(err == KErrNone); |
|
552 |
|
553 delete cleanup; |
|
554 TheTest.End(); |
|
555 TheTest.Close(); |
|
556 |
|
557 __UHEAP_MARKEND; |
|
558 return KErrNone; |
|
559 } |