31
|
1 |
|
|
2 |
// STLport regression testsuite component.
|
|
3 |
// To compile as a separate example, please #define MAIN.
|
|
4 |
|
|
5 |
#include <iostream>
|
|
6 |
#include <algorithm>
|
|
7 |
#include <iterator>
|
|
8 |
#include <functional>
|
|
9 |
|
|
10 |
#ifdef MAIN
|
|
11 |
#define ptrbinf1_test main
|
|
12 |
#endif
|
|
13 |
static int sum(int x_, int y_)
|
|
14 |
{
|
|
15 |
return x_ + y_;
|
|
16 |
}
|
|
17 |
|
|
18 |
#if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
|
|
19 |
using namespace std;
|
|
20 |
#endif
|
|
21 |
int ptrbinf1_test(int, char**)
|
|
22 |
{
|
|
23 |
int failures=0;
|
|
24 |
cout<<"Results of ptrbinf1_test:"<<endl;
|
|
25 |
|
|
26 |
int input1 [4] = { 7, 2, 3, 5 };
|
|
27 |
int input2 [4] = { 1, 5, 5, 8 };
|
|
28 |
|
|
29 |
int output [4];
|
|
30 |
transform((int*)input1, (int*)input1 + 4, (int*)input2, (int*)output,
|
|
31 |
pointer_to_binary_function<int, int, int>(sum));
|
|
32 |
for(int i = 0; i < 4; i++)
|
|
33 |
cout << output[i] << endl;
|
|
34 |
|
|
35 |
if(8!=output[0])
|
|
36 |
failures++;
|
|
37 |
else if(7!=output[1])
|
|
38 |
failures++;
|
|
39 |
else if(8!=output[2])
|
|
40 |
failures++;
|
|
41 |
else if(13!=output[3])
|
|
42 |
failures++;
|
|
43 |
|
|
44 |
if(failures)
|
|
45 |
return 1;
|
|
46 |
else
|
|
47 |
return 0;
|
|
48 |
}
|
|
49 |
|