31
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
// INCLUDE FILES
|
|
22 |
#include <e32svr.h>
|
|
23 |
#include <StifParser.h>
|
|
24 |
#include <Stiftestinterface.h>
|
|
25 |
#include "tstl_4.h"
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
#include <locale>
|
|
30 |
#include <numeric>
|
|
31 |
#include <valarray>
|
|
32 |
#include<fstream>
|
|
33 |
|
|
34 |
#include<list>
|
|
35 |
#include<string>
|
|
36 |
#include<cstring>
|
|
37 |
#include<vector>
|
|
38 |
#include<iterator>
|
|
39 |
|
|
40 |
#include<ios>
|
|
41 |
#include<algorithm>
|
|
42 |
#include <numeric>
|
|
43 |
#include<functional>
|
|
44 |
#include <locale>
|
|
45 |
#include<iostream>
|
|
46 |
#include<memory>
|
|
47 |
#include<complex>
|
|
48 |
#include<map>
|
|
49 |
//#include<set>
|
|
50 |
#include<exception>
|
|
51 |
// #include<bitset>
|
|
52 |
|
|
53 |
#include <stl/char_traits.h> // fpos
|
|
54 |
|
|
55 |
#undef test
|
|
56 |
using namespace std;
|
|
57 |
#define STDCPP_OOM FALSE// TRUE for OOM testing
|
|
58 |
|
|
59 |
// EXTERNAL DATA STRUCTURES
|
|
60 |
//extern ?external_data;
|
|
61 |
|
|
62 |
// EXTERNAL FUNCTION PROTOTYPES
|
|
63 |
//extern ?external_function( ?arg_type,?arg_type );
|
|
64 |
|
|
65 |
// CONSTANTS
|
|
66 |
//const ?type ?constant_var = ?constant;
|
|
67 |
|
|
68 |
// MACROS
|
|
69 |
//#define ?macro ?macro_def
|
|
70 |
|
|
71 |
// LOCAL CONSTANTS AND MACROS
|
|
72 |
//const ?type ?constant_var = ?constant;
|
|
73 |
//#define ?macro_name ?macro_def
|
|
74 |
|
|
75 |
// MODULE DATA STRUCTURES
|
|
76 |
//enum ?declaration
|
|
77 |
//typedef ?declaration
|
|
78 |
|
|
79 |
// LOCAL FUNCTION PROTOTYPES
|
|
80 |
//?type ?function_name( ?arg_type, ?arg_type );
|
|
81 |
|
|
82 |
// FORWARD DECLARATIONS
|
|
83 |
//class ?FORWARD_CLASSNAME;
|
|
84 |
|
|
85 |
// ============================= LOCAL FUNCTIONS ===============================
|
|
86 |
|
|
87 |
// -----------------------------------------------------------------------------
|
|
88 |
// ?function_name ?description.
|
|
89 |
// ?description
|
|
90 |
// Returns: ?value_1: ?description
|
|
91 |
// ?value_n: ?description_line1
|
|
92 |
// ?description_line2
|
|
93 |
// -----------------------------------------------------------------------------
|
|
94 |
//
|
|
95 |
/*
|
|
96 |
?type ?function_name(
|
|
97 |
?arg_type arg, // ?description
|
|
98 |
?arg_type arg) // ?description
|
|
99 |
{
|
|
100 |
|
|
101 |
?code // ?comment
|
|
102 |
|
|
103 |
// ?comment
|
|
104 |
?code
|
|
105 |
}
|
|
106 |
*/
|
|
107 |
|
|
108 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
109 |
|
|
110 |
// -----------------------------------------------------------------------------
|
|
111 |
// Ctstl_4::Delete
|
|
112 |
// Delete here all resources allocated and opened from test methods.
|
|
113 |
// Called from destructor.
|
|
114 |
// -----------------------------------------------------------------------------
|
|
115 |
//
|
|
116 |
void Ctstl_4::Delete()
|
|
117 |
{
|
|
118 |
|
|
119 |
}
|
|
120 |
|
|
121 |
// -----------------------------------------------------------------------------
|
|
122 |
// Ctstl_4::RunMethodL
|
|
123 |
// Run specified method. Contains also table of test mothods and their names.
|
|
124 |
// -----------------------------------------------------------------------------
|
|
125 |
//
|
|
126 |
TInt Ctstl_4::RunMethodL(
|
|
127 |
CStifItemParser& aItem )
|
|
128 |
{
|
|
129 |
|
|
130 |
static TStifFunctionInfo const KFunctions[] =
|
|
131 |
{
|
|
132 |
// Copy this line for every implemented function.
|
|
133 |
// First string is the function name used in TestScripter script file.
|
|
134 |
// Second is the actual implementation member function.
|
|
135 |
|
|
136 |
ENTRY( "Swapof", Ctstl_4::Swapof ),
|
|
137 |
ENTRY( "Accumulate", Ctstl_4::Accumulate ),
|
|
138 |
ENTRY( "Adjacent_difference", Ctstl_4::Adjacent_difference),
|
|
139 |
ENTRY( "Adjacent_find", Ctstl_4::Adjacent_find),
|
|
140 |
ENTRY( "Logical_or", Ctstl_4::Logical_or ),
|
|
141 |
ENTRY( "Logical_and", Ctstl_4::Logical_and ),
|
|
142 |
ENTRY( "Logical_not", Ctstl_4::Logical_not ),
|
|
143 |
ENTRY( "count_fun", Ctstl_4::count_fun),
|
|
144 |
ENTRY( "countif_fun", Ctstl_4::countif_fun),
|
|
145 |
ENTRY( "equal_fun", Ctstl_4::equal_fun),
|
|
146 |
ENTRY( "equalto", Ctstl_4::equalto),
|
|
147 |
ENTRY( "notequalto", Ctstl_4::notequalto),
|
|
148 |
ENTRY( "sort_fun", Ctstl_4::sort_fun),
|
|
149 |
ENTRY( "less_equal_fun", Ctstl_4::less_equal_fun),
|
|
150 |
ENTRY( "greater_equal_fun", Ctstl_4::greater_equal_fun),
|
|
151 |
ENTRY( "greater_fun", Ctstl_4::greater_fun),
|
|
152 |
ENTRY( "less_fun", Ctstl_4::less_fun),
|
|
153 |
ENTRY( "find_fun", Ctstl_4::find_fun),
|
|
154 |
ENTRY( "findif_fun", Ctstl_4::findif_fun),
|
|
155 |
ENTRY( "findend_fun", Ctstl_4::findend_fun),
|
|
156 |
ENTRY( "Minof", Ctstl_4::Minof ),
|
|
157 |
ENTRY( "Maxelement", Ctstl_4::Maxelement ),
|
|
158 |
ENTRY( "Minelement", Ctstl_4::Minelement ),
|
|
159 |
|
|
160 |
|
|
161 |
ENTRY( "ToUpper", Ctstl_4::ToUpper ),
|
|
162 |
ENTRY( "ToLower", Ctstl_4::ToLower ),
|
|
163 |
ENTRY( "Islower", Ctstl_4::Islower ),
|
|
164 |
ENTRY( "Isupper", Ctstl_4::Isupper ),
|
|
165 |
ENTRY( "Maxof", Ctstl_4::Maxof ),
|
|
166 |
|
|
167 |
|
|
168 |
ENTRY("Advance", Ctstl_4::Advance ),
|
|
169 |
ENTRY("Backinsert_iterator", Ctstl_4::Backinsert_iterator ),
|
|
170 |
ENTRY("Frontinsert_iterator", Ctstl_4::Frontinsert_iterator ),
|
|
171 |
ENTRY("Insert_iterator", Ctstl_4::Insert_iterator ),
|
|
172 |
ENTRY("Reverse_iterator", Ctstl_4::Reverse_iterator ),
|
|
173 |
ENTRY("Distance", Ctstl_4::Distance ),
|
|
174 |
|
|
175 |
|
|
176 |
ENTRY("Isdigit", Ctstl_4::Isdigit ),
|
|
177 |
ENTRY("Isgraph", Ctstl_4::Isgraph ),
|
|
178 |
ENTRY("Isalnum", Ctstl_4::Isalnum ),
|
|
179 |
ENTRY("Isalpha", Ctstl_4::Isalpha ),
|
|
180 |
ENTRY("Iscntrl", Ctstl_4::Iscntrl ),
|
|
181 |
ENTRY("Isprint", Ctstl_4::Isprint ),
|
|
182 |
ENTRY("Ispunct", Ctstl_4::Ispunct ),
|
|
183 |
ENTRY("Isspace", Ctstl_4::Isspace ),
|
|
184 |
ENTRY("Isxdigit", Ctstl_4::Isxdigit ),
|
|
185 |
ENTRY("Fill", Ctstl_4::Fill ),
|
|
186 |
ENTRY("Generate", Ctstl_4::Generate ),
|
|
187 |
ENTRY("Search", Ctstl_4::Search ),
|
|
188 |
ENTRY("Search_n", Ctstl_4::Search_n ),
|
|
189 |
ENTRY("Times", Ctstl_4::Times ),
|
|
190 |
ENTRY("Unique", Ctstl_4::Unique ),
|
|
191 |
ENTRY("Uniquecopy", Ctstl_4::Uniquecopy ),
|
|
192 |
ENTRY("Partialsort", Ctstl_4::Partialsort ),
|
|
193 |
ENTRY("Partialsortcopy", Ctstl_4::Partialsortcopy ),
|
|
194 |
ENTRY("Partition", Ctstl_4::Partition ),
|
|
195 |
ENTRY("Stablepartition", Ctstl_4::Stablepartition ),
|
|
196 |
ENTRY("Setdifference", Ctstl_4::Setdifference ),
|
|
197 |
|
|
198 |
|
|
199 |
};
|
|
200 |
|
|
201 |
const TInt count = sizeof( KFunctions ) /
|
|
202 |
sizeof( TStifFunctionInfo );
|
|
203 |
|
|
204 |
return RunInternalL( KFunctions, count, aItem );
|
|
205 |
|
|
206 |
}
|
|
207 |
|
|
208 |
|
|
209 |
|
|
210 |
|
|
211 |
|
|
212 |
|
|
213 |
|
|
214 |
|
|
215 |
|
|
216 |
|
|
217 |
|
|
218 |
|
|
219 |
|
|
220 |
|
|
221 |
|
|
222 |
|
|
223 |
|
|
224 |
|
|
225 |
|
|
226 |
|
|
227 |
|
|
228 |
//swap
|
|
229 |
|
|
230 |
TInt Ctstl_4::Swapof(CStifItemParser& aItem)
|
|
231 |
{
|
|
232 |
int x= 10,y=20;
|
|
233 |
|
|
234 |
//__UHEAP_MARK;
|
|
235 |
int failures =0;
|
|
236 |
|
|
237 |
|
|
238 |
try
|
|
239 |
{ //cout<<"";
|
|
240 |
#if STDCPP_OOM
|
|
241 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
242 |
|
|
243 |
#endif
|
|
244 |
swap(x,y);
|
|
245 |
#if STDCPP_OOM
|
|
246 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
247 |
|
|
248 |
|
|
249 |
#endif
|
|
250 |
/*if (x==20 && y==10)
|
|
251 |
|
|
252 |
|
|
253 |
//__UHEAP_MARKEND;
|
|
254 |
|
|
255 |
return KErrNone;
|
|
256 |
return KErrGeneral;*/
|
|
257 |
if(x!=20)
|
|
258 |
failures++;
|
|
259 |
if(y!=10)
|
|
260 |
failures++;
|
|
261 |
|
|
262 |
//#if STDCPP_OOM
|
|
263 |
// failures++;
|
|
264 |
// #endif
|
|
265 |
}
|
|
266 |
catch(bad_alloc&)
|
|
267 |
{
|
|
268 |
}
|
|
269 |
catch(...)
|
|
270 |
{
|
|
271 |
failures++;
|
|
272 |
|
|
273 |
}
|
|
274 |
|
|
275 |
|
|
276 |
if(failures)
|
|
277 |
return KErrGeneral;
|
|
278 |
return KErrNone;
|
|
279 |
}
|
|
280 |
|
|
281 |
|
|
282 |
|
|
283 |
//accumulate
|
|
284 |
int mult(int x,int y)
|
|
285 |
{
|
|
286 |
return x*y;
|
|
287 |
}
|
|
288 |
|
|
289 |
|
|
290 |
TInt Ctstl_4::Accumulate(CStifItemParser& aItem)
|
|
291 |
{
|
|
292 |
|
|
293 |
int failures =0;
|
|
294 |
|
|
295 |
// __UHEAP_MARK;
|
|
296 |
|
|
297 |
try
|
|
298 |
{
|
|
299 |
|
|
300 |
|
|
301 |
int test_array[10] = {1,2,3,4,5,6,7,8,9,10};
|
|
302 |
vector<int> v1(test_array, test_array+10);
|
|
303 |
// cout<<"";
|
|
304 |
#if STDCPP_OOM
|
|
305 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
306 |
|
|
307 |
#endif
|
|
308 |
int sum = accumulate(v1.begin(), v1.end(),0);
|
|
309 |
|
|
310 |
int prod = accumulate(v1.begin(), v1.end(),1,mult);
|
|
311 |
#if STDCPP_OOM
|
|
312 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
313 |
|
|
314 |
|
|
315 |
#endif
|
|
316 |
v1.erase(v1.begin(),v1.end());
|
|
317 |
|
|
318 |
/* if(sum == 55 && prod == 3628800)
|
|
319 |
// __UHEAP_MARKEND;
|
|
320 |
|
|
321 |
return KErrNone;
|
|
322 |
return KErrGeneral;*/
|
|
323 |
if(sum!=55)
|
|
324 |
failures++;
|
|
325 |
if(prod!=3628800)
|
|
326 |
failures++;
|
|
327 |
//#if STDCPP_OOM //failures++; //#endif
|
|
328 |
|
|
329 |
}
|
|
330 |
catch(bad_alloc&)
|
|
331 |
{
|
|
332 |
}
|
|
333 |
catch(...)
|
|
334 |
{
|
|
335 |
failures++;
|
|
336 |
|
|
337 |
}
|
|
338 |
|
|
339 |
|
|
340 |
if(failures)
|
|
341 |
return KErrGeneral;
|
|
342 |
return KErrNone;
|
|
343 |
}
|
|
344 |
|
|
345 |
|
|
346 |
|
|
347 |
|
|
348 |
|
|
349 |
TInt Ctstl_4::Adjacent_difference(CStifItemParser& aItem)
|
|
350 |
{
|
|
351 |
|
|
352 |
|
|
353 |
//__UHEAP_MARK;
|
|
354 |
|
|
355 |
|
|
356 |
int failures =0;
|
|
357 |
|
|
358 |
|
|
359 |
try
|
|
360 |
{
|
|
361 |
vector<int> V1( 10 ), V2( 10 );
|
|
362 |
vector<int>::iterator VIter1, VIter2, VIterend, VIterend2;
|
|
363 |
|
|
364 |
|
|
365 |
int array1[10];
|
|
366 |
int array2[10];
|
|
367 |
list <int> L1;
|
|
368 |
// list <int>::iterator LIter1, LIterend, LIterend2;
|
|
369 |
|
|
370 |
int t;
|
|
371 |
for ( t = 1 ; t <= 10 ; t++ )
|
|
372 |
{
|
|
373 |
L1.push_back( t * t );
|
|
374 |
}
|
|
375 |
//cout<<"";
|
|
376 |
#if STDCPP_OOM
|
|
377 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
378 |
|
|
379 |
#endif
|
|
380 |
// The first member function for the adjacent_differences of
|
|
381 |
// elements in a list output to a vector
|
|
382 |
VIterend = adjacent_difference ( L1.begin (),L1.end (),V1.begin () );
|
|
383 |
#if STDCPP_OOM
|
|
384 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
385 |
|
|
386 |
|
|
387 |
#endif
|
|
388 |
for ( VIter1 = V1.begin( ) ; VIter1 != VIterend ; VIter1++ )
|
|
389 |
|
|
390 |
|
|
391 |
{
|
|
392 |
static int i;
|
|
393 |
|
|
394 |
array1[i] = *VIter1;
|
|
395 |
i++;
|
|
396 |
}
|
|
397 |
|
|
398 |
#if STDCPP_OOM
|
|
399 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
400 |
|
|
401 |
#endif
|
|
402 |
// The second member function used to compute
|
|
403 |
// the adjacent products of the elements in a list
|
|
404 |
VIterend2 = adjacent_difference ( L1.begin (),L1.end ( ),V2.begin ( ),multiplies<int>( ) );
|
|
405 |
#if STDCPP_OOM
|
|
406 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
407 |
|
|
408 |
|
|
409 |
#endif
|
|
410 |
for ( VIter2 = V2.begin( ) ; VIter2 != VIterend2 ; VIter2++ )
|
|
411 |
{
|
|
412 |
|
|
413 |
static int i;
|
|
414 |
array2[i] = *VIter2;
|
|
415 |
i++;
|
|
416 |
}
|
|
417 |
|
|
418 |
/*
|
|
419 |
if(array1[0] == 1)
|
|
420 |
if(array1[1] == 3)
|
|
421 |
if(array1[2] == 5)
|
|
422 |
if(array1[3] == 7)
|
|
423 |
if(array1[4] == 9)
|
|
424 |
if(array1[5] == 11)
|
|
425 |
if(array1[6] == 13)
|
|
426 |
if(array1[7] == 15)
|
|
427 |
if(array1[8] == 17)
|
|
428 |
if(array1[9] == 19)
|
|
429 |
|
|
430 |
if(array2[0] == 1)
|
|
431 |
if(array2[1] == 4)
|
|
432 |
if(array2[2] == 36)
|
|
433 |
if(array2[3] == 144)
|
|
434 |
if(array2[4] == 400)
|
|
435 |
if(array2[5] == 900)
|
|
436 |
if(array2[6] == 1764)
|
|
437 |
if(array2[7] == 3136)
|
|
438 |
if(array2[8] == 5184)
|
|
439 |
if(array2[9] == 8100)
|
|
440 |
|
|
441 |
//__UHEAP_MARKEND;
|
|
442 |
return KErrNone;
|
|
443 |
return KErrGeneral;*/
|
|
444 |
if(array1[0] != 1)
|
|
445 |
failures++;
|
|
446 |
if(array1[1] != 3)
|
|
447 |
failures++;
|
|
448 |
if(array1[2] != 5)
|
|
449 |
failures++;
|
|
450 |
if(array1[3] != 7)
|
|
451 |
failures++;
|
|
452 |
if(array1[4] != 9)
|
|
453 |
failures++;
|
|
454 |
if(array1[5] != 11)
|
|
455 |
failures++;
|
|
456 |
if(array1[6] != 13)
|
|
457 |
failures++;
|
|
458 |
if(array1[7] != 15)
|
|
459 |
failures++;
|
|
460 |
if(array1[8] != 17)
|
|
461 |
failures++;
|
|
462 |
if(array1[9] != 19)
|
|
463 |
failures++;
|
|
464 |
|
|
465 |
if(array2[0] != 1)
|
|
466 |
failures++;
|
|
467 |
if(array2[1] != 4)
|
|
468 |
failures++;
|
|
469 |
if(array2[2] != 36)
|
|
470 |
failures++;
|
|
471 |
if(array2[3] != 144)
|
|
472 |
failures++;
|
|
473 |
if(array2[4] != 400)
|
|
474 |
failures++;
|
|
475 |
if(array2[5] != 900)
|
|
476 |
failures++;
|
|
477 |
if(array2[6] != 1764)
|
|
478 |
failures++;
|
|
479 |
if(array2[7] != 3136)
|
|
480 |
failures++;
|
|
481 |
if(array2[8] != 5184)
|
|
482 |
failures++;
|
|
483 |
if(array2[9] != 8100)
|
|
484 |
failures++;
|
|
485 |
//#if STDCPP_OOM //failures++; //#endif
|
|
486 |
|
|
487 |
|
|
488 |
}
|
|
489 |
catch(bad_alloc&)
|
|
490 |
{
|
|
491 |
}
|
|
492 |
catch(...)
|
|
493 |
{
|
|
494 |
failures++;
|
|
495 |
|
|
496 |
}
|
|
497 |
|
|
498 |
// __UHEAP_MARKEND;
|
|
499 |
|
|
500 |
if(failures)
|
|
501 |
return KErrGeneral;
|
|
502 |
return KErrNone;
|
|
503 |
|
|
504 |
|
|
505 |
|
|
506 |
}
|
|
507 |
|
|
508 |
|
|
509 |
|
|
510 |
TInt Ctstl_4::Adjacent_find(CStifItemParser& aItem)
|
|
511 |
{
|
|
512 |
|
|
513 |
|
|
514 |
//__UHEAP_MARK;
|
|
515 |
|
|
516 |
int failures =0;
|
|
517 |
|
|
518 |
|
|
519 |
try
|
|
520 |
{
|
|
521 |
int myints[] = {10,20,30,30,20,10,50,60};
|
|
522 |
int myints1[]=
|
|
523 |
{
|
|
524 |
10,20,30,40,50,60,70
|
|
525 |
};
|
|
526 |
vector<int> myvector (myints,myints+8) ,myvector1(myints1,myints1+7);
|
|
527 |
vector<int>::iterator it;
|
|
528 |
//cout<<"";
|
|
529 |
#if STDCPP_OOM
|
|
530 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
531 |
|
|
532 |
#endif
|
|
533 |
it = adjacent_find (myvector.begin(), myvector.end());
|
|
534 |
#if STDCPP_OOM
|
|
535 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
536 |
|
|
537 |
|
|
538 |
#endif
|
|
539 |
/*
|
|
540 |
if(*it == 30)
|
|
541 |
|
|
542 |
|
|
543 |
// __UHEAP_MARKEND;
|
|
544 |
return KErrNone;
|
|
545 |
return KErrGeneral;
|
|
546 |
|
|
547 |
*/
|
|
548 |
if(*it!=30)
|
|
549 |
failures++;
|
|
550 |
|
|
551 |
//#if STDCPP_OOM //failures++; //#endif
|
|
552 |
}
|
|
553 |
catch(bad_alloc&)
|
|
554 |
{
|
|
555 |
|
|
556 |
}
|
|
557 |
catch(...)
|
|
558 |
{
|
|
559 |
failures++;
|
|
560 |
|
|
561 |
}
|
|
562 |
|
|
563 |
// __UHEAP_MARKEND;
|
|
564 |
|
|
565 |
if(failures)
|
|
566 |
return KErrGeneral;
|
|
567 |
return KErrNone;
|
|
568 |
|
|
569 |
|
|
570 |
|
|
571 |
|
|
572 |
|
|
573 |
}
|
|
574 |
|
|
575 |
|
|
576 |
|
|
577 |
|
|
578 |
|
|
579 |
|
|
580 |
|
|
581 |
|
|
582 |
|
|
583 |
|
|
584 |
// logical or
|
|
585 |
TInt Ctstl_4::Logical_or(CStifItemParser& aItem)
|
|
586 |
{
|
|
587 |
|
|
588 |
|
|
589 |
//__UHEAP_MARK;
|
|
590 |
int failures =0;
|
|
591 |
|
|
592 |
|
|
593 |
try
|
|
594 |
{
|
|
595 |
int input1 [4] = { 1, 1, 0, 1 };
|
|
596 |
int input2 [4] = { 0, 1, 0, 0 };
|
|
597 |
int output [4];
|
|
598 |
#if STDCPP_OOM
|
|
599 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
600 |
|
|
601 |
#endif
|
|
602 |
transform((int*)input1, (int*)input1 + 4, (int*)input2, (int*)output, logical_or<bool>());
|
|
603 |
|
|
604 |
#if STDCPP_OOM
|
|
605 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
606 |
|
|
607 |
|
|
608 |
#endif
|
|
609 |
/* if(output[0] == 1 && output[1] == 1 && output[2] ==0 && output[3] == 1)
|
|
610 |
|
|
611 |
// __UHEAP_MARKEND;
|
|
612 |
return KErrNone;
|
|
613 |
return KErrGeneral; */
|
|
614 |
if(output[0] != 1)
|
|
615 |
failures++;
|
|
616 |
if(output[1] != 1 )
|
|
617 |
failures++;
|
|
618 |
if(output[2] !=0)
|
|
619 |
failures++;
|
|
620 |
if( output[3] != 1)
|
|
621 |
failures++;
|
|
622 |
|
|
623 |
//#if STDCPP_OOM //failures++; //#endif
|
|
624 |
}
|
|
625 |
catch(bad_alloc&)
|
|
626 |
{
|
|
627 |
}
|
|
628 |
catch(...)
|
|
629 |
{
|
|
630 |
failures++;
|
|
631 |
|
|
632 |
}
|
|
633 |
|
|
634 |
// __UHEAP_MARKEND;
|
|
635 |
|
|
636 |
if(failures)
|
|
637 |
return KErrGeneral;
|
|
638 |
return KErrNone;
|
|
639 |
|
|
640 |
}
|
|
641 |
|
|
642 |
|
|
643 |
//logical and
|
|
644 |
|
|
645 |
TInt Ctstl_4::Logical_and(CStifItemParser& aItem)
|
|
646 |
{
|
|
647 |
|
|
648 |
|
|
649 |
//__UHEAP_MARK;
|
|
650 |
int failures =0;
|
|
651 |
|
|
652 |
|
|
653 |
try
|
|
654 |
{
|
|
655 |
int input1 [4] = { 1, 1, 0, 1 };
|
|
656 |
int input2 [4] = { 0, 1, 0, 0 };
|
|
657 |
int output [4];
|
|
658 |
#if STDCPP_OOM
|
|
659 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
660 |
|
|
661 |
#endif
|
|
662 |
transform((int*)input1, (int*)input1 + 4, (int*)input2, (int*)output, logical_and<bool>());
|
|
663 |
|
|
664 |
#if STDCPP_OOM
|
|
665 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
666 |
|
|
667 |
|
|
668 |
#endif
|
|
669 |
|
|
670 |
/* if(output[0] == 0 && output[1] == 1 && output[2] ==0 && output[3] == 0)
|
|
671 |
|
|
672 |
//__UHEAP_MARKEND;
|
|
673 |
|
|
674 |
return KErrNone;
|
|
675 |
return KErrGeneral; */
|
|
676 |
if(output[0] != 0)
|
|
677 |
failures++;
|
|
678 |
if(output[1] != 1 )
|
|
679 |
failures++;
|
|
680 |
if(output[2] !=0)
|
|
681 |
failures++;
|
|
682 |
if( output[3] != 0)
|
|
683 |
failures++;
|
|
684 |
|
|
685 |
//#if STDCPP_OOM //failures++; //#endif
|
|
686 |
}
|
|
687 |
catch(bad_alloc&)
|
|
688 |
{
|
|
689 |
}
|
|
690 |
catch(...)
|
|
691 |
{
|
|
692 |
failures++;
|
|
693 |
}
|
|
694 |
|
|
695 |
// __UHEAP_MARKEND;
|
|
696 |
|
|
697 |
if(failures)
|
|
698 |
return KErrGeneral;
|
|
699 |
return KErrNone;
|
|
700 |
|
|
701 |
|
|
702 |
}
|
|
703 |
|
|
704 |
|
|
705 |
//LOGICAL NOT
|
|
706 |
|
|
707 |
|
|
708 |
TInt Ctstl_4::Logical_not(CStifItemParser& aItem)
|
|
709 |
{
|
|
710 |
|
|
711 |
//__UHEAP_MARK;
|
|
712 |
int failures =0;
|
|
713 |
|
|
714 |
|
|
715 |
try
|
|
716 |
{
|
|
717 |
int input1 [4] = { 1, 1, 0, 1 };
|
|
718 |
|
|
719 |
int output [4];
|
|
720 |
#if STDCPP_OOM
|
|
721 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
722 |
|
|
723 |
#endif
|
|
724 |
transform((int*)input1, (int*)input1 + 4, (int*)output, logical_not<bool>());
|
|
725 |
|
|
726 |
|
|
727 |
#if STDCPP_OOM
|
|
728 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
729 |
|
|
730 |
|
|
731 |
#endif
|
|
732 |
/*
|
|
733 |
if(output[0] == 0 && output[1] == 0 && output[2] ==1 && output[3] == 0)
|
|
734 |
|
|
735 |
//__UHEAP_MARKEND;
|
|
736 |
|
|
737 |
return KErrNone;
|
|
738 |
return KErrGeneral; */
|
|
739 |
if(output[0] != 0)
|
|
740 |
failures++;
|
|
741 |
if(output[1] != 0 )
|
|
742 |
failures++;
|
|
743 |
if(output[2] !=1)
|
|
744 |
failures++;
|
|
745 |
if( output[3] != 0)
|
|
746 |
failures++;
|
|
747 |
|
|
748 |
//#if STDCPP_OOM //failures++; //#endif
|
|
749 |
}
|
|
750 |
catch(bad_alloc&)
|
|
751 |
{
|
|
752 |
}
|
|
753 |
catch(...)
|
|
754 |
{
|
|
755 |
failures++;
|
|
756 |
}
|
|
757 |
|
|
758 |
|
|
759 |
// __UHEAP_MARKEND;
|
|
760 |
|
|
761 |
if(failures)
|
|
762 |
return KErrGeneral;
|
|
763 |
return KErrNone;
|
|
764 |
|
|
765 |
|
|
766 |
}
|
|
767 |
|
|
768 |
|
|
769 |
//COUNT
|
|
770 |
|
|
771 |
|
|
772 |
|
|
773 |
TInt Ctstl_4::count_fun(CStifItemParser& aItem)
|
|
774 |
{
|
|
775 |
|
|
776 |
|
|
777 |
int failures =0;
|
|
778 |
|
|
779 |
|
|
780 |
try
|
|
781 |
{ // __UHEAP_MARK;
|
|
782 |
|
|
783 |
int sequence[10] = {1,2,3,4,5,5,7,8,9,10};
|
|
784 |
int i=0,j=0,k=0;
|
|
785 |
vector<int> v(sequence,sequence + 10);
|
|
786 |
//cout<<"";
|
|
787 |
#if STDCPP_OOM
|
|
788 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
789 |
|
|
790 |
#endif
|
|
791 |
count(v.begin(),v.end(),5,i);
|
|
792 |
count(v.begin(),v.end(),6,j);
|
|
793 |
count(v.begin(),v.end(),10,k);
|
|
794 |
|
|
795 |
#if STDCPP_OOM
|
|
796 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
797 |
|
|
798 |
|
|
799 |
#endif
|
|
800 |
/*
|
|
801 |
if(i==2 && j==0 && k ==1)
|
|
802 |
|
|
803 |
//__UHEAP_MARKEND;
|
|
804 |
return KErrNone;
|
|
805 |
return KErrGeneral;*/
|
|
806 |
if(i!=2)
|
|
807 |
failures++;
|
|
808 |
if(j!=0)
|
|
809 |
failures++;
|
|
810 |
if(k!=1)
|
|
811 |
failures++;
|
|
812 |
//#if STDCPP_OOM //failures++; //#endif
|
|
813 |
|
|
814 |
}
|
|
815 |
catch(bad_alloc&)
|
|
816 |
{
|
|
817 |
}
|
|
818 |
catch(...)
|
|
819 |
{
|
|
820 |
failures++;
|
|
821 |
|
|
822 |
}
|
|
823 |
|
|
824 |
// __UHEAP_MARKEND;
|
|
825 |
|
|
826 |
if(failures)
|
|
827 |
return KErrGeneral;
|
|
828 |
return KErrNone;
|
|
829 |
|
|
830 |
}
|
|
831 |
|
|
832 |
|
|
833 |
|
|
834 |
|
|
835 |
//COUNTIF
|
|
836 |
TInt Ctstl_4::countif_fun(CStifItemParser& aItem)
|
|
837 |
{
|
|
838 |
|
|
839 |
//__UHEAP_MARK;
|
|
840 |
int failures =0;
|
|
841 |
|
|
842 |
try
|
|
843 |
{
|
|
844 |
int sequence[10] = {1,2,3,4,5,5,7,8,9,10};
|
|
845 |
int i=0 ,j=0;
|
|
846 |
vector<int> v(sequence,sequence + 10);
|
|
847 |
//cout<<"";
|
|
848 |
#if STDCPP_OOM
|
|
849 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
850 |
|
|
851 |
#endif
|
|
852 |
|
|
853 |
count_if(v.begin(),v.end(),bind2nd(less<int>(),8),i);
|
|
854 |
count_if(v.begin(),v.end(),bind2nd(less<int>(),1),j);
|
|
855 |
#if STDCPP_OOM
|
|
856 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
857 |
|
|
858 |
|
|
859 |
#endif
|
|
860 |
|
|
861 |
/*
|
|
862 |
if(i==7 && j==0)
|
|
863 |
|
|
864 |
//__UHEAP_MARKEND ;
|
|
865 |
return KErrNone;
|
|
866 |
return KErrGeneral;*/
|
|
867 |
if(i!=7)
|
|
868 |
failures++;
|
|
869 |
if(j!=0)
|
|
870 |
failures++;
|
|
871 |
//#if STDCPP_OOM //failures++; //#endif
|
|
872 |
}
|
|
873 |
catch(bad_alloc&)
|
|
874 |
{
|
|
875 |
}
|
|
876 |
catch(...)
|
|
877 |
{
|
|
878 |
failures++;
|
|
879 |
|
|
880 |
}
|
|
881 |
|
|
882 |
// __UHEAP_MARKEND;
|
|
883 |
|
|
884 |
if(failures)
|
|
885 |
return KErrGeneral;
|
|
886 |
return KErrNone;
|
|
887 |
|
|
888 |
}
|
|
889 |
|
|
890 |
|
|
891 |
//equal
|
|
892 |
|
|
893 |
|
|
894 |
TInt Ctstl_4::equal_fun(CStifItemParser& aItem)
|
|
895 |
{
|
|
896 |
|
|
897 |
|
|
898 |
//__UHEAP_MARK;
|
|
899 |
int failures =0;
|
|
900 |
|
|
901 |
|
|
902 |
try
|
|
903 |
{
|
|
904 |
int input1 [4] = { 0, 4, 6, -7 };
|
|
905 |
int input2 [4] = { -0, 34, 6, -7 };
|
|
906 |
|
|
907 |
vector<int> v1(input1+0, input1 + 3), v2(input2+0, input2 + 3);
|
|
908 |
#if STDCPP_OOM
|
|
909 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
910 |
|
|
911 |
#endif
|
|
912 |
// Check for equality
|
|
913 |
if(equal(v1.begin(),v1.end(),v2.begin()))
|
|
914 |
failures++;
|
|
915 |
//__UHEAP_MARKEND;
|
|
916 |
//return KErrNone;
|
|
917 |
//return KErrGeneral;
|
|
918 |
|
|
919 |
#if STDCPP_OOM
|
|
920 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
921 |
|
|
922 |
|
|
923 |
#endif
|
|
924 |
//#if STDCPP_OOM //failures++; //#endif
|
|
925 |
}
|
|
926 |
catch(bad_alloc&)
|
|
927 |
{
|
|
928 |
}
|
|
929 |
catch(...)
|
|
930 |
{
|
|
931 |
failures++;
|
|
932 |
|
|
933 |
}
|
|
934 |
|
|
935 |
// __UHEAP_MARKEND;
|
|
936 |
|
|
937 |
if(failures)
|
|
938 |
return KErrGeneral;
|
|
939 |
return KErrNone;
|
|
940 |
|
|
941 |
|
|
942 |
|
|
943 |
|
|
944 |
}
|
|
945 |
|
|
946 |
|
|
947 |
|
|
948 |
|
|
949 |
|
|
950 |
|
|
951 |
//equalto
|
|
952 |
|
|
953 |
TInt Ctstl_4::equalto(CStifItemParser& aItem)
|
|
954 |
{
|
|
955 |
|
|
956 |
|
|
957 |
// __UHEAP_MARK;
|
|
958 |
int failures =0;
|
|
959 |
|
|
960 |
try
|
|
961 |
{
|
|
962 |
int input1 [4] = { 0, 4, 6, -7 };
|
|
963 |
int input2 [4] = { -0, 34, 6, -7 };
|
|
964 |
int output [4];
|
|
965 |
#if STDCPP_OOM
|
|
966 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
967 |
|
|
968 |
#endif
|
|
969 |
|
|
970 |
transform((int*)input1, (int*)input1 + 4, (int*)input2, (int*)output, equal_to<int>());
|
|
971 |
#if STDCPP_OOM
|
|
972 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
973 |
|
|
974 |
|
|
975 |
#endif
|
|
976 |
/*
|
|
977 |
if(output[0] == 1 && output[1] == 0 && output[2] ==1 && output[3] == 1)
|
|
978 |
|
|
979 |
//__UHEAP_MARKEND;
|
|
980 |
|
|
981 |
return KErrNone;
|
|
982 |
return KErrGeneral;*/
|
|
983 |
if(output[0] != 1)
|
|
984 |
failures++;
|
|
985 |
if(output[1] != 0 )
|
|
986 |
failures++;
|
|
987 |
if(output[2] !=1)
|
|
988 |
failures++;
|
|
989 |
if( output[3] != 1)
|
|
990 |
failures++;
|
|
991 |
|
|
992 |
//#if STDCPP_OOM //failures++; //#endif
|
|
993 |
}
|
|
994 |
catch(bad_alloc&)
|
|
995 |
{
|
|
996 |
}
|
|
997 |
catch(...)
|
|
998 |
{
|
|
999 |
failures++;
|
|
1000 |
|
|
1001 |
}
|
|
1002 |
|
|
1003 |
// __UHEAP_MARKEND;
|
|
1004 |
|
|
1005 |
if(failures)
|
|
1006 |
return KErrGeneral;
|
|
1007 |
return KErrNone;
|
|
1008 |
}
|
|
1009 |
|
|
1010 |
|
|
1011 |
//NOTEQUAL TO
|
|
1012 |
|
|
1013 |
TInt Ctstl_4::notequalto(CStifItemParser& aItem)
|
|
1014 |
{
|
|
1015 |
int failures =0;
|
|
1016 |
|
|
1017 |
|
|
1018 |
try
|
|
1019 |
{
|
|
1020 |
|
|
1021 |
//__UHEAP_MARK;
|
|
1022 |
int input1 [4] = { 0, 4, 6, -7 };
|
|
1023 |
int input2 [4] = { -0, 34, 6, -7 };
|
|
1024 |
int output [4];
|
|
1025 |
#if STDCPP_OOM
|
|
1026 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
1027 |
|
|
1028 |
#endif
|
|
1029 |
transform((int*)input1, (int*)input1 + 4, (int*)input2, (int*)output, not_equal_to<int>());
|
|
1030 |
|
|
1031 |
#if STDCPP_OOM
|
|
1032 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
1033 |
|
|
1034 |
|
|
1035 |
#endif
|
|
1036 |
/*
|
|
1037 |
if(output[0] == 0 && output[1] == 1 && output[2] ==0 && output[3] == 0)
|
|
1038 |
|
|
1039 |
//__UHEAP_MARKEND;
|
|
1040 |
|
|
1041 |
return KErrNone;
|
|
1042 |
return KErrGeneral;*/
|
|
1043 |
if(output[0] != 0)
|
|
1044 |
failures++;
|
|
1045 |
if(output[1] != 1)
|
|
1046 |
failures++;
|
|
1047 |
if(output[2] !=0)
|
|
1048 |
failures++;
|
|
1049 |
if( output[3] != 0)
|
|
1050 |
failures++;
|
|
1051 |
|
|
1052 |
//#if STDCPP_OOM //failures++; //#endif
|
|
1053 |
|
|
1054 |
|
|
1055 |
}
|
|
1056 |
catch(bad_alloc&)
|
|
1057 |
{
|
|
1058 |
}
|
|
1059 |
catch(...)
|
|
1060 |
{
|
|
1061 |
failures++;
|
|
1062 |
|
|
1063 |
}
|
|
1064 |
|
|
1065 |
// __UHEAP_MARKEND;
|
|
1066 |
|
|
1067 |
if(failures)
|
|
1068 |
return KErrGeneral;
|
|
1069 |
return KErrNone;
|
|
1070 |
}
|
|
1071 |
|
|
1072 |
|
|
1073 |
|
|
1074 |
|
|
1075 |
//sort
|
|
1076 |
|
|
1077 |
TInt Ctstl_4::sort_fun(CStifItemParser& aItem)
|
|
1078 |
{
|
|
1079 |
|
|
1080 |
int failures =0;
|
|
1081 |
|
|
1082 |
|
|
1083 |
try
|
|
1084 |
{
|
|
1085 |
// __UHEAP_MARK;
|
|
1086 |
int sequence[7] = {6262, 6262, 41 ,18467, 6334, 26500, 19169 };
|
|
1087 |
vector <int>::iterator Iter1;
|
|
1088 |
|
|
1089 |
int output[7];
|
|
1090 |
|
|
1091 |
vector<int> v1(sequence,sequence + 7);
|
|
1092 |
//cout<<"";
|
|
1093 |
#if STDCPP_OOM
|
|
1094 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
1095 |
|
|
1096 |
#endif
|
|
1097 |
sort( v1.begin( ), v1.end( ) );
|
|
1098 |
#if STDCPP_OOM
|
|
1099 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
1100 |
|
|
1101 |
|
|
1102 |
#endif
|
|
1103 |
for ( Iter1 = v1.begin( ) ; Iter1 != v1.end( ) ; Iter1++ )
|
|
1104 |
|
|
1105 |
{
|
|
1106 |
static int i = 0;
|
|
1107 |
|
|
1108 |
output[i] = *Iter1;
|
|
1109 |
i++;
|
|
1110 |
|
|
1111 |
}
|
|
1112 |
|
|
1113 |
/*(output[0] == 41 && output[1] == 6262 && output[2] == 6262 && output[3] == 6334 && output[4] == 18467 && output[5] == 19169 && output[6] == 26500)
|
|
1114 |
|
|
1115 |
// __UHEAP_MARKEND;
|
|
1116 |
|
|
1117 |
return KErrNone ;
|
|
1118 |
return KErrGeneral;*/
|
|
1119 |
if(output[0] != 41)
|
|
1120 |
failures++;
|
|
1121 |
if(output[1] != 6262)
|
|
1122 |
failures++;
|
|
1123 |
if(output[2] !=6262)
|
|
1124 |
failures++;
|
|
1125 |
if( output[3] != 6334)
|
|
1126 |
failures++;
|
|
1127 |
if(output[4] != 18467)
|
|
1128 |
failures++;
|
|
1129 |
if(output[5] !=19169)
|
|
1130 |
failures++;
|
|
1131 |
if( output[6] != 26500)
|
|
1132 |
failures++;
|
|
1133 |
|
|
1134 |
//#if STDCPP_OOM //failures++; //#endif
|
|
1135 |
}
|
|
1136 |
catch(bad_alloc&)
|
|
1137 |
{
|
|
1138 |
}
|
|
1139 |
catch(...)
|
|
1140 |
{
|
|
1141 |
failures++;
|
|
1142 |
|
|
1143 |
}
|
|
1144 |
|
|
1145 |
// __UHEAP_MARKEND;
|
|
1146 |
|
|
1147 |
if(failures)
|
|
1148 |
return KErrGeneral;
|
|
1149 |
return KErrNone;
|
|
1150 |
|
|
1151 |
}
|
|
1152 |
|
|
1153 |
|
|
1154 |
|
|
1155 |
|
|
1156 |
//less_equal
|
|
1157 |
|
|
1158 |
TInt Ctstl_4::less_equal_fun(CStifItemParser& aItem)
|
|
1159 |
{
|
|
1160 |
|
|
1161 |
|
|
1162 |
// __UHEAP_MARK;
|
|
1163 |
int failures =0;
|
|
1164 |
|
|
1165 |
|
|
1166 |
try
|
|
1167 |
{
|
|
1168 |
int sequence[7] = {6262, 6262, 41 ,18467, 6334, 26500, 19169 };
|
|
1169 |
vector <int>::iterator Iter1;
|
|
1170 |
|
|
1171 |
int output[7];
|
|
1172 |
|
|
1173 |
vector<int> v1(sequence,sequence + 7);
|
|
1174 |
#if STDCPP_OOM
|
|
1175 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
1176 |
|
|
1177 |
#endif
|
|
1178 |
sort( v1.begin( ), v1.end( ),less_equal<int>( ) );
|
|
1179 |
#if STDCPP_OOM
|
|
1180 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
1181 |
|
|
1182 |
|
|
1183 |
#endif
|
|
1184 |
for ( Iter1 = v1.begin( ) ; Iter1 != v1.end( ) ; Iter1++ )
|
|
1185 |
|
|
1186 |
{
|
|
1187 |
static int i = 0;
|
|
1188 |
|
|
1189 |
output[i] = *Iter1;
|
|
1190 |
i++;
|
|
1191 |
|
|
1192 |
}
|
|
1193 |
|
|
1194 |
/* if(output[0] == 41 && output[1] == 6262 && output[2] == 6262 && output[3] == 6334 && output[4] == 18467 && output[5] == 19169 && output[6] == 26500)
|
|
1195 |
|
|
1196 |
// __UHEAP_MARKEND;
|
|
1197 |
|
|
1198 |
|
|
1199 |
return KErrNone ;
|
|
1200 |
return KErrGeneral;*/
|
|
1201 |
if(output[0] != 41)
|
|
1202 |
failures++;
|
|
1203 |
if(output[1] != 6262)
|
|
1204 |
failures++;
|
|
1205 |
if(output[2] !=6262)
|
|
1206 |
failures++;
|
|
1207 |
if( output[3] != 6334)
|
|
1208 |
failures++;
|
|
1209 |
if(output[4] != 18467)
|
|
1210 |
failures++;
|
|
1211 |
if(output[5] !=19169)
|
|
1212 |
failures++;
|
|
1213 |
if( output[6] != 26500)
|
|
1214 |
failures++;
|
|
1215 |
|
|
1216 |
//#if STDCPP_OOM //failures++; //#endif
|
|
1217 |
|
|
1218 |
}
|
|
1219 |
catch(bad_alloc&)
|
|
1220 |
{
|
|
1221 |
}
|
|
1222 |
catch(...)
|
|
1223 |
{
|
|
1224 |
failures++;
|
|
1225 |
|
|
1226 |
}
|
|
1227 |
|
|
1228 |
// __UHEAP_MARKEND;
|
|
1229 |
|
|
1230 |
if(failures)
|
|
1231 |
return KErrGeneral;
|
|
1232 |
return KErrNone;
|
|
1233 |
}
|
|
1234 |
|
|
1235 |
|
|
1236 |
|
|
1237 |
|
|
1238 |
|
|
1239 |
//greater_equal
|
|
1240 |
|
|
1241 |
TInt Ctstl_4::greater_equal_fun(CStifItemParser& aItem)
|
|
1242 |
{
|
|
1243 |
|
|
1244 |
|
|
1245 |
// __UHEAP_MARK;
|
|
1246 |
int failures =0;
|
|
1247 |
|
|
1248 |
|
|
1249 |
try
|
|
1250 |
{
|
|
1251 |
int sequence[7] = {6262, 6262, 41 ,18467, 6334, 26500, 19169 };
|
|
1252 |
vector <int>::iterator Iter1;
|
|
1253 |
|
|
1254 |
int output[7];
|
|
1255 |
|
|
1256 |
vector<int> v1(sequence,sequence + 7);
|
|
1257 |
#if STDCPP_OOM
|
|
1258 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
1259 |
|
|
1260 |
#endif
|
|
1261 |
sort( v1.begin( ), v1.end( ) ,greater_equal<int>( ) );
|
|
1262 |
#if STDCPP_OOM
|
|
1263 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
1264 |
|
|
1265 |
|
|
1266 |
#endif
|
|
1267 |
for ( Iter1 = v1.begin( ) ; Iter1 != v1.end( ) ; Iter1++ )
|
|
1268 |
|
|
1269 |
{
|
|
1270 |
static int i = 0;
|
|
1271 |
|
|
1272 |
output[i] = *Iter1;
|
|
1273 |
i++;
|
|
1274 |
|
|
1275 |
}
|
|
1276 |
|
|
1277 |
/* if(output[6] == 41 && output[5] == 6262 && output[4] == 6262 && output[3] == 6334 && output[2] == 18467 && output[1] == 19169 && output[0] == 26500)
|
|
1278 |
|
|
1279 |
// __UHEAP_MARKEND;
|
|
1280 |
|
|
1281 |
return KErrNone ;
|
|
1282 |
return KErrGeneral;*/
|
|
1283 |
if(output[6] != 41)
|
|
1284 |
failures++;
|
|
1285 |
if(output[5] != 6262)
|
|
1286 |
failures++;
|
|
1287 |
if(output[4] !=6262)
|
|
1288 |
failures++;
|
|
1289 |
if( output[3] != 6334)
|
|
1290 |
failures++;
|
|
1291 |
if(output[2] != 18467)
|
|
1292 |
failures++;
|
|
1293 |
if(output[1] !=19169)
|
|
1294 |
failures++;
|
|
1295 |
if( output[0] != 26500)
|
|
1296 |
failures++;
|
|
1297 |
|
|
1298 |
//#if STDCPP_OOM //failures++; //#endif
|
|
1299 |
}
|
|
1300 |
catch(bad_alloc&)
|
|
1301 |
{
|
|
1302 |
}
|
|
1303 |
catch(...)
|
|
1304 |
{
|
|
1305 |
failures++;
|
|
1306 |
|
|
1307 |
}
|
|
1308 |
|
|
1309 |
// __UHEAP_MARKEND;
|
|
1310 |
|
|
1311 |
if(failures)
|
|
1312 |
return KErrGeneral;
|
|
1313 |
return KErrNone;
|
|
1314 |
}
|
|
1315 |
|
|
1316 |
|
|
1317 |
|
|
1318 |
//greater
|
|
1319 |
|
|
1320 |
TInt Ctstl_4::greater_fun(CStifItemParser& aItem)
|
|
1321 |
{
|
|
1322 |
|
|
1323 |
int failures =0;
|
|
1324 |
|
|
1325 |
|
|
1326 |
try
|
|
1327 |
{
|
|
1328 |
//__UHEAP_MARK;
|
|
1329 |
int input1 [4] = { 0, 4, 6, 8 };
|
|
1330 |
int input2 [4] = { -0, 34, 6, -7 };
|
|
1331 |
int output [4];
|
|
1332 |
#if STDCPP_OOM
|
|
1333 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
1334 |
|
|
1335 |
#endif
|
|
1336 |
transform((int*)input1, (int*)input1 + 4, (int*)input2, (int*)output, greater<int>());
|
|
1337 |
#if STDCPP_OOM
|
|
1338 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
1339 |
|
|
1340 |
|
|
1341 |
#endif
|
|
1342 |
// After this call to transform, output will contain a "1" if input1
|
|
1343 |
//was greater than input2 or a "0" if input1 was less than or equal to
|
|
1344 |
//input2.
|
|
1345 |
/*
|
|
1346 |
if(output[0] == 0 && output[1] == 0 && output[2] == 0 && output[3] == 1)
|
|
1347 |
// __UHEAP_MARKEND;
|
|
1348 |
return KErrNone;
|
|
1349 |
return KErrGeneral;*/
|
|
1350 |
if(output[0] != 0)
|
|
1351 |
failures++;
|
|
1352 |
if(output[1] != 0)
|
|
1353 |
failures++;
|
|
1354 |
if(output[2] !=0)
|
|
1355 |
failures++;
|
|
1356 |
if( output[3] != 1)
|
|
1357 |
failures++;
|
|
1358 |
|
|
1359 |
//#if STDCPP_OOM //failures++; //#endif
|
|
1360 |
}
|
|
1361 |
catch(bad_alloc&)
|
|
1362 |
{
|
|
1363 |
}
|
|
1364 |
catch(...)
|
|
1365 |
{
|
|
1366 |
failures++;
|
|
1367 |
|
|
1368 |
}
|
|
1369 |
|
|
1370 |
// __UHEAP_MARKEND;
|
|
1371 |
|
|
1372 |
if(failures)
|
|
1373 |
return KErrGeneral;
|
|
1374 |
return KErrNone;
|
|
1375 |
|
|
1376 |
|
|
1377 |
|
|
1378 |
|
|
1379 |
}
|
|
1380 |
|
|
1381 |
|
|
1382 |
//LESS
|
|
1383 |
|
|
1384 |
TInt Ctstl_4::less_fun(CStifItemParser& aItem)
|
|
1385 |
{
|
|
1386 |
// __UHEAP_MARK;
|
|
1387 |
int failures =0;
|
|
1388 |
|
|
1389 |
|
|
1390 |
try
|
|
1391 |
{ int input1 [4] = { 0, 4, 6, 8 };
|
|
1392 |
int input2 [4] = { -0, 34, 6, -7 };
|
|
1393 |
int output [4];
|
|
1394 |
#if STDCPP_OOM
|
|
1395 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
1396 |
|
|
1397 |
#endif
|
|
1398 |
transform((int*)input1, (int*)input1 + 4, (int*)input2, (int*)output, less<int>());
|
|
1399 |
#if STDCPP_OOM
|
|
1400 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
1401 |
|
|
1402 |
|
|
1403 |
#endif
|
|
1404 |
//After this call to transform, output will contain a "1" if intput1
|
|
1405 |
//was less than input2 or a "0" if intput1 was greater than or equal to
|
|
1406 |
//input2.
|
|
1407 |
|
|
1408 |
/* if(output[0] == 0 && output[1] == 1 && output[2] == 0 && output[3] == 0)
|
|
1409 |
// __UHEAP_MARKEND;
|
|
1410 |
return KErrNone;
|
|
1411 |
return KErrGeneral;*/
|
|
1412 |
if(output[0] != 0)
|
|
1413 |
failures++;
|
|
1414 |
if(output[1] != 1)
|
|
1415 |
failures++;
|
|
1416 |
if(output[2] !=0)
|
|
1417 |
failures++;
|
|
1418 |
if( output[3] != 0)
|
|
1419 |
failures++;
|
|
1420 |
|
|
1421 |
//#if STDCPP_OOM //failures++; //#endif
|
|
1422 |
|
|
1423 |
}
|
|
1424 |
catch(bad_alloc&)
|
|
1425 |
{
|
|
1426 |
}
|
|
1427 |
catch(...)
|
|
1428 |
{
|
|
1429 |
failures++;
|
|
1430 |
|
|
1431 |
}
|
|
1432 |
|
|
1433 |
// __UHEAP_MARKEND;
|
|
1434 |
|
|
1435 |
if(failures)
|
|
1436 |
return KErrGeneral;
|
|
1437 |
return KErrNone;
|
|
1438 |
}
|
|
1439 |
|
|
1440 |
|
|
1441 |
|
|
1442 |
// find code check
|
|
1443 |
//---------------------
|
|
1444 |
|
|
1445 |
TInt Ctstl_4::find_fun(CStifItemParser& aItem)
|
|
1446 |
{
|
|
1447 |
// __UHEAP_MARK;
|
|
1448 |
int failures =0;
|
|
1449 |
|
|
1450 |
try
|
|
1451 |
{ typedef vector<int>::iterator iterator;
|
|
1452 |
int d1[10] = {0,1,2,2,3,4,2,2,6,7};
|
|
1453 |
|
|
1454 |
vector<int> v1(d1,d1 + 10);
|
|
1455 |
//cout<<"";
|
|
1456 |
#if STDCPP_OOM
|
|
1457 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
1458 |
|
|
1459 |
#endif
|
|
1460 |
|
|
1461 |
iterator it1 = find(v1.begin(),v1.end(),3);
|
|
1462 |
#if STDCPP_OOM
|
|
1463 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
1464 |
|
|
1465 |
|
|
1466 |
#endif
|
|
1467 |
//last iterator is returned if unfound
|
|
1468 |
|
|
1469 |
/* if((it1) && ((*it1) == 3) )
|
|
1470 |
|
|
1471 |
|
|
1472 |
|
|
1473 |
// __UHEAP_MARKEND;
|
|
1474 |
return KErrNone;
|
|
1475 |
return KErrGeneral; */
|
|
1476 |
|
|
1477 |
if((it1) && ((*it1) != 3) )
|
|
1478 |
failures++;
|
|
1479 |
//#if STDCPP_OOM
|
|
1480 |
// failures++;
|
|
1481 |
// #endif
|
|
1482 |
}
|
|
1483 |
catch(bad_alloc&)
|
|
1484 |
{
|
|
1485 |
}
|
|
1486 |
catch(...)
|
|
1487 |
{
|
|
1488 |
failures++;
|
|
1489 |
|
|
1490 |
}
|
|
1491 |
|
|
1492 |
// __UHEAP_MARKEND;
|
|
1493 |
|
|
1494 |
if(failures)
|
|
1495 |
return KErrGeneral;
|
|
1496 |
return KErrNone;
|
|
1497 |
|
|
1498 |
|
|
1499 |
}
|
|
1500 |
|
|
1501 |
|
|
1502 |
|
|
1503 |
// find_if
|
|
1504 |
//----------------------
|
|
1505 |
|
|
1506 |
|
|
1507 |
TInt Ctstl_4::findif_fun(CStifItemParser& aItem)
|
|
1508 |
{
|
|
1509 |
|
|
1510 |
//__UHEAP_MARK;
|
|
1511 |
|
|
1512 |
int failures =0;
|
|
1513 |
|
|
1514 |
|
|
1515 |
try
|
|
1516 |
{ typedef vector<int>::iterator iterator;
|
|
1517 |
int d1[10] = {0,1,2,2,3,4,2,2,6,7};
|
|
1518 |
|
|
1519 |
vector<int> v1(d1,d1 + 10);
|
|
1520 |
//cout<<"";
|
|
1521 |
#if STDCPP_OOM
|
|
1522 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
1523 |
|
|
1524 |
#endif
|
|
1525 |
iterator it1 = find_if(v1.begin(),v1.end(),bind1st(equal_to<int>(),7));
|
|
1526 |
|
|
1527 |
#if STDCPP_OOM
|
|
1528 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
1529 |
|
|
1530 |
|
|
1531 |
#endif
|
|
1532 |
//last iterator is returned if unfound
|
|
1533 |
/* if((it1) && ((*it1) == 7) )
|
|
1534 |
|
|
1535 |
//__UHEAP_MARKEND;
|
|
1536 |
return KErrNone;
|
|
1537 |
return KErrGeneral;*/
|
|
1538 |
if((it1) && ((*it1) != 7) )
|
|
1539 |
failures++;
|
|
1540 |
//#if STDCPP_OOM //failures++; //#endif
|
|
1541 |
|
|
1542 |
}
|
|
1543 |
catch(bad_alloc&)
|
|
1544 |
{
|
|
1545 |
}
|
|
1546 |
catch(...)
|
|
1547 |
{
|
|
1548 |
failures++;
|
|
1549 |
|
|
1550 |
}
|
|
1551 |
|
|
1552 |
// __UHEAP_MARKEND;
|
|
1553 |
|
|
1554 |
if(failures)
|
|
1555 |
return KErrGeneral;
|
|
1556 |
return KErrNone;
|
|
1557 |
|
|
1558 |
|
|
1559 |
|
|
1560 |
}
|
|
1561 |
|
|
1562 |
|
|
1563 |
|
|
1564 |
//find_end
|
|
1565 |
|
|
1566 |
TInt Ctstl_4::findend_fun(CStifItemParser& aItem)
|
|
1567 |
{
|
|
1568 |
|
|
1569 |
|
|
1570 |
//__UHEAP_MARK;
|
|
1571 |
int failures =0;
|
|
1572 |
|
|
1573 |
|
|
1574 |
try
|
|
1575 |
{
|
|
1576 |
int array1[12] = {0,5,10,15,20,25,0,5,10,15,20,25};
|
|
1577 |
int array2[3] = {20,30,40 };
|
|
1578 |
int array3[4]= {5,10,15,20 };
|
|
1579 |
int array4[4] ={30,40,50,60 }; //not found iterator
|
|
1580 |
|
|
1581 |
|
|
1582 |
vector <int> v1(array1,array1+12), v2(array2,array2+3),v3(array3,array3+4);
|
|
1583 |
vector<int> v4(array4,array4+4);
|
|
1584 |
// vector <int>::iterator Iter1, Iter2,Iter3 ,Iter4;
|
|
1585 |
|
|
1586 |
|
|
1587 |
vector <int>::iterator result1;
|
|
1588 |
|
|
1589 |
|
|
1590 |
//cout<<"";
|
|
1591 |
#if STDCPP_OOM
|
|
1592 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
1593 |
|
|
1594 |
#endif
|
|
1595 |
result1 = find_end( v1.begin( ), v1.end( ), v3.begin( ), v3.end( ) );
|
|
1596 |
|
|
1597 |
// result2 = find_end ( v1.begin( ), v1.end( ), v4.begin( ), v4.end( ) );
|
|
1598 |
#if STDCPP_OOM
|
|
1599 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
1600 |
|
|
1601 |
#endif
|
|
1602 |
|
|
1603 |
/* if((result1 - v1.begin() == 7) && (result1 - v1.begin( ) != 1))
|
|
1604 |
|
|
1605 |
if(result2 == v1.end()) // if not found
|
|
1606 |
|
|
1607 |
// __UHEAP_MARKEND;
|
|
1608 |
return KErrNone;
|
|
1609 |
return KErrGeneral;*/
|
|
1610 |
if((result1 - v1.begin() != 7) && (result1 - v1.begin( ) == 1))
|
|
1611 |
failures++;
|
|
1612 |
//#if STDCPP_OOM //failures++; //#endif
|
|
1613 |
}
|
|
1614 |
catch(bad_alloc&)
|
|
1615 |
{
|
|
1616 |
}
|
|
1617 |
catch(...)
|
|
1618 |
{
|
|
1619 |
failures++;
|
|
1620 |
|
|
1621 |
}
|
|
1622 |
|
|
1623 |
// __UHEAP_MARKEND;
|
|
1624 |
|
|
1625 |
if(failures)
|
|
1626 |
return KErrGeneral;
|
|
1627 |
return KErrNone;
|
|
1628 |
|
|
1629 |
|
|
1630 |
|
|
1631 |
}
|
|
1632 |
|
|
1633 |
|
|
1634 |
|
|
1635 |
|
|
1636 |
|
|
1637 |
|
|
1638 |
// Ctstl_4::Minof
|
|
1639 |
|
|
1640 |
|
|
1641 |
TInt Ctstl_4::Minof( CStifItemParser& aItem )
|
|
1642 |
{
|
|
1643 |
|
|
1644 |
int failures =0;
|
|
1645 |
|
|
1646 |
|
|
1647 |
try
|
|
1648 |
{
|
|
1649 |
int result_int1;
|
|
1650 |
int result_int2;
|
|
1651 |
char result_char;
|
|
1652 |
#if STDCPP_OOM
|
|
1653 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
1654 |
|
|
1655 |
#endif
|
|
1656 |
result_int1 = min(2,1);
|
|
1657 |
result_int2 = min(-2,-25);
|
|
1658 |
result_char = min('a','z');
|
|
1659 |
|
|
1660 |
#if STDCPP_OOM
|
|
1661 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
1662 |
|
|
1663 |
|
|
1664 |
#endif
|
|
1665 |
|
|
1666 |
/* if (result_int1 == 1)
|
|
1667 |
if(result_int2 == -25)
|
|
1668 |
if (result_char == 'a')
|
|
1669 |
if(min(2.23,2.24) == 2.23)
|
|
1670 |
|
|
1671 |
|
|
1672 |
return KErrNone;
|
|
1673 |
return KErrGeneral;
|
|
1674 |
*/
|
|
1675 |
if (result_int1 != 1)
|
|
1676 |
failures++;
|
|
1677 |
|
|
1678 |
if(result_int2 != -25)
|
|
1679 |
failures++;
|
|
1680 |
if (result_char != 'a')
|
|
1681 |
failures++;
|
|
1682 |
if(min(2.23,2.24) != 2.23)
|
|
1683 |
failures++;
|
|
1684 |
|
|
1685 |
}
|
|
1686 |
catch(bad_alloc&)
|
|
1687 |
{
|
|
1688 |
//do nothing
|
|
1689 |
}
|
|
1690 |
catch(...)
|
|
1691 |
{
|
|
1692 |
failures++;
|
|
1693 |
|
|
1694 |
}
|
|
1695 |
|
|
1696 |
|
|
1697 |
if(failures)
|
|
1698 |
return KErrGeneral;
|
|
1699 |
return KErrNone;
|
|
1700 |
|
|
1701 |
|
|
1702 |
|
|
1703 |
}
|
|
1704 |
|
|
1705 |
|
|
1706 |
|
|
1707 |
TInt Ctstl_4::Maxelement(CStifItemParser& aItem)
|
|
1708 |
{
|
|
1709 |
|
|
1710 |
|
|
1711 |
|
|
1712 |
|
|
1713 |
int failures =0;
|
|
1714 |
|
|
1715 |
|
|
1716 |
try
|
|
1717 |
{
|
|
1718 |
|
|
1719 |
int test_array1[] = { 0,-2,-3333,1,23,3333,234,989};
|
|
1720 |
char test_array2[] = {'c','d','z','e','w'};
|
|
1721 |
|
|
1722 |
int test_variable1;
|
|
1723 |
char test_variable2;
|
|
1724 |
|
|
1725 |
#if STDCPP_OOM
|
|
1726 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
1727 |
|
|
1728 |
#endif
|
|
1729 |
test_variable1 = *max_element(test_array1,test_array1 + 8);
|
|
1730 |
test_variable2 = *max_element(test_array2,test_array2+5);
|
|
1731 |
int test_variable3 =*max_element(test_array1,test_array1 + 7);
|
|
1732 |
|
|
1733 |
#if STDCPP_OOM
|
|
1734 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
1735 |
|
|
1736 |
|
|
1737 |
#endif
|
|
1738 |
/*if((test_variable1 == 3333)&&(test_variable2 == 'z'))
|
|
1739 |
if(test_variable3!=3333)
|
|
1740 |
|
|
1741 |
return KErrNone;
|
|
1742 |
return KErrGeneral;
|
|
1743 |
*/
|
|
1744 |
|
|
1745 |
if((test_variable1 != 3333)&&(test_variable2 != 'z'))
|
|
1746 |
failures++;
|
|
1747 |
if(test_variable3!=3333)
|
|
1748 |
failures++;
|
|
1749 |
|
|
1750 |
|
|
1751 |
}
|
|
1752 |
catch(bad_alloc&)
|
|
1753 |
{
|
|
1754 |
//do nothing
|
|
1755 |
}
|
|
1756 |
catch(...)
|
|
1757 |
{
|
|
1758 |
failures++;
|
|
1759 |
|
|
1760 |
}
|
|
1761 |
|
|
1762 |
|
|
1763 |
|
|
1764 |
if(failures)
|
|
1765 |
return KErrGeneral;
|
|
1766 |
return KErrNone;
|
|
1767 |
|
|
1768 |
|
|
1769 |
}
|
|
1770 |
|
|
1771 |
|
|
1772 |
|
|
1773 |
|
|
1774 |
|
|
1775 |
TInt Ctstl_4::Minelement(CStifItemParser& aItem)
|
|
1776 |
{
|
|
1777 |
|
|
1778 |
|
|
1779 |
int failures =0;
|
|
1780 |
|
|
1781 |
try
|
|
1782 |
{
|
|
1783 |
|
|
1784 |
int test_array1[] = { 0,-2,-3333,1,23,3333,234,989};
|
|
1785 |
char test_array2[] = {'c','d','z','e','w'};
|
|
1786 |
|
|
1787 |
int test_variable1;
|
|
1788 |
char test_variable2;
|
|
1789 |
|
|
1790 |
|
|
1791 |
#if STDCPP_OOM
|
|
1792 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
1793 |
|
|
1794 |
#endif
|
|
1795 |
test_variable1 = *min_element(test_array1,test_array1 + 8);
|
|
1796 |
test_variable2 = *min_element(test_array2,test_array2 + 5);
|
|
1797 |
|
|
1798 |
#if STDCPP_OOM
|
|
1799 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
1800 |
|
|
1801 |
|
|
1802 |
#endif
|
|
1803 |
|
|
1804 |
/* if((test_variable1 == -3333)&&(test_variable2 == 'c'))
|
|
1805 |
|
|
1806 |
|
|
1807 |
return KErrNone;
|
|
1808 |
return KErrGeneral;*/
|
|
1809 |
|
|
1810 |
if(test_variable1 != -3333)failures++;
|
|
1811 |
if(test_variable2 != 'c') failures++;
|
|
1812 |
}
|
|
1813 |
catch(bad_alloc&)
|
|
1814 |
{
|
|
1815 |
return KErrNone;
|
|
1816 |
}
|
|
1817 |
catch(...)
|
|
1818 |
{
|
|
1819 |
failures++;
|
|
1820 |
|
|
1821 |
}
|
|
1822 |
|
|
1823 |
|
|
1824 |
|
|
1825 |
if(failures)
|
|
1826 |
return KErrGeneral;
|
|
1827 |
return KErrNone;
|
|
1828 |
|
|
1829 |
|
|
1830 |
}
|
|
1831 |
|
|
1832 |
|
|
1833 |
|
|
1834 |
|
|
1835 |
// -----------------------------------------------------------------------------
|
|
1836 |
// Ctstl_4::ToUpper
|
|
1837 |
// -----------------------------------------------------------------------------
|
|
1838 |
//
|
|
1839 |
TInt Ctstl_4::ToUpper( CStifItemParser& aItem )
|
|
1840 |
{
|
|
1841 |
|
|
1842 |
int failures=0 ;
|
|
1843 |
|
|
1844 |
//__UHEAP_MARK;
|
|
1845 |
|
|
1846 |
|
|
1847 |
try
|
|
1848 |
{
|
|
1849 |
//testcase starts
|
|
1850 |
char lower_char ;
|
|
1851 |
|
|
1852 |
|
|
1853 |
for(lower_char='a';lower_char<='z';lower_char++)
|
|
1854 |
|
|
1855 |
{
|
|
1856 |
|
|
1857 |
#if STDCPP_OOM
|
|
1858 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
1859 |
#endif
|
|
1860 |
|
|
1861 |
char upper_char = toupper(lower_char);
|
|
1862 |
|
|
1863 |
#if STDCPP_OOM
|
|
1864 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
1865 |
#endif
|
|
1866 |
|
|
1867 |
|
|
1868 |
if ((lower_char - 32) != upper_char )
|
|
1869 |
|
|
1870 |
failures++;
|
|
1871 |
}
|
|
1872 |
|
|
1873 |
|
|
1874 |
|
|
1875 |
for(char lower_char=0x00;lower_char<=0x60;lower_char++)
|
|
1876 |
{
|
|
1877 |
#if STDCPP_OOM
|
|
1878 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
1879 |
#endif
|
|
1880 |
char upper_char = toupper(lower_char);
|
|
1881 |
#if STDCPP_OOM
|
|
1882 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
1883 |
|
|
1884 |
#endif
|
|
1885 |
|
|
1886 |
if(lower_char!=upper_char)
|
|
1887 |
failures++;
|
|
1888 |
|
|
1889 |
}
|
|
1890 |
|
|
1891 |
for(char lower_char=0x7B;lower_char<=0x7E;lower_char++)
|
|
1892 |
{
|
|
1893 |
#if STDCPP_OOM
|
|
1894 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
1895 |
#endif
|
|
1896 |
char upper_char = toupper(lower_char);
|
|
1897 |
#if STDCPP_OOM
|
|
1898 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
1899 |
|
|
1900 |
#endif
|
|
1901 |
|
|
1902 |
if(lower_char!=upper_char)
|
|
1903 |
failures++;
|
|
1904 |
|
|
1905 |
|
|
1906 |
|
|
1907 |
}
|
|
1908 |
|
|
1909 |
|
|
1910 |
//testcase ends
|
|
1911 |
|
|
1912 |
|
|
1913 |
//#if STDCPP_OOM
|
|
1914 |
//failures++;
|
|
1915 |
//#endif
|
|
1916 |
|
|
1917 |
}
|
|
1918 |
|
|
1919 |
//catching bad alloc exception
|
|
1920 |
catch(bad_alloc&)
|
|
1921 |
{
|
|
1922 |
//do nothing
|
|
1923 |
}
|
|
1924 |
|
|
1925 |
//catching any other exception
|
|
1926 |
|
|
1927 |
catch(...)
|
|
1928 |
{
|
|
1929 |
failures++;
|
|
1930 |
|
|
1931 |
}
|
|
1932 |
|
|
1933 |
|
|
1934 |
|
|
1935 |
|
|
1936 |
//__UHEAP_MARKEND;
|
|
1937 |
if(failures)
|
|
1938 |
return KErrGeneral;
|
|
1939 |
return KErrNone;
|
|
1940 |
|
|
1941 |
|
|
1942 |
}
|
|
1943 |
|
|
1944 |
// -----------------------------------------------------------------------------
|
|
1945 |
// Ctstl_4::ToLower
|
|
1946 |
// -----------------------------------------------------------------------------
|
|
1947 |
//
|
|
1948 |
|
|
1949 |
|
|
1950 |
|
|
1951 |
|
|
1952 |
TInt Ctstl_4::ToLower( CStifItemParser& aItem )
|
|
1953 |
{
|
|
1954 |
|
|
1955 |
//__UHEAP_MARK;
|
|
1956 |
char upper_char ;
|
|
1957 |
int failures = 0;
|
|
1958 |
|
|
1959 |
|
|
1960 |
try
|
|
1961 |
{
|
|
1962 |
#if STDCPP_OOM
|
|
1963 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
1964 |
|
|
1965 |
#endif
|
|
1966 |
for(upper_char='A';upper_char<='Z';upper_char++)
|
|
1967 |
{
|
|
1968 |
|
|
1969 |
|
|
1970 |
char lower_char = tolower(upper_char);
|
|
1971 |
|
|
1972 |
if (lower_char != (upper_char + 32 ))
|
|
1973 |
|
|
1974 |
failures++;
|
|
1975 |
}
|
|
1976 |
|
|
1977 |
|
|
1978 |
for(char upper_char=0x00;upper_char<=0x40;upper_char++)
|
|
1979 |
{
|
|
1980 |
|
|
1981 |
char lower_char = tolower(upper_char);
|
|
1982 |
if(lower_char!=upper_char)
|
|
1983 |
failures++;
|
|
1984 |
|
|
1985 |
}
|
|
1986 |
for(char upper_char=0x5B;upper_char<=0x7E;upper_char++)
|
|
1987 |
{
|
|
1988 |
|
|
1989 |
char lower_char = tolower(upper_char);
|
|
1990 |
if(lower_char!=upper_char)
|
|
1991 |
failures++;
|
|
1992 |
|
|
1993 |
|
|
1994 |
|
|
1995 |
}
|
|
1996 |
|
|
1997 |
#if STDCPP_OOM
|
|
1998 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
1999 |
|
|
2000 |
#endif
|
|
2001 |
|
|
2002 |
//#if STDCPP_OOM
|
|
2003 |
//failures++;
|
|
2004 |
//#endif
|
|
2005 |
|
|
2006 |
}
|
|
2007 |
|
|
2008 |
catch(bad_alloc&)
|
|
2009 |
{
|
|
2010 |
//do nothing
|
|
2011 |
}
|
|
2012 |
|
|
2013 |
catch(...)
|
|
2014 |
{
|
|
2015 |
failures++;
|
|
2016 |
|
|
2017 |
}
|
|
2018 |
|
|
2019 |
// __UHEAP_MARKEND;
|
|
2020 |
if(failures)
|
|
2021 |
return KErrGeneral;
|
|
2022 |
return KErrNone;
|
|
2023 |
|
|
2024 |
}
|
|
2025 |
|
|
2026 |
|
|
2027 |
// -----------------------------------------------------------------------------
|
|
2028 |
// Ctstl_4::Islower
|
|
2029 |
// -----------------------------------------------------------------------------
|
|
2030 |
//
|
|
2031 |
|
|
2032 |
TInt Ctstl_4::Islower( CStifItemParser& aItem )
|
|
2033 |
{
|
|
2034 |
|
|
2035 |
// __UHEAP_MARK;
|
|
2036 |
|
|
2037 |
char lower_char;
|
|
2038 |
int failures =0;
|
|
2039 |
|
|
2040 |
|
|
2041 |
try
|
|
2042 |
{
|
|
2043 |
#if STDCPP_OOM
|
|
2044 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
2045 |
|
|
2046 |
#endif
|
|
2047 |
for(lower_char = 'a' ;lower_char<='z';lower_char++)
|
|
2048 |
{
|
|
2049 |
|
|
2050 |
if(!islower(lower_char))
|
|
2051 |
failures++;
|
|
2052 |
|
|
2053 |
}
|
|
2054 |
|
|
2055 |
#if STDCPP_OOM
|
|
2056 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
2057 |
|
|
2058 |
|
|
2059 |
#endif
|
|
2060 |
//#if STDCPP_OOM
|
|
2061 |
//failures++;
|
|
2062 |
//#endif
|
|
2063 |
|
|
2064 |
}
|
|
2065 |
catch(bad_alloc&)
|
|
2066 |
{
|
|
2067 |
|
|
2068 |
}
|
|
2069 |
catch(...)
|
|
2070 |
{
|
|
2071 |
failures++;
|
|
2072 |
|
|
2073 |
}
|
|
2074 |
|
|
2075 |
// __UHEAP_MARKEND;
|
|
2076 |
|
|
2077 |
if(failures)
|
|
2078 |
return KErrGeneral;
|
|
2079 |
return KErrNone;
|
|
2080 |
}
|
|
2081 |
|
|
2082 |
// -----------------------------------------------------------------------------
|
|
2083 |
// Ctstl_4::Isupper
|
|
2084 |
// -----------------------------------------------------------------------------
|
|
2085 |
//
|
|
2086 |
|
|
2087 |
|
|
2088 |
TInt Ctstl_4::Isupper( CStifItemParser& aItem )
|
|
2089 |
{
|
|
2090 |
|
|
2091 |
//__UHEAP_MARK;
|
|
2092 |
|
|
2093 |
char upper_char;
|
|
2094 |
|
|
2095 |
int failures =0;
|
|
2096 |
|
|
2097 |
|
|
2098 |
try
|
|
2099 |
{
|
|
2100 |
|
|
2101 |
for(upper_char = 'A' ;upper_char<='Z';upper_char++)
|
|
2102 |
{
|
|
2103 |
|
|
2104 |
#if STDCPP_OOM
|
|
2105 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
2106 |
|
|
2107 |
#endif
|
|
2108 |
if(!isupper(upper_char))
|
|
2109 |
failures++;
|
|
2110 |
|
|
2111 |
#if STDCPP_OOM
|
|
2112 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
2113 |
|
|
2114 |
|
|
2115 |
#endif
|
|
2116 |
}
|
|
2117 |
|
|
2118 |
//#if STDCPP_OOM
|
|
2119 |
//failures++;
|
|
2120 |
//#endif
|
|
2121 |
}
|
|
2122 |
catch(bad_alloc&)
|
|
2123 |
{
|
|
2124 |
|
|
2125 |
}
|
|
2126 |
catch(...)
|
|
2127 |
{
|
|
2128 |
failures++;
|
|
2129 |
|
|
2130 |
}
|
|
2131 |
|
|
2132 |
|
|
2133 |
if(failures)
|
|
2134 |
return KErrGeneral;
|
|
2135 |
return KErrNone;
|
|
2136 |
}
|
|
2137 |
|
|
2138 |
|
|
2139 |
// Ctstl_4::Maxof
|
|
2140 |
|
|
2141 |
|
|
2142 |
TInt Ctstl_4::Maxof( CStifItemParser& aItem )
|
|
2143 |
{
|
|
2144 |
int failures =0;
|
|
2145 |
|
|
2146 |
|
|
2147 |
try
|
|
2148 |
{
|
|
2149 |
int result_int1;
|
|
2150 |
int result_int2;
|
|
2151 |
char result_char;
|
|
2152 |
// float result_float;
|
|
2153 |
#if STDCPP_OOM
|
|
2154 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
2155 |
|
|
2156 |
#endif
|
|
2157 |
result_int1 = max(2,1);
|
|
2158 |
result_int2 = max(-2,-25);
|
|
2159 |
result_char = max('a','z');
|
|
2160 |
#if STDCPP_OOM
|
|
2161 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
2162 |
|
|
2163 |
|
|
2164 |
#endif
|
|
2165 |
|
|
2166 |
/*
|
|
2167 |
if (result_int1 == 2)
|
|
2168 |
if(result_int2 == -2)
|
|
2169 |
if (result_char == 'z')
|
|
2170 |
if(max(2.23,2.24) == 2.24)
|
|
2171 |
// __UHEAP_MARKEND;
|
|
2172 |
return KErrNone;
|
|
2173 |
return KErrGeneral;*/
|
|
2174 |
if (result_int1 != 2)
|
|
2175 |
failures++;
|
|
2176 |
if(result_int2 != -2)
|
|
2177 |
failures++;
|
|
2178 |
if (result_char != 'z')
|
|
2179 |
failures++;
|
|
2180 |
if(max(2.23,2.24) != 2.24)
|
|
2181 |
failures++;
|
|
2182 |
|
|
2183 |
//#if STDCPP_OOM //failures++; //#endif
|
|
2184 |
|
|
2185 |
|
|
2186 |
}
|
|
2187 |
catch(bad_alloc&)
|
|
2188 |
{
|
|
2189 |
//do nothing
|
|
2190 |
}
|
|
2191 |
catch(...)
|
|
2192 |
{
|
|
2193 |
failures++;
|
|
2194 |
|
|
2195 |
}
|
|
2196 |
|
|
2197 |
|
|
2198 |
if(failures)
|
|
2199 |
return KErrGeneral;
|
|
2200 |
return KErrNone;
|
|
2201 |
|
|
2202 |
|
|
2203 |
}
|
|
2204 |
|
|
2205 |
|
|
2206 |
// -----------------------------------------------------------------------------
|
|
2207 |
// Ctstl_4::ExampleL
|
|
2208 |
// Example test method function.
|
|
2209 |
// (other items were commented in a header).
|
|
2210 |
// -----------------------------------------------------------------------------
|
|
2211 |
//
|
|
2212 |
TInt Ctstl_4::Advance( CStifItemParser& aItem )
|
|
2213 |
{
|
|
2214 |
|
|
2215 |
|
|
2216 |
int failures=0 ;
|
|
2217 |
|
|
2218 |
|
|
2219 |
|
|
2220 |
|
|
2221 |
try
|
|
2222 |
{
|
|
2223 |
|
|
2224 |
list<string>::iterator iList1,iList2;
|
|
2225 |
list<string> List;
|
|
2226 |
List.push_back("A1");
|
|
2227 |
List.push_back("B2");
|
|
2228 |
List.push_back("C3");
|
|
2229 |
List.push_back("D4");
|
|
2230 |
List.push_back("E5");
|
|
2231 |
List.push_back("F6");
|
|
2232 |
List.push_back("G7");
|
|
2233 |
// cout<<"";
|
|
2234 |
#if STDCPP_OOM
|
|
2235 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
2236 |
#endif
|
|
2237 |
|
|
2238 |
iList1=List.begin();
|
|
2239 |
advance(iList1,2);
|
|
2240 |
iList2 = List.begin();
|
|
2241 |
advance(iList2,0);
|
|
2242 |
#if STDCPP_OOM
|
|
2243 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
2244 |
|
|
2245 |
|
|
2246 |
#endif
|
|
2247 |
if(*iList1 != "C3")
|
|
2248 |
failures++;
|
|
2249 |
|
|
2250 |
if(*iList2 != "A1")
|
|
2251 |
failures++;
|
|
2252 |
|
|
2253 |
//#if STDCPP_OOM
|
|
2254 |
//failures++;
|
|
2255 |
// #endif
|
|
2256 |
/*
|
|
2257 |
if(*iList1 == "C3")
|
|
2258 |
if(*iList2 == "A1")
|
|
2259 |
return KErrNone;
|
|
2260 |
return KErrGeneral;
|
|
2261 |
*/
|
|
2262 |
}
|
|
2263 |
catch(bad_alloc&)
|
|
2264 |
{
|
|
2265 |
//do nothing
|
|
2266 |
}
|
|
2267 |
catch(...)
|
|
2268 |
{
|
|
2269 |
failures++;
|
|
2270 |
|
|
2271 |
}
|
|
2272 |
|
|
2273 |
if(failures )
|
|
2274 |
return KErrGeneral;
|
|
2275 |
return KErrNone;
|
|
2276 |
}
|
|
2277 |
|
|
2278 |
|
|
2279 |
|
|
2280 |
|
|
2281 |
|
|
2282 |
TInt Ctstl_4::Backinsert_iterator( CStifItemParser& aItem )
|
|
2283 |
{
|
|
2284 |
int failures=0;
|
|
2285 |
try
|
|
2286 |
{
|
|
2287 |
|
|
2288 |
|
|
2289 |
|
|
2290 |
int i;
|
|
2291 |
int output[4];
|
|
2292 |
vector<int> vec;
|
|
2293 |
for (i = 1 ; i < 4 ; ++i )
|
|
2294 |
{
|
|
2295 |
vec.push_back ( i );
|
|
2296 |
}
|
|
2297 |
|
|
2298 |
|
|
2299 |
vector <int>::iterator vIter;
|
|
2300 |
|
|
2301 |
|
|
2302 |
|
|
2303 |
back_insert_iterator<vector<int> >::container_type vec1 = vec;
|
|
2304 |
// cout<<"";
|
|
2305 |
#if STDCPP_OOM
|
|
2306 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
2307 |
#endif
|
|
2308 |
back_inserter ( vec1 ) = 40;
|
|
2309 |
|
|
2310 |
#if STDCPP_OOM
|
|
2311 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
2312 |
|
|
2313 |
|
|
2314 |
#endif
|
|
2315 |
for ( vIter = vec1.begin ( ) ; vIter != vec1.end ( ); vIter++)
|
|
2316 |
|
|
2317 |
|
|
2318 |
{
|
|
2319 |
|
|
2320 |
static int i;
|
|
2321 |
output[i] = *vIter;
|
|
2322 |
i++;
|
|
2323 |
|
|
2324 |
}
|
|
2325 |
|
|
2326 |
|
|
2327 |
if(output[0] != 1)
|
|
2328 |
failures++;
|
|
2329 |
if(output[1] != 2)
|
|
2330 |
failures++;
|
|
2331 |
if(output[2] != 3)
|
|
2332 |
failures++;
|
|
2333 |
if(output[3] != 40)
|
|
2334 |
failures++;
|
|
2335 |
|
|
2336 |
/*
|
|
2337 |
if(output[0] == 1)
|
|
2338 |
if(output[1] == 2)
|
|
2339 |
if(output[2] == 3)
|
|
2340 |
if(output[3] == 40)
|
|
2341 |
return KErrNone;
|
|
2342 |
return KErrGeneral;
|
|
2343 |
*/
|
|
2344 |
//#if STDCPP_OOM
|
|
2345 |
//failures++;
|
|
2346 |
// #endif
|
|
2347 |
}
|
|
2348 |
catch(bad_alloc&)
|
|
2349 |
{
|
|
2350 |
//do nothing
|
|
2351 |
}
|
|
2352 |
catch(...)
|
|
2353 |
{
|
|
2354 |
failures++;
|
|
2355 |
|
|
2356 |
}
|
|
2357 |
|
|
2358 |
if(failures )
|
|
2359 |
return KErrGeneral;
|
|
2360 |
return KErrNone;
|
|
2361 |
}
|
|
2362 |
|
|
2363 |
|
|
2364 |
|
|
2365 |
TInt Ctstl_4::Frontinsert_iterator( CStifItemParser& aItem )
|
|
2366 |
{
|
|
2367 |
int failures=0;
|
|
2368 |
try{
|
|
2369 |
int i;
|
|
2370 |
list <int>::iterator L_Iter;
|
|
2371 |
int output[12];
|
|
2372 |
list<int> L;
|
|
2373 |
for (i = -1 ; i < 9 ; ++i )
|
|
2374 |
{
|
|
2375 |
L.push_back ( 2 * i );
|
|
2376 |
}
|
|
2377 |
// cout<<"";
|
|
2378 |
#if STDCPP_OOM
|
|
2379 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
2380 |
#endif
|
|
2381 |
|
|
2382 |
// Using the member function to insert an element
|
|
2383 |
front_inserter ( L ) = 20;
|
|
2384 |
|
|
2385 |
// Alternatively, one may use the template function
|
|
2386 |
front_insert_iterator< list < int> > Iter(L);
|
|
2387 |
#if STDCPP_OOM
|
|
2388 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
2389 |
#endif
|
|
2390 |
*Iter = 30;
|
|
2391 |
|
|
2392 |
for ( L_Iter = L.begin( ) ; L_Iter != L.end( ); L_Iter++)
|
|
2393 |
|
|
2394 |
|
|
2395 |
{
|
|
2396 |
static int i;
|
|
2397 |
output[i] = *L_Iter;
|
|
2398 |
i++;
|
|
2399 |
}
|
|
2400 |
if(output[0] != 30)
|
|
2401 |
failures++;
|
|
2402 |
if(output[1] != 20)
|
|
2403 |
failures++;
|
|
2404 |
if(output[2] != -2)
|
|
2405 |
failures++;
|
|
2406 |
if(output[3] != 0)
|
|
2407 |
failures++;
|
|
2408 |
|
|
2409 |
//#if STDCPP_OOM
|
|
2410 |
//failures++;
|
|
2411 |
// #endif
|
|
2412 |
|
|
2413 |
/*
|
|
2414 |
if(output[0] == 30)
|
|
2415 |
if(output[1] == 20)
|
|
2416 |
if(output[2] == -2)
|
|
2417 |
if(output[3] == 0)
|
|
2418 |
return KErrNone;
|
|
2419 |
return KErrGeneral;*/
|
|
2420 |
|
|
2421 |
|
|
2422 |
|
|
2423 |
}
|
|
2424 |
|
|
2425 |
|
|
2426 |
catch(bad_alloc&)
|
|
2427 |
{
|
|
2428 |
//do nothing
|
|
2429 |
}
|
|
2430 |
catch(...)
|
|
2431 |
{
|
|
2432 |
failures++;
|
|
2433 |
|
|
2434 |
}
|
|
2435 |
|
|
2436 |
if(failures )
|
|
2437 |
return KErrGeneral;
|
|
2438 |
return KErrNone;
|
|
2439 |
}
|
|
2440 |
|
|
2441 |
|
|
2442 |
|
|
2443 |
|
|
2444 |
TInt Ctstl_4::Insert_iterator( CStifItemParser& aItem )
|
|
2445 |
{
|
|
2446 |
int failures=0;
|
|
2447 |
try{
|
|
2448 |
int i;
|
|
2449 |
list <int>::iterator L_Iter;
|
|
2450 |
int output[5];
|
|
2451 |
list<int> L;
|
|
2452 |
for (i = 2 ; i < 5 ; ++i )
|
|
2453 |
{
|
|
2454 |
L.push_back ( 10 * i );
|
|
2455 |
}
|
|
2456 |
// cout<<"";
|
|
2457 |
#if STDCPP_OOM
|
|
2458 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
2459 |
#endif
|
|
2460 |
|
|
2461 |
// Using the template version to insert an element
|
|
2462 |
insert_iterator<list <int> > Iter( L, L.begin ( ) );
|
|
2463 |
*Iter = 1;
|
|
2464 |
|
|
2465 |
// Alternatively, using the member function to insert an element
|
|
2466 |
inserter ( L, L.end ( ) ) = 500;
|
|
2467 |
#if STDCPP_OOM
|
|
2468 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
2469 |
#endif
|
|
2470 |
for ( L_Iter = L.begin( ) ; L_Iter != L.end( ); L_Iter++)
|
|
2471 |
|
|
2472 |
{
|
|
2473 |
static int i;
|
|
2474 |
output[i] = *L_Iter;
|
|
2475 |
i++;
|
|
2476 |
}
|
|
2477 |
|
|
2478 |
if(output[0] != 1)
|
|
2479 |
failures++;
|
|
2480 |
if(output[4] != 500)
|
|
2481 |
failures++;
|
|
2482 |
/*
|
|
2483 |
if(output[0] == 1)
|
|
2484 |
if(output[4] == 500)
|
|
2485 |
|
|
2486 |
return KErrNone;
|
|
2487 |
return KErrGeneral;
|
|
2488 |
*/
|
|
2489 |
//#if STDCPP_OOM
|
|
2490 |
//failures++;
|
|
2491 |
// #endif
|
|
2492 |
|
|
2493 |
}
|
|
2494 |
|
|
2495 |
|
|
2496 |
catch(bad_alloc&)
|
|
2497 |
{
|
|
2498 |
//do nothing
|
|
2499 |
}
|
|
2500 |
catch(...)
|
|
2501 |
{
|
|
2502 |
failures++;
|
|
2503 |
|
|
2504 |
}
|
|
2505 |
|
|
2506 |
if(failures )
|
|
2507 |
return KErrGeneral;
|
|
2508 |
return KErrNone;
|
|
2509 |
}
|
|
2510 |
|
|
2511 |
TInt Ctstl_4::Reverse_iterator( CStifItemParser& aItem )
|
|
2512 |
|
|
2513 |
{
|
|
2514 |
int failures=0;
|
|
2515 |
try{
|
|
2516 |
int i;
|
|
2517 |
|
|
2518 |
|
|
2519 |
vector<int> vec;
|
|
2520 |
|
|
2521 |
for ( i = 1 ; i < 6 ; ++i )
|
|
2522 |
{
|
|
2523 |
vec.push_back ( i );
|
|
2524 |
}
|
|
2525 |
|
|
2526 |
// vector <int>::iterator vIter;
|
|
2527 |
|
|
2528 |
|
|
2529 |
// vector <int>::reverse_iterator rvIter;
|
|
2530 |
|
|
2531 |
vector <int>::iterator pos;
|
|
2532 |
|
|
2533 |
pos = find ( vec.begin ( ), vec.end ( ), 4 );
|
|
2534 |
|
|
2535 |
|
|
2536 |
if(*pos != 4)
|
|
2537 |
failures++;
|
|
2538 |
// cout<<"";
|
|
2539 |
#if STDCPP_OOM
|
|
2540 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
2541 |
#endif
|
|
2542 |
vector <int>::reverse_iterator rpos ( pos );
|
|
2543 |
#if STDCPP_OOM
|
|
2544 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
2545 |
#endif
|
|
2546 |
if(*rpos != 3)
|
|
2547 |
failures++;
|
|
2548 |
|
|
2549 |
|
|
2550 |
//#if STDCPP_OOM
|
|
2551 |
//failures++;
|
|
2552 |
// #endif
|
|
2553 |
|
|
2554 |
|
|
2555 |
}
|
|
2556 |
|
|
2557 |
|
|
2558 |
|
|
2559 |
catch(bad_alloc&)
|
|
2560 |
{
|
|
2561 |
//do nothing
|
|
2562 |
}
|
|
2563 |
catch(...)
|
|
2564 |
{
|
|
2565 |
failures++;
|
|
2566 |
|
|
2567 |
}
|
|
2568 |
|
|
2569 |
if(failures )
|
|
2570 |
return KErrGeneral;
|
|
2571 |
return KErrNone;
|
|
2572 |
}
|
|
2573 |
|
|
2574 |
TInt Ctstl_4::Distance( CStifItemParser& aItem )
|
|
2575 |
|
|
2576 |
{
|
|
2577 |
int failures =0;
|
|
2578 |
try{
|
|
2579 |
int i;
|
|
2580 |
|
|
2581 |
|
|
2582 |
list<int> L;
|
|
2583 |
for ( i = -1 ; i < 9 ; ++i )
|
|
2584 |
{
|
|
2585 |
L.push_back ( 2 * i );
|
|
2586 |
}
|
|
2587 |
|
|
2588 |
|
|
2589 |
list <int>::iterator LPOS = L.begin ( );
|
|
2590 |
|
|
2591 |
|
|
2592 |
|
|
2593 |
|
|
2594 |
advance ( LPOS , 7 );
|
|
2595 |
|
|
2596 |
list<int>::difference_type Ldiff ;
|
|
2597 |
// cout<<"";
|
|
2598 |
#if STDCPP_OOM
|
|
2599 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
2600 |
#endif
|
|
2601 |
Ldiff = distance ( L.begin ( ) , LPOS );
|
|
2602 |
|
|
2603 |
#if STDCPP_OOM
|
|
2604 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
2605 |
#endif
|
|
2606 |
/*if(*LPOS ==12)
|
|
2607 |
if(Ldiff==7)
|
|
2608 |
return KErrNone;
|
|
2609 |
return KErrGeneral;*/
|
|
2610 |
|
|
2611 |
if(*LPOS !=12)
|
|
2612 |
failures++;
|
|
2613 |
if(Ldiff!=7)
|
|
2614 |
failures++;
|
|
2615 |
//#if STDCPP_OOM
|
|
2616 |
//failures++;
|
|
2617 |
// #endif
|
|
2618 |
|
|
2619 |
}
|
|
2620 |
catch(bad_alloc&)
|
|
2621 |
{
|
|
2622 |
//do nothing
|
|
2623 |
}
|
|
2624 |
catch(...)
|
|
2625 |
{
|
|
2626 |
failures++;
|
|
2627 |
|
|
2628 |
}
|
|
2629 |
|
|
2630 |
if(failures )
|
|
2631 |
return KErrGeneral;
|
|
2632 |
return KErrNone;
|
|
2633 |
}
|
|
2634 |
|
|
2635 |
|
|
2636 |
|
|
2637 |
|
|
2638 |
|
|
2639 |
|
|
2640 |
|
|
2641 |
//#if STDCPP_OOM
|
|
2642 |
//failures++;
|
|
2643 |
// #endif
|
|
2644 |
|
|
2645 |
|
|
2646 |
|
|
2647 |
|
|
2648 |
TInt Ctstl_4::Isdigit( CStifItemParser& aItem )
|
|
2649 |
|
|
2650 |
{
|
|
2651 |
|
|
2652 |
char str[]="1776ad";
|
|
2653 |
|
|
2654 |
int failures =0;
|
|
2655 |
try{
|
|
2656 |
// cout<<"";
|
|
2657 |
#if STDCPP_OOM
|
|
2658 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
2659 |
#endif
|
|
2660 |
if (!isdigit(str[0]))
|
|
2661 |
failures++;
|
|
2662 |
if (!isdigit(str[1]))
|
|
2663 |
failures++;
|
|
2664 |
if (!isdigit(str[2]))
|
|
2665 |
failures++;
|
|
2666 |
if (!isdigit(str[3]))
|
|
2667 |
failures++;
|
|
2668 |
if (isdigit(str[4]))
|
|
2669 |
failures++;
|
|
2670 |
if (isdigit(str[5]))
|
|
2671 |
failures++;
|
|
2672 |
#if STDCPP_OOM
|
|
2673 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
2674 |
#endif
|
|
2675 |
//#if STDCPP_OOM
|
|
2676 |
//failures++;
|
|
2677 |
// #endif
|
|
2678 |
|
|
2679 |
|
|
2680 |
|
|
2681 |
|
|
2682 |
|
|
2683 |
}
|
|
2684 |
catch(bad_alloc&)
|
|
2685 |
{
|
|
2686 |
//do nothing
|
|
2687 |
}
|
|
2688 |
catch(...)
|
|
2689 |
{
|
|
2690 |
failures++;
|
|
2691 |
|
|
2692 |
}
|
|
2693 |
|
|
2694 |
if(failures )
|
|
2695 |
return KErrGeneral;
|
|
2696 |
return KErrNone;
|
|
2697 |
}
|
|
2698 |
|
|
2699 |
|
|
2700 |
TInt Ctstl_4::Isgraph( CStifItemParser& aItem )
|
|
2701 |
|
|
2702 |
{
|
|
2703 |
|
|
2704 |
int failures =0;
|
|
2705 |
// char array[42] = "!"#$%&'()*+,-./0123456789:;<=>?@[\]^_`{|}~";
|
|
2706 |
|
|
2707 |
|
|
2708 |
try{
|
|
2709 |
|
|
2710 |
for(char i=0x21;i<=0x7E;i++)
|
|
2711 |
{
|
|
2712 |
// cout<<"";
|
|
2713 |
#if STDCPP_OOM
|
|
2714 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
2715 |
#endif
|
|
2716 |
|
|
2717 |
if(!isgraph(i))
|
|
2718 |
|
|
2719 |
failures++;
|
|
2720 |
#if STDCPP_OOM
|
|
2721 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
2722 |
#endif
|
|
2723 |
|
|
2724 |
|
|
2725 |
}
|
|
2726 |
|
|
2727 |
|
|
2728 |
|
|
2729 |
|
|
2730 |
|
|
2731 |
//#if STDCPP_OOM
|
|
2732 |
//failures++;
|
|
2733 |
// #endif
|
|
2734 |
|
|
2735 |
|
|
2736 |
|
|
2737 |
}
|
|
2738 |
|
|
2739 |
catch(bad_alloc&)
|
|
2740 |
{
|
|
2741 |
//do nothing
|
|
2742 |
}
|
|
2743 |
catch(...)
|
|
2744 |
{
|
|
2745 |
failures++;
|
|
2746 |
|
|
2747 |
}
|
|
2748 |
|
|
2749 |
if(failures )
|
|
2750 |
return KErrGeneral;
|
|
2751 |
return KErrNone;
|
|
2752 |
}
|
|
2753 |
|
|
2754 |
|
|
2755 |
|
|
2756 |
TInt Ctstl_4::Isalnum( CStifItemParser& aItem )
|
|
2757 |
|
|
2758 |
{
|
|
2759 |
|
|
2760 |
int failures =0;
|
|
2761 |
|
|
2762 |
|
|
2763 |
try{
|
|
2764 |
|
|
2765 |
for(char text='a';text<='z';text++)
|
|
2766 |
{
|
|
2767 |
|
|
2768 |
#if STDCPP_OOM
|
|
2769 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
2770 |
#endif
|
|
2771 |
if(!isalnum(text))
|
|
2772 |
failures++;
|
|
2773 |
#if STDCPP_OOM
|
|
2774 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
2775 |
#endif
|
|
2776 |
|
|
2777 |
|
|
2778 |
|
|
2779 |
}
|
|
2780 |
|
|
2781 |
|
|
2782 |
for(char text='A';text<='Z';text++)
|
|
2783 |
{
|
|
2784 |
|
|
2785 |
#if STDCPP_OOM
|
|
2786 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
2787 |
#endif
|
|
2788 |
if(!isalnum(text))
|
|
2789 |
failures++;
|
|
2790 |
#if STDCPP_OOM
|
|
2791 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
2792 |
#endif
|
|
2793 |
|
|
2794 |
|
|
2795 |
|
|
2796 |
}
|
|
2797 |
|
|
2798 |
|
|
2799 |
|
|
2800 |
for(int text='0';text<='9';text++)
|
|
2801 |
{
|
|
2802 |
|
|
2803 |
|
|
2804 |
if(!isalnum(text))
|
|
2805 |
failures++;
|
|
2806 |
|
|
2807 |
|
|
2808 |
}
|
|
2809 |
|
|
2810 |
//#if STDCPP_OOM
|
|
2811 |
//failures++;
|
|
2812 |
// #endif
|
|
2813 |
|
|
2814 |
|
|
2815 |
|
|
2816 |
}
|
|
2817 |
|
|
2818 |
|
|
2819 |
|
|
2820 |
catch(bad_alloc&)
|
|
2821 |
{
|
|
2822 |
//do nothing
|
|
2823 |
}
|
|
2824 |
catch(...)
|
|
2825 |
{
|
|
2826 |
failures++;
|
|
2827 |
|
|
2828 |
}
|
|
2829 |
|
|
2830 |
if(failures )
|
|
2831 |
return KErrGeneral;
|
|
2832 |
return KErrNone;
|
|
2833 |
}
|
|
2834 |
TInt Ctstl_4::Isalpha( CStifItemParser& aItem )
|
|
2835 |
|
|
2836 |
{
|
|
2837 |
|
|
2838 |
int failures =0;
|
|
2839 |
|
|
2840 |
try{
|
|
2841 |
|
|
2842 |
|
|
2843 |
for(char text='a';text<='z';text++)
|
|
2844 |
{
|
|
2845 |
|
|
2846 |
#if STDCPP_OOM
|
|
2847 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
2848 |
#endif
|
|
2849 |
if(!isalpha(text))
|
|
2850 |
failures++;
|
|
2851 |
#if STDCPP_OOM
|
|
2852 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
2853 |
#endif
|
|
2854 |
|
|
2855 |
|
|
2856 |
|
|
2857 |
}
|
|
2858 |
|
|
2859 |
|
|
2860 |
for(char text='A';text<='Z';text++)
|
|
2861 |
{
|
|
2862 |
|
|
2863 |
|
|
2864 |
if(!isalpha(text))
|
|
2865 |
failures++;
|
|
2866 |
|
|
2867 |
|
|
2868 |
}
|
|
2869 |
|
|
2870 |
|
|
2871 |
|
|
2872 |
for(int text='0';text<='9';text++)
|
|
2873 |
{
|
|
2874 |
|
|
2875 |
|
|
2876 |
if(isalpha(text))
|
|
2877 |
failures++;
|
|
2878 |
|
|
2879 |
|
|
2880 |
}
|
|
2881 |
|
|
2882 |
//#if STDCPP_OOM
|
|
2883 |
//failures++;
|
|
2884 |
// #endif
|
|
2885 |
|
|
2886 |
|
|
2887 |
}
|
|
2888 |
catch(bad_alloc&)
|
|
2889 |
{
|
|
2890 |
//do nothing
|
|
2891 |
}
|
|
2892 |
catch(...)
|
|
2893 |
{
|
|
2894 |
failures++;
|
|
2895 |
|
|
2896 |
}
|
|
2897 |
|
|
2898 |
if(failures )
|
|
2899 |
return KErrGeneral;
|
|
2900 |
return KErrNone;
|
|
2901 |
}
|
|
2902 |
|
|
2903 |
|
|
2904 |
|
|
2905 |
TInt Ctstl_4::Iscntrl( CStifItemParser& aItem )
|
|
2906 |
|
|
2907 |
{
|
|
2908 |
int failures =0;
|
|
2909 |
|
|
2910 |
try{
|
|
2911 |
|
|
2912 |
|
|
2913 |
|
|
2914 |
|
|
2915 |
for(char text=0x00;text<=0x1F;text++)
|
|
2916 |
{
|
|
2917 |
|
|
2918 |
#if STDCPP_OOM
|
|
2919 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
2920 |
#endif
|
|
2921 |
if(!iscntrl(text))
|
|
2922 |
failures++;
|
|
2923 |
#if STDCPP_OOM
|
|
2924 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
2925 |
#endif
|
|
2926 |
|
|
2927 |
|
|
2928 |
}
|
|
2929 |
|
|
2930 |
if(!iscntrl(0x7F))
|
|
2931 |
failures++;
|
|
2932 |
/*
|
|
2933 |
if(failures)
|
|
2934 |
return KErrGeneral;
|
|
2935 |
return KErrNone;
|
|
2936 |
*/
|
|
2937 |
//#if STDCPP_OOM
|
|
2938 |
//failures++;
|
|
2939 |
// #endif
|
|
2940 |
|
|
2941 |
|
|
2942 |
}
|
|
2943 |
|
|
2944 |
catch(bad_alloc&)
|
|
2945 |
{
|
|
2946 |
//do nothing
|
|
2947 |
}
|
|
2948 |
catch(...)
|
|
2949 |
{
|
|
2950 |
failures++;
|
|
2951 |
|
|
2952 |
}
|
|
2953 |
|
|
2954 |
if(failures )
|
|
2955 |
return KErrGeneral;
|
|
2956 |
return KErrNone;
|
|
2957 |
}
|
|
2958 |
|
|
2959 |
|
|
2960 |
TInt Ctstl_4::Isprint( CStifItemParser& aItem )
|
|
2961 |
|
|
2962 |
{
|
|
2963 |
|
|
2964 |
int failures =0;
|
|
2965 |
|
|
2966 |
try{
|
|
2967 |
|
|
2968 |
|
|
2969 |
for(char text=0x20;text<=0x7E;text++)
|
|
2970 |
{
|
|
2971 |
|
|
2972 |
#if STDCPP_OOM
|
|
2973 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
2974 |
#endif
|
|
2975 |
if(!isprint(text))
|
|
2976 |
failures++;
|
|
2977 |
#if STDCPP_OOM
|
|
2978 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
2979 |
#endif
|
|
2980 |
|
|
2981 |
}
|
|
2982 |
|
|
2983 |
|
|
2984 |
/*
|
|
2985 |
if(failures)
|
|
2986 |
return KErrGeneral;
|
|
2987 |
return KErrNone;
|
|
2988 |
*/
|
|
2989 |
//#if STDCPP_OOM
|
|
2990 |
//failures++;
|
|
2991 |
// #endif
|
|
2992 |
|
|
2993 |
|
|
2994 |
}
|
|
2995 |
|
|
2996 |
catch(bad_alloc&)
|
|
2997 |
{
|
|
2998 |
//do nothing
|
|
2999 |
}
|
|
3000 |
catch(...)
|
|
3001 |
{
|
|
3002 |
failures++;
|
|
3003 |
|
|
3004 |
}
|
|
3005 |
|
|
3006 |
if(failures )
|
|
3007 |
return KErrGeneral;
|
|
3008 |
return KErrNone;
|
|
3009 |
}
|
|
3010 |
|
|
3011 |
|
|
3012 |
TInt Ctstl_4::Ispunct( CStifItemParser& aItem )
|
|
3013 |
|
|
3014 |
{
|
|
3015 |
|
|
3016 |
int failures =0;
|
|
3017 |
|
|
3018 |
try{
|
|
3019 |
for(char text=0x21;text<=0x2F;text++)
|
|
3020 |
{
|
|
3021 |
#if STDCPP_OOM
|
|
3022 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
3023 |
#endif
|
|
3024 |
if(!ispunct(text))
|
|
3025 |
failures++;
|
|
3026 |
#if STDCPP_OOM
|
|
3027 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
3028 |
#endif
|
|
3029 |
|
|
3030 |
|
|
3031 |
}
|
|
3032 |
|
|
3033 |
for(char text=0x3A;text<=0x40;text++)
|
|
3034 |
{
|
|
3035 |
|
|
3036 |
if(!ispunct(text))
|
|
3037 |
failures++;
|
|
3038 |
|
|
3039 |
}
|
|
3040 |
|
|
3041 |
for(char text=0x5B;text<=0x60;text++)
|
|
3042 |
{
|
|
3043 |
|
|
3044 |
if(!ispunct(text))
|
|
3045 |
failures++;
|
|
3046 |
|
|
3047 |
}
|
|
3048 |
|
|
3049 |
for(char text=0x7B;text<=0x7E;text++)
|
|
3050 |
{
|
|
3051 |
|
|
3052 |
|
|
3053 |
if(!ispunct(text))
|
|
3054 |
failures++;
|
|
3055 |
|
|
3056 |
}
|
|
3057 |
|
|
3058 |
/*
|
|
3059 |
|
|
3060 |
if(failures)
|
|
3061 |
return KErrGeneral;
|
|
3062 |
return KErrNone;
|
|
3063 |
*/
|
|
3064 |
//#if STDCPP_OOM
|
|
3065 |
//failures++;
|
|
3066 |
// #endif
|
|
3067 |
}
|
|
3068 |
catch(bad_alloc&)
|
|
3069 |
{
|
|
3070 |
//do nothing
|
|
3071 |
}
|
|
3072 |
catch(...)
|
|
3073 |
{
|
|
3074 |
failures++;
|
|
3075 |
|
|
3076 |
}
|
|
3077 |
|
|
3078 |
if(failures )
|
|
3079 |
return KErrGeneral;
|
|
3080 |
return KErrNone;
|
|
3081 |
}
|
|
3082 |
TInt Ctstl_4::Isspace( CStifItemParser& aItem )
|
|
3083 |
|
|
3084 |
{
|
|
3085 |
|
|
3086 |
int failures =0;
|
|
3087 |
|
|
3088 |
try{
|
|
3089 |
|
|
3090 |
|
|
3091 |
for(char text=0x09;text<=0x0D;text++)
|
|
3092 |
{
|
|
3093 |
#if STDCPP_OOM
|
|
3094 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
3095 |
#endif
|
|
3096 |
if(!isspace(text))
|
|
3097 |
failures++;
|
|
3098 |
#if STDCPP_OOM
|
|
3099 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
3100 |
#endif
|
|
3101 |
|
|
3102 |
|
|
3103 |
}
|
|
3104 |
|
|
3105 |
if(!isspace(0x20))
|
|
3106 |
failures++;
|
|
3107 |
|
|
3108 |
|
|
3109 |
/*
|
|
3110 |
|
|
3111 |
|
|
3112 |
if(failures)
|
|
3113 |
return KErrGeneral;
|
|
3114 |
return KErrNone;
|
|
3115 |
*/
|
|
3116 |
//#if STDCPP_OOM
|
|
3117 |
//failures++;
|
|
3118 |
// #endif
|
|
3119 |
|
|
3120 |
|
|
3121 |
}
|
|
3122 |
catch(bad_alloc&)
|
|
3123 |
{
|
|
3124 |
//do nothing
|
|
3125 |
}
|
|
3126 |
catch(...)
|
|
3127 |
{
|
|
3128 |
failures++;
|
|
3129 |
|
|
3130 |
}
|
|
3131 |
|
|
3132 |
if(failures )
|
|
3133 |
return KErrGeneral;
|
|
3134 |
return KErrNone;
|
|
3135 |
}
|
|
3136 |
|
|
3137 |
TInt Ctstl_4::Isxdigit( CStifItemParser& aItem )
|
|
3138 |
|
|
3139 |
{
|
|
3140 |
|
|
3141 |
int failures =0;
|
|
3142 |
try{
|
|
3143 |
for(char text=0x30;text<=0x39;text++)
|
|
3144 |
{
|
|
3145 |
|
|
3146 |
#if STDCPP_OOM
|
|
3147 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
3148 |
#endif
|
|
3149 |
if(!isxdigit(text))
|
|
3150 |
failures++;
|
|
3151 |
#if STDCPP_OOM
|
|
3152 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
3153 |
#endif
|
|
3154 |
|
|
3155 |
|
|
3156 |
}
|
|
3157 |
|
|
3158 |
|
|
3159 |
for(char text=0x41;text<=0x46;text++)
|
|
3160 |
{
|
|
3161 |
|
|
3162 |
|
|
3163 |
if(!isxdigit(text))
|
|
3164 |
failures++;
|
|
3165 |
|
|
3166 |
}
|
|
3167 |
|
|
3168 |
|
|
3169 |
for(char text=0x61;text<=0x66;text++)
|
|
3170 |
{
|
|
3171 |
|
|
3172 |
|
|
3173 |
if(!isxdigit(text))
|
|
3174 |
failures++;
|
|
3175 |
|
|
3176 |
}
|
|
3177 |
|
|
3178 |
|
|
3179 |
|
|
3180 |
/*
|
|
3181 |
|
|
3182 |
if(failures)
|
|
3183 |
return KErrGeneral;
|
|
3184 |
return KErrNone;*/
|
|
3185 |
//#if STDCPP_OOM
|
|
3186 |
//failures++;
|
|
3187 |
// #endif
|
|
3188 |
|
|
3189 |
|
|
3190 |
|
|
3191 |
}
|
|
3192 |
|
|
3193 |
catch(bad_alloc&)
|
|
3194 |
{
|
|
3195 |
//do nothing
|
|
3196 |
}
|
|
3197 |
catch(...)
|
|
3198 |
{
|
|
3199 |
failures++;
|
|
3200 |
|
|
3201 |
}
|
|
3202 |
|
|
3203 |
if(failures )
|
|
3204 |
return KErrGeneral;
|
|
3205 |
return KErrNone;
|
|
3206 |
}
|
|
3207 |
|
|
3208 |
|
|
3209 |
TInt Ctstl_4::Fill( CStifItemParser& aItem )
|
|
3210 |
|
|
3211 |
{
|
|
3212 |
|
|
3213 |
int failures =0;
|
|
3214 |
|
|
3215 |
try
|
|
3216 |
{
|
|
3217 |
|
|
3218 |
vector<int> myvector (8,10); // myvector: 10 10 10 10 10 10 10 10
|
|
3219 |
vector<int>::iterator it ;
|
|
3220 |
// cout<<"";
|
|
3221 |
#if STDCPP_OOM
|
|
3222 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
3223 |
#endif
|
|
3224 |
fill_n(myvector.begin(),4,20); // myvector: 20 20 20 20 10 10 10 10
|
|
3225 |
#if STDCPP_OOM
|
|
3226 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
3227 |
#endif
|
|
3228 |
|
|
3229 |
for( it = myvector.begin();it!=myvector.begin()+4;++it)
|
|
3230 |
{
|
|
3231 |
|
|
3232 |
if(*it!=20)
|
|
3233 |
failures++;
|
|
3234 |
|
|
3235 |
}
|
|
3236 |
|
|
3237 |
|
|
3238 |
|
|
3239 |
|
|
3240 |
vector<int> myvector1 (8);
|
|
3241 |
// cout<<"";
|
|
3242 |
#if STDCPP_OOM
|
|
3243 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
3244 |
#endif // myvector: 0 0 0 0 0 0 0 0
|
|
3245 |
fill (myvector1.begin(),myvector1.begin()+4,5);
|
|
3246 |
#if STDCPP_OOM
|
|
3247 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
3248 |
#endif
|
|
3249 |
|
|
3250 |
|
|
3251 |
for (vector<int>::iterator it=myvector1.begin(); it!=myvector1.begin()+3; ++it)
|
|
3252 |
{
|
|
3253 |
|
|
3254 |
if(*it!=5)
|
|
3255 |
failures++;
|
|
3256 |
|
|
3257 |
}
|
|
3258 |
|
|
3259 |
//#if STDCPP_OOM
|
|
3260 |
//failures++;
|
|
3261 |
// #endif
|
|
3262 |
|
|
3263 |
}
|
|
3264 |
|
|
3265 |
catch(bad_alloc&)
|
|
3266 |
{
|
|
3267 |
//do nothing
|
|
3268 |
}
|
|
3269 |
catch(...)
|
|
3270 |
{
|
|
3271 |
failures++;
|
|
3272 |
|
|
3273 |
}
|
|
3274 |
|
|
3275 |
if(failures )
|
|
3276 |
return KErrGeneral;
|
|
3277 |
return KErrNone;
|
|
3278 |
}
|
|
3279 |
|
|
3280 |
|
|
3281 |
|
|
3282 |
|
|
3283 |
|
|
3284 |
static int UniqueNumber()
|
|
3285 |
{
|
|
3286 |
|
|
3287 |
static int current;
|
|
3288 |
return current++;
|
|
3289 |
}
|
|
3290 |
|
|
3291 |
|
|
3292 |
TInt Ctstl_4::Generate( CStifItemParser& aItem )
|
|
3293 |
|
|
3294 |
{
|
|
3295 |
int failures = 0;
|
|
3296 |
|
|
3297 |
try{
|
|
3298 |
vector<int> myvector (8);
|
|
3299 |
vector<int>::iterator it;
|
|
3300 |
int output[8];
|
|
3301 |
// cout<<"";
|
|
3302 |
#if STDCPP_OOM
|
|
3303 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
3304 |
#endif
|
|
3305 |
generate(myvector.begin(), myvector.end(), UniqueNumber);
|
|
3306 |
#if STDCPP_OOM
|
|
3307 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
3308 |
#endif
|
|
3309 |
|
|
3310 |
for (it=myvector.begin(); it!=myvector.end(); ++it)
|
|
3311 |
|
|
3312 |
{
|
|
3313 |
static int i;
|
|
3314 |
output[i] = *it;
|
|
3315 |
i++;
|
|
3316 |
|
|
3317 |
|
|
3318 |
}
|
|
3319 |
|
|
3320 |
|
|
3321 |
for(int i=0;i<=7;i++)
|
|
3322 |
{
|
|
3323 |
if(!output[i] == i)
|
|
3324 |
failures++;
|
|
3325 |
}
|
|
3326 |
// cout<<"";
|
|
3327 |
#if STDCPP_OOM
|
|
3328 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
3329 |
#endif
|
|
3330 |
generate_n(myvector.begin()+5,3,UniqueNumber);
|
|
3331 |
#if STDCPP_OOM
|
|
3332 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
3333 |
#endif
|
|
3334 |
|
|
3335 |
|
|
3336 |
for(int i=5;i<=7;i++)
|
|
3337 |
{
|
|
3338 |
if(!output[0] == 0)
|
|
3339 |
if(!output[1]==0)
|
|
3340 |
if(!output[2]==0)
|
|
3341 |
if(!output[3]==0)
|
|
3342 |
if(!output[4]==0)
|
|
3343 |
if(!output[i] == i)
|
|
3344 |
failures++;
|
|
3345 |
}
|
|
3346 |
|
|
3347 |
|
|
3348 |
|
|
3349 |
/*
|
|
3350 |
if(!failures)
|
|
3351 |
return KErrNone;
|
|
3352 |
return KErrGeneral;
|
|
3353 |
*/
|
|
3354 |
//#if STDCPP_OOM
|
|
3355 |
//failures++;
|
|
3356 |
// #endif
|
|
3357 |
|
|
3358 |
}
|
|
3359 |
|
|
3360 |
|
|
3361 |
catch(bad_alloc&)
|
|
3362 |
{
|
|
3363 |
//do nothing
|
|
3364 |
}
|
|
3365 |
catch(...)
|
|
3366 |
{
|
|
3367 |
failures++;
|
|
3368 |
|
|
3369 |
}
|
|
3370 |
|
|
3371 |
if(failures )
|
|
3372 |
return KErrGeneral;
|
|
3373 |
return KErrNone;
|
|
3374 |
}
|
|
3375 |
|
|
3376 |
|
|
3377 |
|
|
3378 |
|
|
3379 |
bool mypredicate1 (int i, int j) {
|
|
3380 |
return (i==j);
|
|
3381 |
}
|
|
3382 |
|
|
3383 |
|
|
3384 |
|
|
3385 |
TInt Ctstl_4::Search( CStifItemParser& aItem )
|
|
3386 |
|
|
3387 |
{
|
|
3388 |
int failures=0;
|
|
3389 |
try{
|
|
3390 |
|
|
3391 |
vector<int> myvector;
|
|
3392 |
vector<int>::iterator it;
|
|
3393 |
|
|
3394 |
// set some values: myvector: 10 20 30 40 50 60 70 80 90
|
|
3395 |
for (int i=1; i<10; i++)
|
|
3396 |
myvector.push_back(i*10);
|
|
3397 |
|
|
3398 |
|
|
3399 |
// using default comparison:
|
|
3400 |
int match1[] = {40,50,60,70};
|
|
3401 |
// cout<<"";
|
|
3402 |
#if STDCPP_OOM
|
|
3403 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
3404 |
#endif
|
|
3405 |
it = search (myvector.begin(), myvector.end(), match1, match1+4);
|
|
3406 |
|
|
3407 |
#if STDCPP_OOM
|
|
3408 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
3409 |
#endif
|
|
3410 |
if(int(it-myvector.begin())!=3)
|
|
3411 |
|
|
3412 |
failures++;
|
|
3413 |
|
|
3414 |
|
|
3415 |
// using predicate comparison:
|
|
3416 |
int match2[] = {20,30,50};
|
|
3417 |
#if STDCPP_OOM
|
|
3418 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
3419 |
#endif
|
|
3420 |
it = search (myvector.begin(), myvector.end(), match2, match2+3, mypredicate1);
|
|
3421 |
|
|
3422 |
#if STDCPP_OOM
|
|
3423 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
3424 |
#endif
|
|
3425 |
|
|
3426 |
if(int(it-myvector.begin()) == 1)
|
|
3427 |
failures++;
|
|
3428 |
|
|
3429 |
//#if STDCPP_OOM
|
|
3430 |
//failures++;
|
|
3431 |
// #endif
|
|
3432 |
//return KErrNone;
|
|
3433 |
//return KErrGeneral;
|
|
3434 |
}
|
|
3435 |
|
|
3436 |
|
|
3437 |
catch(bad_alloc&)
|
|
3438 |
{
|
|
3439 |
//do nothing
|
|
3440 |
}
|
|
3441 |
catch(...)
|
|
3442 |
{
|
|
3443 |
failures++;
|
|
3444 |
|
|
3445 |
}
|
|
3446 |
|
|
3447 |
if(failures )
|
|
3448 |
return KErrGeneral;
|
|
3449 |
return KErrNone;
|
|
3450 |
}
|
|
3451 |
|
|
3452 |
|
|
3453 |
|
|
3454 |
|
|
3455 |
TInt Ctstl_4::Search_n(CStifItemParser& aItem )
|
|
3456 |
|
|
3457 |
{
|
|
3458 |
|
|
3459 |
int failures=0;
|
|
3460 |
try{
|
|
3461 |
int myints[]={10,20,30,30,20,10,10,20};
|
|
3462 |
vector<int> myvector (myints,myints+8);
|
|
3463 |
|
|
3464 |
vector<int>::iterator it;
|
|
3465 |
// cout<<"";
|
|
3466 |
#if STDCPP_OOM
|
|
3467 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
3468 |
#endif
|
|
3469 |
// using default comparison:
|
|
3470 |
it = search_n (myvector.begin(), myvector.end(), 2, 30);
|
|
3471 |
|
|
3472 |
#if STDCPP_OOM
|
|
3473 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
3474 |
#endif
|
|
3475 |
|
|
3476 |
|
|
3477 |
/*
|
|
3478 |
if(int(it-myvector.begin())==2)
|
|
3479 |
return KErrNone;
|
|
3480 |
return KErrGeneral;
|
|
3481 |
*/
|
|
3482 |
|
|
3483 |
if(int(it-myvector.begin())!=2)
|
|
3484 |
failures++;
|
|
3485 |
|
|
3486 |
//#if STDCPP_OOM
|
|
3487 |
//failures++;
|
|
3488 |
// #endif
|
|
3489 |
}
|
|
3490 |
|
|
3491 |
catch(bad_alloc&)
|
|
3492 |
{
|
|
3493 |
//do nothing
|
|
3494 |
}
|
|
3495 |
catch(...)
|
|
3496 |
{
|
|
3497 |
failures++;
|
|
3498 |
|
|
3499 |
}
|
|
3500 |
|
|
3501 |
if(failures )
|
|
3502 |
return KErrGeneral;
|
|
3503 |
return KErrNone;
|
|
3504 |
}
|
|
3505 |
//code to be verified
|
|
3506 |
//--------------------------
|
|
3507 |
|
|
3508 |
TInt Ctstl_4::Times(CStifItemParser& aItem)
|
|
3509 |
{
|
|
3510 |
int failures=0;
|
|
3511 |
|
|
3512 |
//__UHEAP_MARK;
|
|
3513 |
try
|
|
3514 |
{
|
|
3515 |
|
|
3516 |
|
|
3517 |
int input1 [4] = { -10, 20, 30, 40 };
|
|
3518 |
int input2 [4] = { 40, 30, 20, -10 };
|
|
3519 |
int output [4];
|
|
3520 |
#if STDCPP_OOM
|
|
3521 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
3522 |
#endif
|
|
3523 |
transform((int*)input1, (int*)input1 + 4, (int*)input2, (int*)output, multiplies<int>());
|
|
3524 |
#if STDCPP_OOM
|
|
3525 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
3526 |
#endif
|
|
3527 |
if( output[1] != 600)
|
|
3528 |
failures++;
|
|
3529 |
if( output[2] != 600 )
|
|
3530 |
failures++;
|
|
3531 |
|
|
3532 |
if( output[3] != -400)
|
|
3533 |
failures++;
|
|
3534 |
|
|
3535 |
|
|
3536 |
|
|
3537 |
|
|
3538 |
//__UHEAP_MARKEND;
|
|
3539 |
}
|
|
3540 |
|
|
3541 |
catch(bad_alloc&)
|
|
3542 |
{
|
|
3543 |
//do nothing
|
|
3544 |
}
|
|
3545 |
catch(...)
|
|
3546 |
{
|
|
3547 |
failures++;
|
|
3548 |
|
|
3549 |
}
|
|
3550 |
|
|
3551 |
if(failures )
|
|
3552 |
return KErrGeneral;
|
|
3553 |
return KErrNone;
|
|
3554 |
}
|
|
3555 |
|
|
3556 |
TInt Ctstl_4::Unique(CStifItemParser& aItem)
|
|
3557 |
{
|
|
3558 |
|
|
3559 |
int failures=0;
|
|
3560 |
//__UHEAP_MARK;
|
|
3561 |
try{
|
|
3562 |
int myints[] = {10,20,20,20,30,30,20,20,10}; // 10 20 20 20 30 30 20 20 10
|
|
3563 |
vector<int> myvector (myints,myints+9);
|
|
3564 |
vector<int>::iterator it;
|
|
3565 |
int output[5];
|
|
3566 |
// cout<<"";
|
|
3567 |
#if STDCPP_OOM
|
|
3568 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
3569 |
#endif
|
|
3570 |
|
|
3571 |
// using default comparison:
|
|
3572 |
it = unique (myvector.begin(), myvector.end()); // 10 20 30 20 10 30 20 20 10
|
|
3573 |
// ^
|
|
3574 |
#if STDCPP_OOM
|
|
3575 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
3576 |
#endif
|
|
3577 |
myvector.resize( it - myvector.begin() ); // 10 20 30 20 10
|
|
3578 |
|
|
3579 |
|
|
3580 |
// print out content:
|
|
3581 |
for (it=myvector.begin(); it!=myvector.end(); ++it)
|
|
3582 |
|
|
3583 |
{
|
|
3584 |
|
|
3585 |
static int i;
|
|
3586 |
output[i] = *it;
|
|
3587 |
i++;
|
|
3588 |
|
|
3589 |
}
|
|
3590 |
|
|
3591 |
|
|
3592 |
/*
|
|
3593 |
|
|
3594 |
if(output[0]== 10)
|
|
3595 |
if(output[1]== 20)
|
|
3596 |
if(output[2]== 30)
|
|
3597 |
if(output[3]== 20)
|
|
3598 |
if(output[4]== 10)
|
|
3599 |
|
|
3600 |
return KErrNone;
|
|
3601 |
return KErrGeneral;*/
|
|
3602 |
// __UHEAP_MARKEND;
|
|
3603 |
|
|
3604 |
if(output[0]!=10)
|
|
3605 |
failures++;
|
|
3606 |
|
|
3607 |
if(output[1]!=20)
|
|
3608 |
failures++;
|
|
3609 |
|
|
3610 |
if(output[2]!=30)
|
|
3611 |
failures++;
|
|
3612 |
if(output[3]!=20)
|
|
3613 |
failures++;
|
|
3614 |
if(output[4]!=10)
|
|
3615 |
failures++;
|
|
3616 |
|
|
3617 |
|
|
3618 |
|
|
3619 |
|
|
3620 |
//#if STDCPP_OOM
|
|
3621 |
//failures++;
|
|
3622 |
// #endif
|
|
3623 |
|
|
3624 |
}
|
|
3625 |
|
|
3626 |
catch(bad_alloc&)
|
|
3627 |
{
|
|
3628 |
//do nothing
|
|
3629 |
}
|
|
3630 |
catch(...)
|
|
3631 |
{
|
|
3632 |
failures++;
|
|
3633 |
|
|
3634 |
}
|
|
3635 |
|
|
3636 |
if(failures )
|
|
3637 |
return KErrGeneral;
|
|
3638 |
return KErrNone;
|
|
3639 |
}
|
|
3640 |
|
|
3641 |
TInt Ctstl_4::Uniquecopy(CStifItemParser& aItem)
|
|
3642 |
{
|
|
3643 |
int failures=0;
|
|
3644 |
|
|
3645 |
try{
|
|
3646 |
//__UHEAP_MARK;
|
|
3647 |
int myints[] = {10,20,20,20,30,30,20,20,10};
|
|
3648 |
vector<int> myvector (9); // 0 0 0 0 0 0 0 0 0
|
|
3649 |
vector<int>::iterator it;
|
|
3650 |
int output[9];
|
|
3651 |
//cout<<"";
|
|
3652 |
#if STDCPP_OOM
|
|
3653 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
3654 |
#endif
|
|
3655 |
// using default comparison:
|
|
3656 |
it=unique_copy(myints,myints+9,myvector.begin()); // 10 20 30 20 10 0 0 0 0
|
|
3657 |
#if STDCPP_OOM
|
|
3658 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
3659 |
#endif // ^
|
|
3660 |
for (it=myvector.begin(); it!=myvector.end(); ++it)
|
|
3661 |
{
|
|
3662 |
static int i;
|
|
3663 |
output[i] = *it;
|
|
3664 |
i++;
|
|
3665 |
}
|
|
3666 |
// 10 20 30 20 30 0 0 0 0
|
|
3667 |
/* // ^
|
|
3668 |
if(output[0]==10)
|
|
3669 |
if(output[1]==20)
|
|
3670 |
if(output[2]==30)
|
|
3671 |
if(output[3]==20)
|
|
3672 |
if(output[4]==10)
|
|
3673 |
if(output[5]==0)
|
|
3674 |
if(output[6]==0)
|
|
3675 |
if(output[7]==0)
|
|
3676 |
if(output[8]==0)
|
|
3677 |
return KErrNone;
|
|
3678 |
return KErrGeneral;
|
|
3679 |
*/
|
|
3680 |
if(output[0]!=10)
|
|
3681 |
failures++;
|
|
3682 |
|
|
3683 |
if(output[1]!=20)
|
|
3684 |
failures++;
|
|
3685 |
|
|
3686 |
if(output[2]!=30)
|
|
3687 |
failures++;
|
|
3688 |
if(output[3]!=20)
|
|
3689 |
failures++;
|
|
3690 |
if(output[4]!=10)
|
|
3691 |
failures++;
|
|
3692 |
if(output[5]!=0)
|
|
3693 |
failures++;
|
|
3694 |
if(output[6]!=0)
|
|
3695 |
failures++;
|
|
3696 |
if(output[7]!=0)
|
|
3697 |
failures++;
|
|
3698 |
if(output[8]!=0)
|
|
3699 |
failures++;
|
|
3700 |
|
|
3701 |
|
|
3702 |
//#if STDCPP_OOM
|
|
3703 |
//failures++;
|
|
3704 |
// #endif
|
|
3705 |
|
|
3706 |
// __UHEAP_MARKEND;
|
|
3707 |
|
|
3708 |
}
|
|
3709 |
|
|
3710 |
catch(bad_alloc&)
|
|
3711 |
{
|
|
3712 |
//do nothing
|
|
3713 |
}
|
|
3714 |
catch(...)
|
|
3715 |
{
|
|
3716 |
failures++;
|
|
3717 |
|
|
3718 |
}
|
|
3719 |
|
|
3720 |
if(failures )
|
|
3721 |
return KErrGeneral;
|
|
3722 |
return KErrNone;
|
|
3723 |
}
|
|
3724 |
|
|
3725 |
|
|
3726 |
TInt Ctstl_4::Partialsort(CStifItemParser& aItem)
|
|
3727 |
{
|
|
3728 |
int failures=0;
|
|
3729 |
try
|
|
3730 |
{
|
|
3731 |
|
|
3732 |
//__UHEAP_MARK;
|
|
3733 |
int myints[] = {9,8,7,6,5,4,3,2,1};
|
|
3734 |
vector<int> myvector (myints, myints+9);
|
|
3735 |
vector<int>::iterator it;
|
|
3736 |
int output[9];
|
|
3737 |
//cout<<"";
|
|
3738 |
#if STDCPP_OOM
|
|
3739 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
3740 |
#endif
|
|
3741 |
// using default comparison (operator <):
|
|
3742 |
partial_sort (myvector.begin(), myvector.begin()+5, myvector.end());
|
|
3743 |
|
|
3744 |
#if STDCPP_OOM
|
|
3745 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
3746 |
#endif
|
|
3747 |
for (it=myvector.begin(); it!=myvector.end(); ++it)
|
|
3748 |
{
|
|
3749 |
static int i;
|
|
3750 |
output[i] = *it;
|
|
3751 |
i++;
|
|
3752 |
}
|
|
3753 |
|
|
3754 |
/*
|
|
3755 |
if(output[0]==1)
|
|
3756 |
if(output[1]==2)
|
|
3757 |
if(output[2]==3)
|
|
3758 |
if(output[3]==4)
|
|
3759 |
if(output[5]==9)
|
|
3760 |
if(output[6]==8)
|
|
3761 |
if(output[7]==7)
|
|
3762 |
if(output[8]==6)
|
|
3763 |
if(output[4]==5)
|
|
3764 |
|
|
3765 |
return KErrNone;
|
|
3766 |
return KErrGeneral;
|
|
3767 |
*/
|
|
3768 |
|
|
3769 |
// __UHEAP_MARKEND;
|
|
3770 |
if(output[0]!=1)
|
|
3771 |
failures++;
|
|
3772 |
|
|
3773 |
if(output[1]!=2)
|
|
3774 |
failures++;
|
|
3775 |
|
|
3776 |
if(output[2]!=3)
|
|
3777 |
failures++;
|
|
3778 |
if(output[3]!=4)
|
|
3779 |
failures++;
|
|
3780 |
if(output[4]!=5)
|
|
3781 |
failures++;
|
|
3782 |
if(output[5]!=9)
|
|
3783 |
failures++;
|
|
3784 |
if(output[6]!=8)
|
|
3785 |
failures++;
|
|
3786 |
if(output[7]!=7)
|
|
3787 |
failures++;
|
|
3788 |
if(output[8]!=6)
|
|
3789 |
failures++;
|
|
3790 |
|
|
3791 |
|
|
3792 |
//#if STDCPP_OOM
|
|
3793 |
//failures++;
|
|
3794 |
// #endif
|
|
3795 |
}
|
|
3796 |
|
|
3797 |
catch(bad_alloc&)
|
|
3798 |
{
|
|
3799 |
//do nothing
|
|
3800 |
}
|
|
3801 |
catch(...)
|
|
3802 |
{
|
|
3803 |
failures++;
|
|
3804 |
|
|
3805 |
}
|
|
3806 |
|
|
3807 |
if(failures )
|
|
3808 |
return KErrGeneral;
|
|
3809 |
return KErrNone;
|
|
3810 |
}
|
|
3811 |
|
|
3812 |
|
|
3813 |
TInt Ctstl_4::Partialsortcopy(CStifItemParser& aItem)
|
|
3814 |
{
|
|
3815 |
int failures=0;
|
|
3816 |
try{
|
|
3817 |
//__UHEAP_MARK;
|
|
3818 |
int myints[] = {9,8,7,6,5,4,3,2,1};
|
|
3819 |
vector<int> myvector (5);
|
|
3820 |
vector<int>::iterator it;
|
|
3821 |
int output[5];
|
|
3822 |
//cout<<"";
|
|
3823 |
#if STDCPP_OOM
|
|
3824 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
3825 |
#endif
|
|
3826 |
// using default comparison (operator <):
|
|
3827 |
partial_sort_copy (myints, myints+9, myvector.begin(), myvector.end());
|
|
3828 |
|
|
3829 |
|
|
3830 |
#if STDCPP_OOM
|
|
3831 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
3832 |
#endif
|
|
3833 |
|
|
3834 |
|
|
3835 |
for (it=myvector.begin(); it!=myvector.end(); ++it)
|
|
3836 |
{
|
|
3837 |
static int i;
|
|
3838 |
output[i] = *it;
|
|
3839 |
i++;
|
|
3840 |
}
|
|
3841 |
|
|
3842 |
/*
|
|
3843 |
if(output[0]==1)
|
|
3844 |
if(output[1]==2)
|
|
3845 |
if(output[2]==3)
|
|
3846 |
if(output[3]==4)
|
|
3847 |
if(output[4]==5)
|
|
3848 |
|
|
3849 |
return KErrNone;
|
|
3850 |
return KErrGeneral;*/
|
|
3851 |
|
|
3852 |
//__UHEAP_MARKEND;
|
|
3853 |
|
|
3854 |
if(output[0]!=1)
|
|
3855 |
failures++;
|
|
3856 |
if(output[1]!=2)
|
|
3857 |
failures++;
|
|
3858 |
if(output[2]!=3)
|
|
3859 |
failures++;
|
|
3860 |
if(output[3]!=4)
|
|
3861 |
failures++;
|
|
3862 |
if(output[4]!=5)
|
|
3863 |
failures++;
|
|
3864 |
//#if STDCPP_OOM
|
|
3865 |
//failures++;
|
|
3866 |
// #endif
|
|
3867 |
|
|
3868 |
}
|
|
3869 |
|
|
3870 |
catch(bad_alloc&)
|
|
3871 |
{
|
|
3872 |
//do nothing
|
|
3873 |
}
|
|
3874 |
catch(...)
|
|
3875 |
{
|
|
3876 |
failures++;
|
|
3877 |
|
|
3878 |
}
|
|
3879 |
|
|
3880 |
if(failures )
|
|
3881 |
return KErrGeneral;
|
|
3882 |
return KErrNone;
|
|
3883 |
}
|
|
3884 |
|
|
3885 |
|
|
3886 |
|
|
3887 |
bool IsOdd(int i)
|
|
3888 |
{
|
|
3889 |
return (i%2)==1;
|
|
3890 |
}
|
|
3891 |
|
|
3892 |
|
|
3893 |
TInt Ctstl_4::Partition(CStifItemParser& aItem)
|
|
3894 |
{
|
|
3895 |
int failures=0;
|
|
3896 |
try{
|
|
3897 |
//__UHEAP_MARK;
|
|
3898 |
//int myints[] = {9,8,7,6,5,4,3,2,1};
|
|
3899 |
vector<int> myvector;
|
|
3900 |
vector<int>::iterator it, bound;
|
|
3901 |
int Odd[5];
|
|
3902 |
int Even[4];
|
|
3903 |
// set some values:
|
|
3904 |
for (int i=1; i<10; ++i) myvector.push_back(i); // 1 2 3 4 5 6 7 8 9
|
|
3905 |
// cout<<"";
|
|
3906 |
#if STDCPP_OOM
|
|
3907 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
3908 |
#endif
|
|
3909 |
bound = partition (myvector.begin(), myvector.end(), IsOdd);
|
|
3910 |
#if STDCPP_OOM
|
|
3911 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
3912 |
#endif
|
|
3913 |
// print out content:
|
|
3914 |
for (it=myvector.begin(); it!=bound; ++it)
|
|
3915 |
|
|
3916 |
{
|
|
3917 |
static int i;
|
|
3918 |
Odd[i] = *it;
|
|
3919 |
i++;
|
|
3920 |
}
|
|
3921 |
|
|
3922 |
|
|
3923 |
for (it=bound; it!=myvector.end(); ++it)
|
|
3924 |
|
|
3925 |
{
|
|
3926 |
static int i;
|
|
3927 |
Even[i]=*it;
|
|
3928 |
i++;
|
|
3929 |
}
|
|
3930 |
|
|
3931 |
/*
|
|
3932 |
if(Odd[0] ==1)
|
|
3933 |
if(Odd[1] ==9)
|
|
3934 |
if(Odd[2] ==3)
|
|
3935 |
if(Odd[3] ==7)
|
|
3936 |
if(Odd[4] ==5)
|
|
3937 |
if(Even[0]==6)
|
|
3938 |
if(Even[1]==4)
|
|
3939 |
if(Even[2]==8)
|
|
3940 |
if(Even[3]==2)
|
|
3941 |
|
|
3942 |
return KErrNone;
|
|
3943 |
return KErrGeneral;*/
|
|
3944 |
if(Odd[0] !=1)
|
|
3945 |
failures++;
|
|
3946 |
|
|
3947 |
if(Odd[1] !=9)
|
|
3948 |
failures++;
|
|
3949 |
if(Odd[2] !=3)
|
|
3950 |
failures++;
|
|
3951 |
if(Odd[3] !=7)
|
|
3952 |
failures++;
|
|
3953 |
if(Odd[4] !=5)
|
|
3954 |
failures++;
|
|
3955 |
if(Even[0]!=6)
|
|
3956 |
failures++;
|
|
3957 |
if(Even[1]!=4)
|
|
3958 |
failures++;
|
|
3959 |
if(Even[2]!=8)
|
|
3960 |
failures++;
|
|
3961 |
if(Even[3]!=2)
|
|
3962 |
failures++;
|
|
3963 |
|
|
3964 |
//#if STDCPP_OOM
|
|
3965 |
//failures++;
|
|
3966 |
// #endif
|
|
3967 |
// __UHEAP_MARKEND;
|
|
3968 |
|
|
3969 |
}
|
|
3970 |
|
|
3971 |
catch(bad_alloc&)
|
|
3972 |
{
|
|
3973 |
//do nothing
|
|
3974 |
}
|
|
3975 |
catch(...)
|
|
3976 |
{
|
|
3977 |
failures++;
|
|
3978 |
|
|
3979 |
}
|
|
3980 |
|
|
3981 |
if(failures )
|
|
3982 |
return KErrGeneral;
|
|
3983 |
return KErrNone;
|
|
3984 |
}
|
|
3985 |
|
|
3986 |
|
|
3987 |
|
|
3988 |
TInt Ctstl_4::Stablepartition(CStifItemParser& aItem)
|
|
3989 |
{
|
|
3990 |
int failures=0;
|
|
3991 |
try{
|
|
3992 |
//__UHEAP_MARK;
|
|
3993 |
//int myints[] = {9,8,7,6,5,4,3,2,1};
|
|
3994 |
vector<int> myvector;
|
|
3995 |
vector<int>::iterator it, bound;
|
|
3996 |
int Odd[5];
|
|
3997 |
int Even[4];
|
|
3998 |
// set some values:
|
|
3999 |
for (int i=1; i<10; ++i) myvector.push_back(i); // 1 2 3 4 5 6 7 8 9
|
|
4000 |
// cout<<"";
|
|
4001 |
#if STDCPP_OOM
|
|
4002 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
4003 |
#endif
|
|
4004 |
bound = stable_partition (myvector.begin(), myvector.end(), IsOdd);
|
|
4005 |
#if STDCPP_OOM
|
|
4006 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
4007 |
#endif
|
|
4008 |
// print out content:
|
|
4009 |
for (it=myvector.begin(); it!=bound; ++it)
|
|
4010 |
|
|
4011 |
{
|
|
4012 |
static int i;
|
|
4013 |
Odd[i] = *it;
|
|
4014 |
i++;
|
|
4015 |
}
|
|
4016 |
|
|
4017 |
|
|
4018 |
for (it=bound; it!=myvector.end(); ++it)
|
|
4019 |
|
|
4020 |
{
|
|
4021 |
static int i;
|
|
4022 |
Even[i]=*it;
|
|
4023 |
i++;
|
|
4024 |
}
|
|
4025 |
|
|
4026 |
/*
|
|
4027 |
if(Odd[0] ==1)
|
|
4028 |
if(Odd[1] ==3)
|
|
4029 |
if(Odd[2] ==5)
|
|
4030 |
if(Odd[3] ==7)
|
|
4031 |
if(Odd[4] ==9)
|
|
4032 |
if(Even[0]==2)
|
|
4033 |
if(Even[1]==4)
|
|
4034 |
if(Even[2]==6)
|
|
4035 |
if(Even[3]==8)
|
|
4036 |
|
|
4037 |
return KErrNone;
|
|
4038 |
return KErrGeneral;*/
|
|
4039 |
|
|
4040 |
//__UHEAP_MARKEND;
|
|
4041 |
|
|
4042 |
if(Odd[0] !=1)
|
|
4043 |
failures++;
|
|
4044 |
|
|
4045 |
if(Odd[1] !=3)
|
|
4046 |
failures++;
|
|
4047 |
if(Odd[2] !=5)
|
|
4048 |
failures++;
|
|
4049 |
if(Odd[3] !=7)
|
|
4050 |
failures++;
|
|
4051 |
if(Odd[4] !=9)
|
|
4052 |
failures++;
|
|
4053 |
if(Even[0]!=2)
|
|
4054 |
failures++;
|
|
4055 |
if(Even[1]!=4)
|
|
4056 |
failures++;
|
|
4057 |
if(Even[2]!=6)
|
|
4058 |
failures++;
|
|
4059 |
if(Even[3]!=8)
|
|
4060 |
failures++;
|
|
4061 |
|
|
4062 |
//#if STDCPP_OOM
|
|
4063 |
//failures++;
|
|
4064 |
// #endif
|
|
4065 |
}
|
|
4066 |
catch(bad_alloc&)
|
|
4067 |
{
|
|
4068 |
//do nothing
|
|
4069 |
}
|
|
4070 |
catch(...)
|
|
4071 |
{
|
|
4072 |
failures++;
|
|
4073 |
|
|
4074 |
}
|
|
4075 |
|
|
4076 |
if(failures )
|
|
4077 |
return KErrGeneral;
|
|
4078 |
return KErrNone;
|
|
4079 |
}
|
|
4080 |
|
|
4081 |
|
|
4082 |
TInt Ctstl_4::Setdifference(CStifItemParser& aItem)
|
|
4083 |
{
|
|
4084 |
int failures=0;
|
|
4085 |
try{
|
|
4086 |
|
|
4087 |
//__UHEAP_MARK;
|
|
4088 |
int first[] = {5,10,15,20,25};
|
|
4089 |
|
|
4090 |
int second[] = {50,40,30,20,10};
|
|
4091 |
|
|
4092 |
int output[10];
|
|
4093 |
vector<int> v(10); // 0 0 0 0 0 0 0 0 0 0
|
|
4094 |
vector<int>::iterator it;
|
|
4095 |
|
|
4096 |
sort (first,first+5); // 5 10 15 20 25
|
|
4097 |
sort (second,second+5); // 10 20 30 40 50
|
|
4098 |
// cout<<"";
|
|
4099 |
#if STDCPP_OOM
|
|
4100 |
User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
|
|
4101 |
#endif
|
|
4102 |
it=set_difference (first, first+5, second, second+5, v.begin());
|
|
4103 |
// 5 15 25 0 0 0 0 0 0 0
|
|
4104 |
#if STDCPP_OOM
|
|
4105 |
User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
|
|
4106 |
#endif
|
|
4107 |
for(it=v.begin();it!=v.end();++it)
|
|
4108 |
{
|
|
4109 |
|
|
4110 |
static int i;
|
|
4111 |
output[i] = *it;
|
|
4112 |
i++;
|
|
4113 |
|
|
4114 |
}
|
|
4115 |
|
|
4116 |
/*if(output[0]==5)
|
|
4117 |
if(output[1]==15)
|
|
4118 |
if(output[2]==25)
|
|
4119 |
return KErrNone;
|
|
4120 |
return KErrGeneral;*/
|
|
4121 |
if(output[0]!=5)
|
|
4122 |
failures++;
|
|
4123 |
if(output[1]!=15)
|
|
4124 |
failures++;
|
|
4125 |
if(output[2]!=25)
|
|
4126 |
failures++;
|
|
4127 |
|
|
4128 |
//#if STDCPP_OOM
|
|
4129 |
//failures++;
|
|
4130 |
// #endif
|
|
4131 |
|
|
4132 |
// __UHEAP_MARKEND;
|
|
4133 |
|
|
4134 |
}
|
|
4135 |
|
|
4136 |
catch(bad_alloc&)
|
|
4137 |
{
|
|
4138 |
//do nothing
|
|
4139 |
}
|
|
4140 |
catch(...)
|
|
4141 |
{
|
|
4142 |
failures++;
|
|
4143 |
|
|
4144 |
}
|
|
4145 |
|
|
4146 |
if(failures )
|
|
4147 |
return KErrGeneral;
|
|
4148 |
return KErrNone;
|
|
4149 |
}
|
|
4150 |
|
|
4151 |
|
|
4152 |
|
|
4153 |
|
|
4154 |
|
|
4155 |
|
|
4156 |
// End of File
|