equal
deleted
inserted
replaced
|
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 ptrbinf2_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 ptrbinf2_test(int, char**) |
|
22 { |
|
23 |
|
24 int failures=0; |
|
25 cout<<"Results of ptrbinf2_test:"<<endl; |
|
26 |
|
27 int input1 [4] = { 7, 2, 3, 5 }; |
|
28 int input2 [4] = { 1, 5, 5, 8 }; |
|
29 |
|
30 int output [4]; |
|
31 transform((int*)input1, (int*)input1 + 4, (int*)input2, (int*)output, ptr_fun(sum)); |
|
32 for(int i = 0; i < 4; i++) |
|
33 cout << output[i] << endl; |
|
34 |
|
35 |
|
36 if(8!=output[0]) |
|
37 failures++; |
|
38 else if(7!=output[1]) |
|
39 failures++; |
|
40 else if(8!=output[2]) |
|
41 failures++; |
|
42 else if(13!=output[3]) |
|
43 failures++; |
|
44 |
|
45 if(failures) |
|
46 return 1; |
|
47 else |
|
48 return 0; |
|
49 } |