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