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