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