31
|
1 |
|
|
2 |
// STLport regression testsuite component.
|
|
3 |
// To compile as a separate example, please #define MAIN.
|
|
4 |
|
|
5 |
#include <iostream>
|
|
6 |
#include <vector>
|
|
7 |
#include <algorithm>
|
|
8 |
#ifdef MAIN
|
|
9 |
#define vec3_test main
|
|
10 |
#endif
|
|
11 |
|
|
12 |
#if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
|
|
13 |
using namespace std;
|
|
14 |
#endif
|
|
15 |
int vec3_test(int, char**)
|
|
16 |
{
|
|
17 |
int failures=0;
|
|
18 |
cout<<"Results of vec3_test:"<<endl;
|
|
19 |
# ifdef __STLPORT_VERSION
|
|
20 |
typedef __vector__<char, allocator<char> > vec_type;
|
|
21 |
# else
|
|
22 |
typedef vector<char> vec_type;
|
|
23 |
# endif
|
|
24 |
vec_type v1; // Empty vector of characters.
|
|
25 |
v1.push_back('h');
|
|
26 |
v1.push_back('i');
|
|
27 |
cout << "v1 = " << v1[0] << v1[1] << endl;
|
|
28 |
|
|
29 |
if('h' !=v1[0])
|
|
30 |
failures++;
|
|
31 |
else if('i'!=v1[1])
|
|
32 |
failures++;
|
|
33 |
|
|
34 |
vec_type v2(v1.begin(), v1.end());
|
|
35 |
v2[1] = 'o'; // Replace second character.
|
|
36 |
cout << "v2 = " << v2[0] << v2[1] << endl;
|
|
37 |
|
|
38 |
if('h' !=v2[0])
|
|
39 |
failures++;
|
|
40 |
else if('o'!=v2[1])
|
|
41 |
failures++;
|
|
42 |
|
|
43 |
cout << "(v1 == v2) = " <<(v1 == v2) << endl;
|
|
44 |
if(v1==v2)
|
|
45 |
failures++;
|
|
46 |
cout << "(v1 < v2) = " <<(v1 < v2) << endl;
|
|
47 |
if(1!=(v1 < v2))
|
|
48 |
failures++;
|
|
49 |
|
|
50 |
if(failures)
|
|
51 |
return 1;
|
|
52 |
else
|
|
53 |
return 0;
|
|
54 |
}
|
|
55 |
/*Results of vec3_test:
|
|
56 |
v1 = hi
|
|
57 |
v2 = ho
|
|
58 |
(v1 == v2) = 0
|
|
59 |
(v1 < v2) = 1
|
|
60 |
*/
|