equal
deleted
inserted
replaced
|
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 |
|
21 #include <iostream> |
|
22 #include <vector> |
|
23 #include <algorithm> |
|
24 #ifdef MAIN |
|
25 #define vec3_test main |
|
26 #endif |
|
27 |
|
28 #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES) |
|
29 using namespace std; |
|
30 #endif |
|
31 int vec3_test(int, char**) |
|
32 { |
|
33 int failures=0; |
|
34 cout<<"Results of vec3_test:"<<endl; |
|
35 # ifdef __STLPORT_VERSION |
|
36 typedef __vector__<char, allocator<char> > vec_type; |
|
37 # else |
|
38 typedef vector<char> vec_type; |
|
39 # endif |
|
40 vec_type v1; // Empty vector of characters. |
|
41 v1.push_back('h'); |
|
42 v1.push_back('i'); |
|
43 cout << "v1 = " << v1[0] << v1[1] << endl; |
|
44 |
|
45 if('h' !=v1[0]) |
|
46 failures++; |
|
47 else if('i'!=v1[1]) |
|
48 failures++; |
|
49 |
|
50 vec_type v2(v1.begin(), v1.end()); |
|
51 v2[1] = 'o'; // Replace second character. |
|
52 cout << "v2 = " << v2[0] << v2[1] << endl; |
|
53 |
|
54 if('h' !=v2[0]) |
|
55 failures++; |
|
56 else if('o'!=v2[1]) |
|
57 failures++; |
|
58 |
|
59 cout << "(v1 == v2) = " <<(v1 == v2) << endl; |
|
60 if(v1==v2) |
|
61 failures++; |
|
62 cout << "(v1 < v2) = " <<(v1 < v2) << endl; |
|
63 if(1!=(v1 < v2)) |
|
64 failures++; |
|
65 |
|
66 if(failures) |
|
67 return 1; |
|
68 else |
|
69 return 0; |
|
70 } |
|
71 /*Results of vec3_test: |
|
72 v1 = hi |
|
73 v2 = ho |
|
74 (v1 == v2) = 0 |
|
75 (v1 < v2) = 1 |
|
76 */ |