31
|
1 |
|
|
2 |
// STLport regression testsuite component.
|
|
3 |
// To compile as a separate example, please #define MAIN.
|
|
4 |
#include <iterator>
|
|
5 |
|
|
6 |
#include <vector>
|
|
7 |
#include <algorithm>
|
|
8 |
#include <iostream>
|
|
9 |
#include <iterator>
|
|
10 |
#include <functional>
|
|
11 |
#include <numeric>
|
|
12 |
|
|
13 |
#ifdef MAIN
|
|
14 |
#define partsum2_test main
|
|
15 |
#endif
|
|
16 |
|
|
17 |
#if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
|
|
18 |
using namespace std;
|
|
19 |
#endif
|
|
20 |
int partsum2_test(int, char**)
|
|
21 |
{
|
|
22 |
|
|
23 |
int failures=0;
|
|
24 |
cout<<"Results of partsum2_test:"<<endl;
|
|
25 |
vector <int> v1(5);
|
|
26 |
iota(v1.begin(), v1.end(), 1);
|
|
27 |
vector <int> v2(v1.size());
|
|
28 |
partial_sum(v1.begin(), v1.end(), v2.begin(), multiplies<int>());
|
|
29 |
ostream_iterator <int> iter(cout, " ");
|
|
30 |
copy(v1.begin(), v1.end(), iter);
|
|
31 |
cout << endl;
|
|
32 |
|
|
33 |
if(1 !=v1[0])
|
|
34 |
failures++;
|
|
35 |
else if(2 !=v1[1])
|
|
36 |
failures++;
|
|
37 |
else if(2 !=v1[2])
|
|
38 |
failures++;
|
|
39 |
else if(2 !=v1[3])
|
|
40 |
failures++;
|
|
41 |
else if(2 !=v1[4])
|
|
42 |
failures++;
|
|
43 |
|
|
44 |
copy(v2.begin(), v2.end(), iter);
|
|
45 |
cout << endl;
|
|
46 |
|
|
47 |
if(1 !=v2[0])
|
|
48 |
failures++;
|
|
49 |
else if(2 !=v2[1])
|
|
50 |
failures++;
|
|
51 |
else if(6 !=v2[2])
|
|
52 |
failures++;
|
|
53 |
else if(24 !=v2[3])
|
|
54 |
failures++;
|
|
55 |
else if(120!=v2[4])
|
|
56 |
failures++;
|
|
57 |
|
|
58 |
return 0;
|
|
59 |
}
|
|
60 |
|