31
|
1 |
|
|
2 |
|
|
3 |
// STLport regression testsuite component.
|
|
4 |
// To compile as a separate example, please #define MAIN.
|
|
5 |
|
|
6 |
#include <algorithm>
|
|
7 |
#include <iostream>
|
|
8 |
|
|
9 |
#include "fadapter.h"
|
|
10 |
|
|
11 |
#ifdef MAIN
|
|
12 |
#define foreach0_test main
|
|
13 |
#endif
|
|
14 |
|
|
15 |
#if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
|
|
16 |
using namespace std;
|
|
17 |
#endif
|
|
18 |
static void print(int a_)
|
|
19 |
{
|
|
20 |
cout << a_ << ' ';
|
|
21 |
}
|
|
22 |
|
|
23 |
int foreach0_test(int, char**)
|
|
24 |
{
|
|
25 |
|
|
26 |
cout<<"Results of foreach0_test:"<<endl;
|
|
27 |
int failures = 0;
|
|
28 |
|
|
29 |
int numbers[10] = { 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 };
|
|
30 |
|
|
31 |
for_each(numbers, numbers + 10, ptr_proc(print));
|
|
32 |
cout << endl;
|
|
33 |
if(numbers[0] != 1)
|
|
34 |
failures++;
|
|
35 |
if(numbers[1] != 1)
|
|
36 |
failures++;
|
|
37 |
if(numbers[2] != 2)
|
|
38 |
failures++;
|
|
39 |
if(numbers[3] != 3)
|
|
40 |
failures++;
|
|
41 |
if(numbers[4] != 5)
|
|
42 |
failures++;
|
|
43 |
if(numbers[5] != 8)
|
|
44 |
failures++;
|
|
45 |
if(numbers[6] != 13)
|
|
46 |
failures++;
|
|
47 |
if(numbers[7] != 21)
|
|
48 |
failures++;
|
|
49 |
if(numbers[8] != 34)
|
|
50 |
failures++;
|
|
51 |
if(numbers[9] != 55)
|
|
52 |
failures++;
|
|
53 |
return failures;
|
|
54 |
}
|