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 |
|
|
21 |
#include <iostream>
|
|
22 |
#include <vector>
|
|
23 |
|
|
24 |
#ifdef MAIN
|
|
25 |
#define bvec1_test main
|
|
26 |
#endif
|
|
27 |
|
|
28 |
#if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
|
|
29 |
using namespace std;
|
|
30 |
#endif
|
|
31 |
|
|
32 |
int bvec1_test(int, char**)
|
|
33 |
{
|
|
34 |
bool ii[3]= {1,0,1};
|
|
35 |
cout<<"Results of bvec1_test:"<<endl;
|
|
36 |
int failures = 0;
|
|
37 |
|
|
38 |
bit_vector b(3);
|
|
39 |
int i;
|
|
40 |
for(i = 0; i < b.size(); i++)
|
|
41 |
cout << b[i];
|
|
42 |
cout << endl;
|
|
43 |
b[0] = b[2] = 1;
|
|
44 |
for(i = 0; i < b.size(); i++)
|
|
45 |
cout << b[i];
|
|
46 |
cout << endl;
|
|
47 |
b.insert(b.begin(),(bool*)ii, ii+2);
|
|
48 |
for(i = 0; i < b.size(); i++)
|
|
49 |
cout << b[i];
|
|
50 |
cout << endl;
|
|
51 |
bit_vector bb = b;
|
|
52 |
if (bb != b)
|
|
53 |
failures++;
|
|
54 |
|
|
55 |
b[0] |= 0;
|
|
56 |
b[1] |= 0;
|
|
57 |
b[2] |= 1;
|
|
58 |
b[3] |= 1;
|
|
59 |
if ((b[0] != 1) || (b[1] != 0) || (b[2] != 1) || (b[3] != 1))
|
|
60 |
failures++;
|
|
61 |
|
|
62 |
bb[0] &= 0;
|
|
63 |
bb[1] &= 0;
|
|
64 |
bb[2] &= 1;
|
|
65 |
bb[3] &= 1;
|
|
66 |
if ((bb[0] != 0) || (bb[1] != 0) || (bb[2] != 1) || (bb[3] != 0))
|
|
67 |
failures++;
|
|
68 |
|
|
69 |
if (!failures)
|
|
70 |
return 0;
|
|
71 |
else
|
|
72 |
return 1;}
|