31
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// STLport regression testsuite component.
|
|
19 |
// To compile as a separate example, please #define MAIN.
|
|
20 |
#include <vector>
|
|
21 |
#include <algorithm>
|
|
22 |
#include <iostream>
|
|
23 |
|
|
24 |
|
|
25 |
#ifdef MAIN
|
|
26 |
#define alg4_test main
|
|
27 |
#endif
|
|
28 |
|
|
29 |
#if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
|
|
30 |
using namespace std;
|
|
31 |
#endif
|
|
32 |
int alg4_test(int, char**)
|
|
33 |
{
|
|
34 |
|
|
35 |
cout<<"Results of alg4_test:"<<endl;
|
|
36 |
// for comparison of results
|
|
37 |
int res_arr[4] = {1962, 1992, 1999, 2001};
|
|
38 |
int failures =0;
|
|
39 |
|
|
40 |
vector<int> years;
|
|
41 |
years.push_back(1962);
|
|
42 |
years.push_back(1992);
|
|
43 |
years.push_back(2001);
|
|
44 |
years.push_back(1999);
|
|
45 |
sort(years.begin(), years.end());
|
|
46 |
vector<int>::const_iterator i;
|
|
47 |
int j;
|
|
48 |
for(i = years.begin(), j =0; i != years.end(); i++, j++)
|
|
49 |
{
|
|
50 |
cout << *i << endl;
|
|
51 |
if( *i != res_arr[j])
|
|
52 |
failures++;
|
|
53 |
}
|
|
54 |
|
|
55 |
if (!failures)
|
|
56 |
return 0;
|
|
57 |
else
|
|
58 |
return 1;
|
|
59 |
}
|