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 |
|
|
19 |
// STLport regression testsuite component.
|
|
20 |
// To compile as a separate example, please #define MAIN.
|
|
21 |
|
|
22 |
#include <deque>
|
|
23 |
#include <algorithm>
|
|
24 |
#include <iostream>
|
|
25 |
|
|
26 |
|
|
27 |
#ifdef MAIN
|
|
28 |
#define deque1_test main
|
|
29 |
#endif
|
|
30 |
|
|
31 |
#if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
|
|
32 |
using namespace std;
|
|
33 |
#endif
|
|
34 |
|
|
35 |
int deque1_test(int, char**)
|
|
36 |
{
|
|
37 |
cout<<"Results of deque1_test:"<<endl;
|
|
38 |
|
|
39 |
int failures = 0;
|
|
40 |
int res_arr[4] = {1, 4, 9, 16};
|
|
41 |
deque<int> d;
|
|
42 |
d.push_back(4); // Add after end.
|
|
43 |
d.push_back(9);
|
|
44 |
d.push_back(16);
|
|
45 |
d.push_front(1); // Insert at beginning.
|
|
46 |
int i;
|
|
47 |
for(i = 0; i < d.size(); i++)
|
|
48 |
{
|
|
49 |
cout << "d[" << i << "] = " << d[i] << endl;
|
|
50 |
if (d[i] != res_arr[i])
|
|
51 |
failures++;
|
|
52 |
}
|
|
53 |
cout << endl;
|
|
54 |
|
|
55 |
int res_arr2[] = {4, 9, 25};
|
|
56 |
|
|
57 |
d.pop_front(); // Erase first element.
|
|
58 |
|
|
59 |
d[2] = 25; // Replace last element.
|
|
60 |
for(i = 0; i < d.size(); i++)
|
|
61 |
{
|
|
62 |
cout << "d[" << i << "] = " << d[i] << endl;
|
|
63 |
if (d[i] != res_arr2[i])
|
|
64 |
failures++;
|
|
65 |
}
|
|
66 |
|
|
67 |
if(!failures)
|
|
68 |
return 0;
|
|
69 |
else
|
|
70 |
return 1;
|
|
71 |
|
|
72 |
}
|
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|