|
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<iostream> |
|
26 #include<fstream> |
|
27 #include<string> |
|
28 #include<ostream> |
|
29 #include <sstream> |
|
30 #include<strstream> |
|
31 #include<deque> |
|
32 #include<iterator> |
|
33 #include<vector> |
|
34 #include <ios> |
|
35 #include <iostream> |
|
36 #include <fstream> |
|
37 #include <stl/char_traits.h> |
|
38 #include<e32std.h> |
|
39 |
|
40 #include<exception> |
|
41 |
|
42 #include "tiostreams.h" |
|
43 using namespace std; |
|
44 #define STDCPP_OOM FALSE// TRUE for OOM testing |
|
45 |
|
46 |
|
47 // ============================ MEMBER FUNCTIONS =============================== |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // Ctiostreams::Delete |
|
51 // Delete here all resources allocated and opened from test methods. |
|
52 // Called from destructor. |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 void Ctiostreams::Delete() |
|
56 { |
|
57 |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // Ctiostreams::RunMethodL |
|
62 // Run specified method. Contains also table of test mothods and their names. |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 TInt Ctiostreams::RunMethodL( |
|
66 CStifItemParser& aItem ) |
|
67 { |
|
68 |
|
69 static TStifFunctionInfo const KFunctions[] = |
|
70 { |
|
71 // Copy this line for every implemented function. |
|
72 // First string is the function name used in TestScripter script file. |
|
73 // Second is the actual implementation member function. |
|
74 // Second is the actual implementation member function. |
|
75 ENTRY( "iofstreamL", Ctiostreams::iofstreamL ), |
|
76 ENTRY( "stringbufL", Ctiostreams::stringbufL ), |
|
77 ENTRY( "stringstreamL", Ctiostreams::stringstreamL ), |
|
78 ENTRY( "streambufL", Ctiostreams:: streambufL ), |
|
79 ENTRY( "ostreamL", Ctiostreams:: ostreamL ), |
|
80 ENTRY( "istreamL", Ctiostreams:: istreamL ), |
|
81 ENTRY( "istringstreamL", Ctiostreams:: istringstreamL ), |
|
82 ENTRY( "ostringstreamL", Ctiostreams:: ostringstreamL ), |
|
83 ENTRY( "ostreamiterators", Ctiostreams::ostreamiterators ), |
|
84 ENTRY( "fstreamL", Ctiostreams::fstreamL), |
|
85 ENTRY( "istrstreamL", Ctiostreams::istrstreamL), |
|
86 ENTRY( "strstreamL", Ctiostreams::strstreamL), |
|
87 ENTRY( "ostrstreamL", Ctiostreams::ostrstreamL), |
|
88 ENTRY( "istreamiterators", Ctiostreams::istreamiterators ), |
|
89 ENTRY( "istreambufiterators", Ctiostreams::istreambufiterators ), |
|
90 ENTRY( "strstreambufL", Ctiostreams::strstreambufL ), |
|
91 ENTRY( "freezeL", Ctiostreams::freezeL ), |
|
92 ENTRY( "fposL", Ctiostreams::fposL ), |
|
93 ENTRY( "filebufL", Ctiostreams::filebufL ), |
|
94 ENTRY( "seekpL", Ctiostreams::seekpL ), |
|
95 |
|
96 |
|
97 }; |
|
98 |
|
99 const TInt count = sizeof( KFunctions ) / |
|
100 sizeof( TStifFunctionInfo ); |
|
101 |
|
102 return RunInternalL( KFunctions, count, aItem ); |
|
103 |
|
104 } |
|
105 |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // Ctiostreams:: ofstream,ifstream |
|
109 // Example test method function. |
|
110 // (other items were commented in a header). |
|
111 // ----------------------------------------------------------------------------- |
|
112 // |
|
113 |
|
114 |
|
115 TInt Ctiostreams::iofstreamL( CStifItemParser& aItem ) |
|
116 { |
|
117 |
|
118 |
|
119 //__UHEAP_MARK; |
|
120 int failures=0 ; |
|
121 try |
|
122 { |
|
123 cout<<""; |
|
124 #if STDCPP_OOM |
|
125 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
126 #endif |
|
127 ofstream myfile; |
|
128 filebuf *fbuf; |
|
129 char * buffer; |
|
130 long size; |
|
131 //ifstream |
|
132 myfile.open ("c:\\TestFramework\\docs\\example.txt"); |
|
133 if(!myfile.is_open()) |
|
134 failures++; |
|
135 |
|
136 myfile << "Writing this to a file."; |
|
137 myfile<<"\0"; |
|
138 myfile.close(); |
|
139 if(myfile.is_open()) |
|
140 failures++; |
|
141 |
|
142 |
|
143 |
|
144 |
|
145 // string line; |
|
146 ifstream myfile1; |
|
147 |
|
148 |
|
149 myfile1.open("c:\\TestFramework\\docs\\example.txt" ); |
|
150 |
|
151 fbuf=myfile1.rdbuf(); |
|
152 |
|
153 |
|
154 // get file size using buffer's members |
|
155 size=fbuf->pubseekoff (0,ios::end,ios::in); |
|
156 fbuf->pubseekpos (0,ios::in); |
|
157 |
|
158 // allocate memory to contain file data |
|
159 buffer=new char[size]; |
|
160 |
|
161 // get file data |
|
162 fbuf->sgetn (buffer,size); |
|
163 |
|
164 #if STDCPP_OOM |
|
165 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
166 #endif |
|
167 |
|
168 |
|
169 if(buffer != "Writing this to a file."); |
|
170 else |
|
171 failures++; |
|
172 |
|
173 if(size!= 23) |
|
174 failures++; |
|
175 |
|
176 |
|
177 if(!myfile1.is_open()) |
|
178 failures++; |
|
179 myfile1.close(); |
|
180 if(myfile1.is_open()) |
|
181 failures++; |
|
182 |
|
183 delete buffer; |
|
184 ios_base::Init(); // 0 - 218 FUNCTION Init() iostream.cpp |
|
185 filebuf* _Stl_create_filebuf(FILE* f, ios_base::openmode mode ); // 0 - 225 FUNCTION _Stl_create_filebuf() iostream.cpp |
|
186 ios_base::sync_with_stdio();//0 - 445 FUNCTION ios_base::sync_with_stdio() |
|
187 /* |
|
188 if(failures) |
|
189 |
|
190 return KErrGeneral; |
|
191 return KErrNone; |
|
192 |
|
193 */ |
|
194 |
|
195 |
|
196 //#if STDCPP_OOM |
|
197 //failures++; |
|
198 // #endif |
|
199 |
|
200 } |
|
201 |
|
202 catch(bad_alloc&) |
|
203 { |
|
204 //do nothing |
|
205 } |
|
206 catch(...) |
|
207 { |
|
208 failures++; |
|
209 |
|
210 } |
|
211 |
|
212 if( failures == 0 ) |
|
213 return KErrNone; |
|
214 else |
|
215 return KErrGeneral; |
|
216 |
|
217 } |
|
218 |
|
219 |
|
220 |
|
221 // ----------------------------------------------------------------------------- |
|
222 // Ctiostreams:: stringbuf |
|
223 // Example test method function. |
|
224 // (other items were commented in a header). |
|
225 // ----------------------------------------------------------------------------- |
|
226 // |
|
227 |
|
228 TInt Ctiostreams::stringbufL(CStifItemParser& aItem ) |
|
229 { |
|
230 |
|
231 int failures = 0; |
|
232 try |
|
233 { |
|
234 cout<<""; |
|
235 #if STDCPP_OOM |
|
236 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
237 #endif |
|
238 stringbuf sb; |
|
239 string mystr; |
|
240 |
|
241 sb.sputn("Sample string",13); |
|
242 mystr=sb.str(); |
|
243 |
|
244 |
|
245 |
|
246 if(sb.in_avail()!=13) |
|
247 failures++; |
|
248 |
|
249 |
|
250 char ch = sb.sgetc(); |
|
251 if(ch!= 'S') |
|
252 failures++; |
|
253 |
|
254 |
|
255 |
|
256 |
|
257 |
|
258 |
|
259 if(mystr.compare("Sample string") != 0) |
|
260 failures++; |
|
261 |
|
262 #if STDCPP_OOM |
|
263 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
264 #endif |
|
265 /* if(failures) |
|
266 |
|
267 return KErrGeneral; |
|
268 else |
|
269 return KErrNone; |
|
270 */ |
|
271 |
|
272 |
|
273 //#if STDCPP_OOM |
|
274 //failures++; |
|
275 // #endif |
|
276 |
|
277 } |
|
278 |
|
279 catch(bad_alloc&) |
|
280 { |
|
281 //do nothing |
|
282 } |
|
283 catch(...) |
|
284 { |
|
285 failures++; |
|
286 |
|
287 } |
|
288 |
|
289 if( failures == 0 ) |
|
290 return KErrNone; |
|
291 else |
|
292 return KErrGeneral; |
|
293 } |
|
294 // ----------------------------------------------------------------------------- |
|
295 // Ctiostreams:: stringstream |
|
296 // Example test method function. |
|
297 // (other items were commented in a header). |
|
298 // ----------------------------------------------------------------------------- |
|
299 // |
|
300 |
|
301 |
|
302 TInt Ctiostreams::stringstreamL(CStifItemParser& aItem ) |
|
303 { |
|
304 |
|
305 int val; |
|
306 string teststr; |
|
307 int failures = 0; |
|
308 try |
|
309 { |
|
310 cout<<""; |
|
311 #if STDCPP_OOM |
|
312 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
313 #endif |
|
314 stringstream ss (stringstream::in | stringstream::out); |
|
315 stringstream teststring; |
|
316 |
|
317 |
|
318 teststring<<"stringstream testcase"; |
|
319 |
|
320 teststr = teststring.str(); |
|
321 |
|
322 if(!teststr.compare("stringstream testcase")) |
|
323 ; |
|
324 else |
|
325 failures++; |
|
326 |
|
327 ss << "120 42 377 6 5 2000"; |
|
328 #if STDCPP_OOM |
|
329 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
330 #endif |
|
331 for (int n=0; n<6; n++) |
|
332 { |
|
333 ss >> val; |
|
334 |
|
335 switch(n) |
|
336 { |
|
337 case 0://precision |
|
338 if(val!=120) |
|
339 failures++; |
|
340 break; |
|
341 case 1: |
|
342 if(val!=42) |
|
343 failures++; |
|
344 break; |
|
345 case 2: |
|
346 if(val!=377) |
|
347 failures++; |
|
348 break; |
|
349 case 3: |
|
350 if(val!=6) |
|
351 failures++; |
|
352 break; |
|
353 |
|
354 case 4: |
|
355 if(val!=5) |
|
356 failures++; |
|
357 break; |
|
358 |
|
359 case 5: |
|
360 if(val!=2000) |
|
361 failures++; |
|
362 break; |
|
363 |
|
364 default: |
|
365 break; |
|
366 } |
|
367 |
|
368 |
|
369 } |
|
370 |
|
371 /* if(failures) |
|
372 return KErrGeneral; |
|
373 return KErrNone; |
|
374 */ |
|
375 |
|
376 |
|
377 |
|
378 //#if STDCPP_OOM |
|
379 //failures++; |
|
380 // #endif |
|
381 } |
|
382 |
|
383 catch(bad_alloc&) |
|
384 { |
|
385 //do nothing |
|
386 } |
|
387 catch(...) |
|
388 { |
|
389 failures++; |
|
390 |
|
391 } |
|
392 |
|
393 if( failures == 0 ) |
|
394 return KErrNone; |
|
395 else |
|
396 return KErrGeneral; |
|
397 } |
|
398 |
|
399 // ----------------------------------------------------------------------------- |
|
400 // Ctiostreams:: streambuf |
|
401 // Example test method function. |
|
402 // (other items were commented in a header). |
|
403 // ----------------------------------------------------------------------------- |
|
404 // |
|
405 |
|
406 TInt Ctiostreams::streambufL(CStifItemParser& aItem ) |
|
407 { |
|
408 // locale loc ("en_GB.UTF-8"); |
|
409 |
|
410 |
|
411 |
|
412 int failures = 0; |
|
413 try |
|
414 { |
|
415 |
|
416 |
|
417 char a[4]= |
|
418 { |
|
419 0 |
|
420 }; |
|
421 |
|
422 char sentence[]= "Sample sentence"; |
|
423 cout<<""; |
|
424 #if STDCPP_OOM |
|
425 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
426 #endif |
|
427 streambuf * pbuf; |
|
428 ofstream ostr ("c:\\TestFramework\\docs\\streambuf.txt"); |
|
429 |
|
430 |
|
431 |
|
432 if(!cout.rdbuf( )->getloc( ).name( ).c_str( )) //failing |
|
433 // failures++; |
|
434 ; |
|
435 char ch[14]; |
|
436 //rdbuf()s |
|
437 pbuf = ostr.rdbuf(); |
|
438 |
|
439 |
|
440 //sputn() |
|
441 |
|
442 |
|
443 |
|
444 |
|
445 pbuf->sputn (sentence,sizeof(sentence)-1); |
|
446 |
|
447 |
|
448 ostr.open("c:\\TestFramework\\docs\\streambuf.txt"); |
|
449 |
|
450 if(!ostr.is_open()) |
|
451 failures++; |
|
452 |
|
453 |
|
454 long size1 = pbuf->pubseekoff(0,ios_base::end); |
|
455 if(size1!=15) |
|
456 failures++; |
|
457 |
|
458 |
|
459 pbuf->sputc('a'); |
|
460 |
|
461 |
|
462 long size2 = pbuf->pubseekoff(0,ios_base::end); |
|
463 if(size2!=16) |
|
464 failures++; |
|
465 |
|
466 ifstream istr("c:\\TestFramework\\docs\\streambuf.txt"); |
|
467 pbuf = istr.rdbuf(); |
|
468 |
|
469 streamsize i = istr.rdbuf()->sgetn(&a[0], 3); |
|
470 |
|
471 // Display the size and contents of the buffer passed to sgetn. |
|
472 if(i!=3) |
|
473 failures++; |
|
474 |
|
475 |
|
476 int k = pbuf->snextc(); |
|
477 |
|
478 |
|
479 //sgetc() |
|
480 while (pbuf->sgetc()!=EOF) |
|
481 { |
|
482 // static int i; |
|
483 int i=0; |
|
484 //sbumpc() |
|
485 ch[i] = pbuf->sbumpc(); |
|
486 i++; |
|
487 } |
|
488 |
|
489 |
|
490 if(ch[0]!='a' ) |
|
491 failures++; |
|
492 |
|
493 |
|
494 |
|
495 |
|
496 |
|
497 |
|
498 istr.close(); |
|
499 #if STDCPP_OOM |
|
500 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
501 #endif |
|
502 /* |
|
503 if(failures) |
|
504 return KErrGeneral; |
|
505 else |
|
506 return KErrNone; |
|
507 |
|
508 */ |
|
509 |
|
510 |
|
511 //#if STDCPP_OOM |
|
512 //failures++; |
|
513 // #endif |
|
514 |
|
515 } |
|
516 catch(bad_alloc&) |
|
517 { |
|
518 //do nothing |
|
519 } |
|
520 catch(...) |
|
521 { |
|
522 failures++; |
|
523 |
|
524 } |
|
525 |
|
526 if( failures == 0 ) |
|
527 return KErrNone; |
|
528 else |
|
529 return KErrGeneral; |
|
530 } |
|
531 |
|
532 |
|
533 // ----------------------------------------------------------------------------- |
|
534 // Ctiostreams:: ostream |
|
535 // Example test method function. |
|
536 // (other items were commented in a header). |
|
537 // ----------------------------------------------------------------------------- |
|
538 // |
|
539 |
|
540 TInt Ctiostreams::ostreamL(CStifItemParser& aItem ) |
|
541 |
|
542 { |
|
543 |
|
544 |
|
545 int failures = 0; |
|
546 try |
|
547 { |
|
548 |
|
549 |
|
550 filebuf fb; |
|
551 char input[17] = "ostream testcase"; |
|
552 streamsize size = 5; |
|
553 fb.open ("c:\\TestFramework\\docs\\ostream.txt",ios::out); |
|
554 cout<<""; |
|
555 #if STDCPP_OOM |
|
556 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
557 #endif |
|
558 ostream os(&fb); |
|
559 |
|
560 os.write(input,size); |
|
561 streamoff i = os.tellp(); |
|
562 if(i!= 5) |
|
563 failures++; |
|
564 |
|
565 os.put('K'); |
|
566 streamoff j = os.tellp(); |
|
567 if(j!=6) |
|
568 failures++; |
|
569 |
|
570 os.seekp(2); |
|
571 os<<"i"; |
|
572 streamoff k = os.tellp(); |
|
573 |
|
574 if(k!=3) |
|
575 failures++; |
|
576 |
|
577 os.flush(); |
|
578 |
|
579 #if STDCPP_OOM |
|
580 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
581 #endif |
|
582 |
|
583 |
|
584 /* |
|
585 if(failures) |
|
586 return KErrGeneral; |
|
587 return KErrNone; |
|
588 */ |
|
589 |
|
590 |
|
591 //#if STDCPP_OOM |
|
592 //failures++; |
|
593 // #endif |
|
594 } |
|
595 |
|
596 catch(bad_alloc&) |
|
597 { |
|
598 //do nothing |
|
599 } |
|
600 catch(...) |
|
601 { |
|
602 failures++; |
|
603 |
|
604 } |
|
605 |
|
606 if( failures == 0 ) |
|
607 return KErrNone; |
|
608 else |
|
609 return KErrGeneral; |
|
610 } |
|
611 |
|
612 // ----------------------------------------------------------------------------- |
|
613 // Ctiostreams:: istream |
|
614 // Example test method function. |
|
615 // (other items were commented in a header). |
|
616 // ----------------------------------------------------------------------------- |
|
617 // |
|
618 TInt Ctiostreams::istreamL(CStifItemParser& aItem ) |
|
619 { |
|
620 |
|
621 int failures =0; |
|
622 try |
|
623 { |
|
624 |
|
625 |
|
626 int length; |
|
627 char * buffer; |
|
628 char getl[8] ; |
|
629 filebuf fb; |
|
630 fb.open ("c:\\TestFramework\\docs\\istream.txt",ios::in); |
|
631 cout<<""; |
|
632 #if STDCPP_OOM |
|
633 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
634 #endif |
|
635 istream is(&fb); |
|
636 |
|
637 //needs to rewrite |
|
638 |
|
639 |
|
640 // get length of file: |
|
641 is.seekg (0, ios::end); |
|
642 length = is.tellg(); |
|
643 is.seekg (0, ios::beg); |
|
644 |
|
645 |
|
646 |
|
647 |
|
648 |
|
649 if(length != 7) |
|
650 failures++; |
|
651 |
|
652 char ch = is.get(); |
|
653 |
|
654 |
|
655 if(is.gcount() != 1) |
|
656 failures++; |
|
657 |
|
658 |
|
659 if( ch != 'S') |
|
660 failures++; |
|
661 |
|
662 |
|
663 |
|
664 |
|
665 |
|
666 |
|
667 |
|
668 char pk1 = is.peek(); |
|
669 |
|
670 if(pk1!= 'h') |
|
671 failures++; |
|
672 |
|
673 |
|
674 is.unget(); |
|
675 |
|
676 char pk2 = is.peek(); |
|
677 if(pk2!= 'S') |
|
678 failures++; |
|
679 |
|
680 is.get(); |
|
681 is.putback('K'); |
|
682 |
|
683 is.getline(getl,8,'\0'); |
|
684 |
|
685 if(getl == "Khaheen") |
|
686 failures++; |
|
687 |
|
688 if(is.gcount() != 7) |
|
689 failures++; |
|
690 |
|
691 |
|
692 fb.close(); |
|
693 /*if(failures) |
|
694 |
|
695 |
|
696 return KErrGeneral; |
|
697 return KErrNone; |
|
698 |
|
699 */ |
|
700 |
|
701 #if STDCPP_OOM |
|
702 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
703 #endif |
|
704 //#if STDCPP_OOM |
|
705 //failures++; |
|
706 // #endif |
|
707 |
|
708 } |
|
709 |
|
710 catch(bad_alloc&) |
|
711 { |
|
712 //do nothing |
|
713 } |
|
714 catch(...) |
|
715 { |
|
716 failures++; |
|
717 |
|
718 } |
|
719 |
|
720 if( failures == 0 ) |
|
721 return KErrNone; |
|
722 else |
|
723 return KErrGeneral; |
|
724 } |
|
725 |
|
726 // ----------------------------------------------------------------------------- |
|
727 // Ctiostreams:: istringstream |
|
728 // Example test method function. |
|
729 // (other items were commented in a header). |
|
730 // ----------------------------------------------------------------------------- |
|
731 // |
|
732 |
|
733 TInt Ctiostreams::istringstreamL(CStifItemParser& aItem ) |
|
734 { |
|
735 int n,val; |
|
736 int failures =0; |
|
737 try |
|
738 { |
|
739 string strvalues = "125 320 512 750 333"; |
|
740 cout<<""; |
|
741 #if STDCPP_OOM |
|
742 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
743 #endif |
|
744 |
|
745 istringstream iss (strvalues,istringstream::in); |
|
746 |
|
747 if(iss.str() != "125 320 512 750 333") |
|
748 failures++; |
|
749 |
|
750 #if STDCPP_OOM |
|
751 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
752 #endif |
|
753 for (n=0; n<5; n++) |
|
754 { |
|
755 iss >> val; |
|
756 switch(n) |
|
757 { |
|
758 case 0: |
|
759 if(val!=125) |
|
760 failures++; |
|
761 break; |
|
762 case 1: |
|
763 if(val!=320) |
|
764 failures++; |
|
765 break; |
|
766 case 2: |
|
767 if(val!=512) |
|
768 failures++; |
|
769 break; |
|
770 case 3: |
|
771 if(val!=750) |
|
772 failures++; |
|
773 break; |
|
774 |
|
775 case 4: |
|
776 if(val!=333) |
|
777 failures++; |
|
778 break; |
|
779 |
|
780 |
|
781 default: |
|
782 break; |
|
783 } |
|
784 |
|
785 } |
|
786 |
|
787 |
|
788 //#if STDCPP_OOM |
|
789 //failures++; |
|
790 // #endif |
|
791 |
|
792 /* if(failures) |
|
793 return KErrGeneral; |
|
794 else |
|
795 return KErrNone;*/ |
|
796 } |
|
797 |
|
798 catch(bad_alloc&) |
|
799 { |
|
800 //do nothing |
|
801 } |
|
802 catch(...) |
|
803 { |
|
804 failures++; |
|
805 |
|
806 } |
|
807 |
|
808 if( failures == 0 ) |
|
809 return KErrNone; |
|
810 else |
|
811 return KErrGeneral; |
|
812 } |
|
813 |
|
814 |
|
815 |
|
816 |
|
817 |
|
818 |
|
819 // ----------------------------------------------------------------------------- |
|
820 // Ctiostreams:: ostringstream, |
|
821 // Example test method function. |
|
822 // (other items were commented in a header). |
|
823 // ----------------------------------------------------------------------------- |
|
824 // |
|
825 |
|
826 TInt Ctiostreams::ostringstreamL(CStifItemParser& aItem ) |
|
827 { |
|
828 int failures =0 ; |
|
829 try |
|
830 { |
|
831 |
|
832 |
|
833 basic_string<char> i( "test" ); |
|
834 cout<<""; |
|
835 #if STDCPP_OOM |
|
836 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
837 #endif |
|
838 ostringstream ss; |
|
839 |
|
840 ss.rdbuf( )->str( i ); |
|
841 if(ss.str( ).compare("test") != 0) |
|
842 failures++; |
|
843 |
|
844 ss << "z"; |
|
845 if(ss.str( ) .compare("zest")!=0) |
|
846 failures++; |
|
847 |
|
848 ss.rdbuf( )->str( "be" ); |
|
849 if(ss.str( ).compare("be")!=0) |
|
850 failures++; |
|
851 |
|
852 #if STDCPP_OOM |
|
853 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
854 #endif |
|
855 /* |
|
856 if(failures) |
|
857 |
|
858 return KErrGeneral; |
|
859 else |
|
860 return KErrNone; |
|
861 */ |
|
862 |
|
863 |
|
864 |
|
865 //#if STDCPP_OOM |
|
866 //failures++; |
|
867 // #endif |
|
868 } |
|
869 |
|
870 catch(bad_alloc&) |
|
871 { |
|
872 //do nothing |
|
873 } |
|
874 catch(...) |
|
875 { |
|
876 failures++; |
|
877 |
|
878 } |
|
879 |
|
880 if( failures == 0 ) |
|
881 return KErrNone; |
|
882 else |
|
883 return KErrGeneral; |
|
884 } |
|
885 |
|
886 TInt Ctiostreams::ostreamiterators(CStifItemParser& aItem ) |
|
887 { |
|
888 |
|
889 |
|
890 //needs to rewrite |
|
891 //____________________ |
|
892 |
|
893 int arr[4] = { 3,4,7,8 }; |
|
894 int total=0; |
|
895 deque<int> d(arr+0, arr+4); |
|
896 // |
|
897 // stream the whole vector and a sum to cout |
|
898 // |
|
899 |
|
900 copy(d.begin(),(d.end()-1),ostream_iterator<int,char>(cout,"")); |
|
901 |
|
902 |
|
903 if( *(d.end()-1) == 8) |
|
904 return KErrNone; |
|
905 return KErrGeneral; |
|
906 |
|
907 |
|
908 } |
|
909 |
|
910 |
|
911 |
|
912 // ----------------------------------------------------------------------------- |
|
913 // Ctiostreams:: fstream |
|
914 // Example test method function. |
|
915 // (other items were commented in a header). |
|
916 // ----------------------------------------------------------------------------- |
|
917 // |
|
918 |
|
919 |
|
920 TInt Ctiostreams::fstreamL(CStifItemParser& aItem ) |
|
921 { |
|
922 // __UHEAP_MARK; |
|
923 int failures =0; |
|
924 try |
|
925 { |
|
926 cout<<""; |
|
927 #if STDCPP_OOM |
|
928 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
929 #endif |
|
930 fstream filestr ("c:\\TestFramework\\docs\\fstream.txt", fstream::in | fstream::out); |
|
931 |
|
932 if(!filestr.is_open()) |
|
933 failures++; |
|
934 |
|
935 filestr.close(); |
|
936 if(filestr.is_open()) |
|
937 failures++; |
|
938 |
|
939 // __UHEAP_MARKEND; |
|
940 |
|
941 /*if(failures) |
|
942 return KErrNone; |
|
943 return KErrGeneral; |
|
944 */ |
|
945 #if STDCPP_OOM |
|
946 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
947 #endif |
|
948 //#if STDCPP_OOM |
|
949 //failures++; |
|
950 // #endif |
|
951 |
|
952 } |
|
953 catch(bad_alloc&) |
|
954 { |
|
955 //do nothing |
|
956 } |
|
957 catch(...) |
|
958 { |
|
959 failures++; |
|
960 |
|
961 } |
|
962 |
|
963 if( failures == 0 ) |
|
964 return KErrNone; |
|
965 else |
|
966 return KErrGeneral; |
|
967 } |
|
968 |
|
969 // ----------------------------------------------------------------------------- |
|
970 // Ctiostreams:: istrstream |
|
971 // Example test method function. |
|
972 // (other items were commented in a header). |
|
973 // ----------------------------------------------------------------------------- |
|
974 // |
|
975 TInt Ctiostreams::istrstreamL(CStifItemParser& aItem ) |
|
976 { |
|
977 // __UHEAP_MARK; |
|
978 int failures=0; |
|
979 try |
|
980 { |
|
981 |
|
982 |
|
983 char* p = "This is first string"; |
|
984 char* q = "This is second string"; |
|
985 char* r = ""; |
|
986 const char* s ="const char"; |
|
987 streamsize n =10; |
|
988 cout<<""; |
|
989 #if STDCPP_OOM |
|
990 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
991 #endif |
|
992 istrstream first(p); |
|
993 istrstream second(q); |
|
994 istrstream third(r); |
|
995 |
|
996 istrstream four(s); |
|
997 |
|
998 istrstream five(p,n); |
|
999 istrstream six(s,n); |
|
1000 /* if(first.str() == "This is first string") |
|
1001 if(second.str()!= " This is second string") |
|
1002 if(third.str() == "") |
|
1003 // __UHEAP_MARKEND; |
|
1004 |
|
1005 return KErrNone; |
|
1006 return KErrGeneral; |
|
1007 */ |
|
1008 first.rdbuf(); |
|
1009 second.rdbuf(); |
|
1010 third.rdbuf(); |
|
1011 |
|
1012 if(first.str() != "This is first string") |
|
1013 if(second.str()== " This is second string") |
|
1014 if(third.str() != "") |
|
1015 failures++; |
|
1016 |
|
1017 #if STDCPP_OOM |
|
1018 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
1019 #endif |
|
1020 //#if STDCPP_OOM |
|
1021 //failures++; |
|
1022 // #endif |
|
1023 |
|
1024 } |
|
1025 |
|
1026 |
|
1027 catch(bad_alloc&) |
|
1028 { |
|
1029 //do nothing |
|
1030 } |
|
1031 catch(...) |
|
1032 { |
|
1033 failures++; |
|
1034 |
|
1035 } |
|
1036 |
|
1037 if( failures == 0 ) |
|
1038 return KErrNone; |
|
1039 else |
|
1040 return KErrGeneral; |
|
1041 } |
|
1042 |
|
1043 TInt Ctiostreams::strstreamL(CStifItemParser& aItem ) |
|
1044 { |
|
1045 // __UHEAP_MARK; |
|
1046 |
|
1047 int failures = 0; |
|
1048 try |
|
1049 { |
|
1050 cout<<""; |
|
1051 #if STDCPP_OOM |
|
1052 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
1053 #endif |
|
1054 char* s; |
|
1055 int n; |
|
1056 ios_base::openmode mode; |
|
1057 // strstream ss3(s, n, mode); |
|
1058 strstream ss1,ss2; |
|
1059 ss1 << ""; |
|
1060 ss1.rdbuf(); |
|
1061 if(ss1.rdbuf( )->pcount( ) != 0) |
|
1062 failures++; |
|
1063 |
|
1064 string str1= ss1.str(); |
|
1065 if(str1.compare("")!=0) |
|
1066 failures++; |
|
1067 |
|
1068 ss2 << "strstream testcase"; |
|
1069 ss2 << '\0'; |
|
1070 if( ss2.rdbuf( )->pcount( ) != sizeof("strstream testcase\0")-1) |
|
1071 failures++; |
|
1072 |
|
1073 string str = ss2.str(); |
|
1074 |
|
1075 if(str.compare("strstream testcase")!= 0) |
|
1076 failures++; |
|
1077 ss1.freeze(); |
|
1078 //__UHEAP_MARKEND; |
|
1079 /* |
|
1080 if(failures) |
|
1081 return KErrGeneral; |
|
1082 else |
|
1083 return KErrNone; |
|
1084 */ |
|
1085 |
|
1086 |
|
1087 #if STDCPP_OOM |
|
1088 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
1089 #endif |
|
1090 |
|
1091 //#if STDCPP_OOM |
|
1092 //failures++; |
|
1093 // #endif |
|
1094 } |
|
1095 |
|
1096 catch(bad_alloc&) |
|
1097 { |
|
1098 //do nothing |
|
1099 } |
|
1100 catch(...) |
|
1101 { |
|
1102 failures++; |
|
1103 |
|
1104 } |
|
1105 |
|
1106 if( failures == 0 ) |
|
1107 return KErrNone; |
|
1108 else |
|
1109 return KErrGeneral; |
|
1110 } |
|
1111 |
|
1112 |
|
1113 TInt Ctiostreams::ostrstreamL(CStifItemParser& aItem ) |
|
1114 { |
|
1115 |
|
1116 //__UHEAP_MARK; |
|
1117 int failures = 0; |
|
1118 try |
|
1119 { |
|
1120 cout<<""; |
|
1121 #if STDCPP_OOM |
|
1122 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
1123 #endif |
|
1124 char* s; |
|
1125 int n; |
|
1126 ios_base::openmode mode; |
|
1127 // ostrstream oss3( s, n, mode); |
|
1128 ostrstream oss1 ,oss2; |
|
1129 string str; |
|
1130 oss1 << ""; |
|
1131 oss1.rdbuf(); |
|
1132 if(oss1.rdbuf( )->pcount( ) != 0) |
|
1133 failures++; |
|
1134 |
|
1135 oss2 << "ostrstream testcase"; |
|
1136 oss2<<'\0'; |
|
1137 str = oss2.str(); |
|
1138 |
|
1139 if(str.compare("ostrstream testcase") !=0) |
|
1140 failures++; |
|
1141 |
|
1142 oss2.freeze(); |
|
1143 |
|
1144 #if STDCPP_OOM |
|
1145 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
1146 #endif |
|
1147 |
|
1148 // __UHEAP_MARKEND; |
|
1149 /* |
|
1150 if(failures) |
|
1151 return KErrGeneral; |
|
1152 else |
|
1153 return KErrNone; |
|
1154 */ |
|
1155 |
|
1156 //#if STDCPP_OOM |
|
1157 //failures++; |
|
1158 // #endif |
|
1159 } |
|
1160 |
|
1161 catch(bad_alloc&) |
|
1162 { |
|
1163 //do nothing |
|
1164 } |
|
1165 catch(...) |
|
1166 { |
|
1167 failures++; |
|
1168 |
|
1169 } |
|
1170 |
|
1171 if( failures == 0 ) |
|
1172 return KErrNone; |
|
1173 else |
|
1174 return KErrGeneral; |
|
1175 } |
|
1176 |
|
1177 |
|
1178 |
|
1179 TInt Ctiostreams::istreamiterators(CStifItemParser& aItem ) |
|
1180 { |
|
1181 |
|
1182 // __UHEAP_MARK; |
|
1183 // Typedefs for convenience. |
|
1184 int failures=0; |
|
1185 try |
|
1186 { |
|
1187 cout<<""; |
|
1188 #if STDCPP_OOM |
|
1189 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
1190 #endif |
|
1191 |
|
1192 typedef std::vector<int, std::allocator<int> > Vector; |
|
1193 |
|
1194 typedef std::istream_iterator<Vector::value_type,char, std::char_traits<char>, ptrdiff_t> is_iter; |
|
1195 |
|
1196 #if STDCPP_OOM |
|
1197 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
1198 #endif |
|
1199 Vector v; |
|
1200 //__UHEAP_MARKEND; |
|
1201 |
|
1202 //#if STDCPP_OOM |
|
1203 //failures++; |
|
1204 // #endif |
|
1205 |
|
1206 |
|
1207 |
|
1208 } |
|
1209 |
|
1210 |
|
1211 catch(bad_alloc&) |
|
1212 { |
|
1213 //do nothing |
|
1214 } |
|
1215 catch(...) |
|
1216 { |
|
1217 failures++; |
|
1218 |
|
1219 } |
|
1220 |
|
1221 if( failures == 0 ) |
|
1222 return KErrNone; |
|
1223 else |
|
1224 return KErrGeneral; |
|
1225 } |
|
1226 |
|
1227 |
|
1228 TInt Ctiostreams::istreambufiterators(CStifItemParser& aItem ) |
|
1229 { |
|
1230 |
|
1231 |
|
1232 // __UHEAP_MARK; |
|
1233 // create a temporary filename |
|
1234 |
|
1235 int failures=0; |
|
1236 try |
|
1237 { |
|
1238 |
|
1239 |
|
1240 const char *fname = tmpnam (0); |
|
1241 |
|
1242 if (!fname) |
|
1243 return 1; |
|
1244 |
|
1245 // open the file is_iter.out for reading and writing |
|
1246 std::ofstream out (fname, std::ios::out | std::ios::in | |
|
1247 std::ios::trunc); |
|
1248 |
|
1249 // output the example sentence into the file |
|
1250 |
|
1251 // seek to the beginning of the file |
|
1252 out.seekp (0); |
|
1253 cout<<""; |
|
1254 #if STDCPP_OOM |
|
1255 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
1256 #endif |
|
1257 // construct an istreambuf_iterator pointing to |
|
1258 // the ofstream object underlying streambuffer |
|
1259 std::istreambuf_iterator<char, std::char_traits<char> >iter (out.rdbuf ()); |
|
1260 |
|
1261 // construct an end of stream iterator |
|
1262 const std::istreambuf_iterator<char,std::char_traits<char> > end; |
|
1263 #if STDCPP_OOM |
|
1264 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
1265 #endif |
|
1266 std::cout << std::endl; |
|
1267 |
|
1268 // output the content of the file |
|
1269 while (!iter.equal (end)) { |
|
1270 |
|
1271 // use both operator++ and operator* |
|
1272 std::cout << *iter++; |
|
1273 } |
|
1274 |
|
1275 std::cout << std::endl; |
|
1276 |
|
1277 // remove temporary file |
|
1278 remove (fname); |
|
1279 //__UHEAP_MARKEND; |
|
1280 |
|
1281 //#if STDCPP_OOM |
|
1282 //failures++; |
|
1283 // #endif |
|
1284 |
|
1285 } |
|
1286 |
|
1287 catch(bad_alloc&) |
|
1288 { |
|
1289 //do nothing |
|
1290 } |
|
1291 catch(...) |
|
1292 { |
|
1293 failures++; |
|
1294 |
|
1295 } |
|
1296 |
|
1297 if( failures == 0 ) |
|
1298 return KErrNone; |
|
1299 else |
|
1300 return KErrGeneral; |
|
1301 } |
|
1302 |
|
1303 |
|
1304 |
|
1305 TInt Ctiostreams::strstreambufL(CStifItemParser& aItem ) |
|
1306 |
|
1307 |
|
1308 { |
|
1309 // __UHEAP_MARK; |
|
1310 |
|
1311 int failures =0; |
|
1312 try |
|
1313 { |
|
1314 |
|
1315 cout<<""; |
|
1316 |
|
1317 #if STDCPP_OOM |
|
1318 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
1319 #endif |
|
1320 |
|
1321 signed char* get; |
|
1322 streamsize n=10; |
|
1323 signed char* put; |
|
1324 unsigned char* uget; |
|
1325 unsigned char* uput; |
|
1326 const char* cget; |
|
1327 const signed char* csget; |
|
1328 |
|
1329 const unsigned char* cucget; |
|
1330 |
|
1331 |
|
1332 typedef void* (*__alloc_fn)(size_t); |
|
1333 typedef void (*__free_fn)(void*); |
|
1334 |
|
1335 __alloc_fn alloc_f; |
|
1336 |
|
1337 __free_fn free_f; |
|
1338 |
|
1339 //overloaded |
|
1340 strstreambuf buf1(get, n,put); |
|
1341 |
|
1342 //overloaded |
|
1343 |
|
1344 strstreambuf buf2(uget,n,uput); |
|
1345 |
|
1346 //overloaded |
|
1347 strstreambuf buf3(cget,n); |
|
1348 //onverloaded |
|
1349 strstreambuf buf4(csget,n); |
|
1350 //overloaded |
|
1351 strstreambuf buf5(cucget,n); |
|
1352 |
|
1353 |
|
1354 // strstreambuf buf6( alloc_f, free_f); |
|
1355 strstreambuf buf7(n); |
|
1356 |
|
1357 strstreambuf buf; |
|
1358 string str; |
|
1359 int i = buf.sputn("strstreambuf testcase", sizeof("strstreambuf testcase")-1); |
|
1360 |
|
1361 if((buf.pcount())!= i) |
|
1362 failures++; |
|
1363 |
|
1364 buf.freeze(); |
|
1365 //if(buf.str() != "strstreambuf testcase") //fails |
|
1366 //failures++; |
|
1367 |
|
1368 #if STDCPP_OOM |
|
1369 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
1370 #endif |
|
1371 |
|
1372 //__UHEAP_MARKEND; |
|
1373 /*if(failures) |
|
1374 return KErrGeneral; |
|
1375 else |
|
1376 return KErrNone; |
|
1377 */ |
|
1378 |
|
1379 //#if STDCPP_OOM |
|
1380 //failures++; |
|
1381 // #endif |
|
1382 |
|
1383 } |
|
1384 catch(bad_alloc&) |
|
1385 { |
|
1386 //do nothing |
|
1387 } |
|
1388 catch(...) |
|
1389 { |
|
1390 failures++; |
|
1391 |
|
1392 } |
|
1393 |
|
1394 if( failures == 0 ) |
|
1395 return KErrNone; |
|
1396 else |
|
1397 return KErrGeneral; |
|
1398 } |
|
1399 |
|
1400 |
|
1401 |
|
1402 |
|
1403 TInt Ctiostreams::freezeL(CStifItemParser& aItem ) |
|
1404 { |
|
1405 |
|
1406 int failures=0; |
|
1407 try |
|
1408 { |
|
1409 |
|
1410 strstream x; |
|
1411 int failures =0; |
|
1412 x << "test1"; |
|
1413 |
|
1414 if(!x.good()) |
|
1415 failures++; |
|
1416 cout<<""; |
|
1417 |
|
1418 #if STDCPP_OOM |
|
1419 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
1420 #endif |
|
1421 |
|
1422 x.rdbuf()->freeze(); |
|
1423 #if STDCPP_OOM |
|
1424 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
1425 #endif |
|
1426 if(!x.good()) |
|
1427 failures++; |
|
1428 |
|
1429 // Stream is bad now, wrote on frozen stream |
|
1430 x << "test1.5"; |
|
1431 |
|
1432 // report(x); |
|
1433 if(!x.good()) |
|
1434 failures++; |
|
1435 // Unfreeze stream, but it is still bad |
|
1436 x.rdbuf()->freeze(false); |
|
1437 if(!x.good()) |
|
1438 failures++; |
|
1439 |
|
1440 // Clear stream |
|
1441 x.clear(); |
|
1442 |
|
1443 if(!x.good()) |
|
1444 failures++; |
|
1445 |
|
1446 |
|
1447 x << "test3"; |
|
1448 |
|
1449 |
|
1450 |
|
1451 |
|
1452 // Clean up. Failure to unfreeze stream will cause a |
|
1453 // memory leak. |
|
1454 x.rdbuf()->freeze(false); |
|
1455 /* |
|
1456 if(failures) |
|
1457 return KErrGeneral; |
|
1458 else |
|
1459 return KErrNone; |
|
1460 |
|
1461 */ |
|
1462 |
|
1463 //#if STDCPP_OOM |
|
1464 //failures++; |
|
1465 // #endif |
|
1466 } |
|
1467 |
|
1468 |
|
1469 |
|
1470 catch(bad_alloc&) |
|
1471 { |
|
1472 //do nothing |
|
1473 } |
|
1474 catch(...) |
|
1475 { |
|
1476 failures++; |
|
1477 |
|
1478 } |
|
1479 |
|
1480 if( failures == 0 ) |
|
1481 return KErrNone; |
|
1482 else |
|
1483 return KErrGeneral; |
|
1484 } |
|
1485 |
|
1486 |
|
1487 TInt Ctiostreams::fposL(CStifItemParser& aItem ) |
|
1488 { |
|
1489 int failures=0; |
|
1490 try |
|
1491 { |
|
1492 |
|
1493 |
|
1494 streamoff s; |
|
1495 ifstream file( "c:\\TestFramework\\docs\\fpos_state.txt" ); |
|
1496 cout<<""; |
|
1497 #if STDCPP_OOM |
|
1498 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
1499 #endif |
|
1500 fpos<mbstate_t> f = file.tellg( ); |
|
1501 char ch; |
|
1502 while ( !file.eof( ) ) |
|
1503 file.get( ch ); |
|
1504 |
|
1505 f.state(); |
|
1506 cout<<""; |
|
1507 #if STDCPP_OOM |
|
1508 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
1509 #endif |
|
1510 //s = f; |
|
1511 // if(f.state( )) |
|
1512 // failures++; |
|
1513 // f.state( 9 ); |
|
1514 // if( f.state( )) |
|
1515 // failures++; |
|
1516 /*if(failures) |
|
1517 return KErrGeneral; |
|
1518 return KErrNone;*/ |
|
1519 |
|
1520 //#if STDCPP_OOM |
|
1521 //failures++; |
|
1522 // #endif |
|
1523 } |
|
1524 |
|
1525 catch(bad_alloc&) |
|
1526 { |
|
1527 //do nothing |
|
1528 } |
|
1529 catch(...) |
|
1530 { |
|
1531 failures++; |
|
1532 |
|
1533 } |
|
1534 |
|
1535 if( failures == 0 ) |
|
1536 return KErrNone; |
|
1537 else |
|
1538 return KErrGeneral; |
|
1539 } |
|
1540 |
|
1541 |
|
1542 |
|
1543 |
|
1544 // ----------------------------------------------------------------------------- |
|
1545 // Cstdcpp_filebuf::filebufL |
|
1546 // Example test method function. |
|
1547 // (other items were commented in a header). |
|
1548 // ----------------------------------------------------------------------------- |
|
1549 // |
|
1550 TInt Ctiostreams::filebufL( CStifItemParser& aItem ) |
|
1551 { |
|
1552 int failures=0; |
|
1553 try |
|
1554 { |
|
1555 |
|
1556 |
|
1557 |
|
1558 ifstream is; |
|
1559 cout<<""; |
|
1560 #if STDCPP_OOM |
|
1561 User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); |
|
1562 #endif |
|
1563 filebuf * fb; |
|
1564 |
|
1565 fb = is.rdbuf(); |
|
1566 fb->open ("c:\\TestFramework\\docs\\filebuf.txt",ios::in); |
|
1567 |
|
1568 if(!fb->is_open()) |
|
1569 failures++; |
|
1570 |
|
1571 |
|
1572 fb->close(); |
|
1573 if(fb->is_open()) |
|
1574 failures++; |
|
1575 |
|
1576 |
|
1577 #if STDCPP_OOM |
|
1578 User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); |
|
1579 #endif |
|
1580 /* |
|
1581 if(failures) |
|
1582 return KErrGeneral; |
|
1583 return KErrNone; |
|
1584 */ |
|
1585 |
|
1586 //#if STDCPP_OOM |
|
1587 //failures++; |
|
1588 // #endif |
|
1589 |
|
1590 } |
|
1591 |
|
1592 catch(bad_alloc&) |
|
1593 { |
|
1594 //do nothing |
|
1595 } |
|
1596 catch(...) |
|
1597 { |
|
1598 failures++; |
|
1599 |
|
1600 } |
|
1601 |
|
1602 if( failures == 0 ) |
|
1603 return KErrNone; |
|
1604 else |
|
1605 return KErrGeneral; |
|
1606 } |
|
1607 |
|
1608 |
|
1609 TInt Ctiostreams::seekpL( CStifItemParser& aItem ) |
|
1610 { |
|
1611 |
|
1612 ostringstream oss2; |
|
1613 |
|
1614 oss2<<"Do me a favor"; |
|
1615 long pos2 = oss2.tellp(); // 13 |
|
1616 |
|
1617 oss2 << "pp"; |
|
1618 pos2 = oss2.tellp(); // 15 |
|
1619 oss2.seekp(pos2 - 2); |
|
1620 pos2 = oss2.tellp(); // 13 |
|
1621 string temp = "ss"; |
|
1622 oss2.write(temp.c_str(), temp.size()); |
|
1623 pos2 = oss2.tellp(); // 15 |
|
1624 oss2.seekp(pos2 - 2); |
|
1625 pos2 = oss2.tellp(); // 13 |
|
1626 oss2 << "ss"; |
|
1627 pos2 = oss2.tellp(); // 15 |
|
1628 oss2.seekp(pos2 - 2); |
|
1629 pos2 = oss2.tellp(); // 13 |
|
1630 oss2 << "ss"; |
|
1631 |
|
1632 pos2 = oss2.tellp(); |
|
1633 |
|
1634 oss2.seekp(pos2 - 2); |
|
1635 pos2 = oss2.tellp(); |
|
1636 oss2 << "pp"; |
|
1637 pos2 = oss2.tellp(); //15 |
|
1638 |
|
1639 oss2.seekp(pos2 - 5); |
|
1640 pos2 = oss2.tellp(); |
|
1641 oss2 << "pppp"; |
|
1642 pos2 = oss2.tellp(); //14 |
|
1643 oss2.seekp(pos2 - 3); |
|
1644 pos2 = oss2.tellp(); |
|
1645 oss2 << "ppp"; |
|
1646 pos2 = oss2.tellp(); //14 |
|
1647 oss2 << "pppppp"; |
|
1648 pos2 = oss2.tellp(); //20 |
|
1649 |
|
1650 |
|
1651 if( pos2 == 20 ) |
|
1652 return KErrNone; |
|
1653 else |
|
1654 return KErrGeneral; |
|
1655 } |
|
1656 |
|
1657 |
|
1658 |
|
1659 // End of File |