equal
deleted
inserted
replaced
|
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 // STLport regression testsuite component. |
|
20 // To compile as a separate example, please #define MAIN. |
|
21 |
|
22 #include <vector> |
|
23 #include <algorithm> |
|
24 #include <iostream> |
|
25 #include <fstream> |
|
26 |
|
27 #include "fadapter.h" |
|
28 |
|
29 #define LOG_FILENAME_LINE __FILE__, __LINE__ |
|
30 extern void std_log(const char *filename,const int lineno,const char* aformat,...); |
|
31 |
|
32 #ifdef MAIN |
|
33 #define foreach1_test main |
|
34 #endif |
|
35 |
|
36 #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES) |
|
37 using namespace std; |
|
38 #endif |
|
39 |
|
40 int array[10],j=0; |
|
41 static void print_sqr(int a_) |
|
42 { |
|
43 |
|
44 cout << a_ * a_ << " "; |
|
45 array[j++] = a_ * a_; |
|
46 } |
|
47 |
|
48 int foreach1_test(int, char**) |
|
49 { |
|
50 |
|
51 vector <int> v1(10); |
|
52 int failures = 0; |
|
53 |
|
54 for(int i = 0; i < v1.size(); i++) |
|
55 v1[i] = i; |
|
56 for_each(v1.begin(), v1.end(), ptr_proc(print_sqr) ); |
|
57 cout << endl; |
|
58 |
|
59 |
|
60 if(array[0] != 0) |
|
61 failures++; |
|
62 if(array[1] != 1) |
|
63 failures++; |
|
64 if(array[2] != 4) |
|
65 failures++; |
|
66 if(array[3] != 9) |
|
67 failures++; |
|
68 if(array[4] != 16) |
|
69 failures++; |
|
70 if(array[5] != 25) |
|
71 failures++; |
|
72 if(array[6] != 36) |
|
73 failures++; |
|
74 if(array[7] != 49) |
|
75 failures++; |
|
76 if(array[8] != 64) |
|
77 failures++; |
|
78 if(array[9] != 81) |
|
79 failures++; |
|
80 |
|
81 return failures; |
|
82 } |