31
|
1 |
|
|
2 |
// STLport regression testsuite component.
|
|
3 |
// To compile as a separate example, please #define MAIN.
|
|
4 |
|
|
5 |
|
|
6 |
#include <stdexcept>
|
|
7 |
#include <iostream>
|
|
8 |
#include <bitset>
|
|
9 |
#include <algorithm>
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
#if defined (_STLP_MSVC) && (_MSC_VER < 1300)
|
|
14 |
# define _STLP_NON_TYPE_TMPL_PARAM_BUG
|
|
15 |
# define _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
|
|
16 |
#endif
|
|
17 |
|
|
18 |
# ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
|
|
19 |
# define CHART
|
|
20 |
# else
|
|
21 |
# define CHART <char, char_traits<char>, allocator<char> >
|
|
22 |
# endif
|
|
23 |
|
|
24 |
#ifdef MAIN
|
|
25 |
#define bitset1_test main
|
|
26 |
#endif
|
|
27 |
|
|
28 |
#if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
|
|
29 |
using namespace std;
|
|
30 |
#endif
|
|
31 |
|
|
32 |
int bitset1_test(int, char**)
|
|
33 |
{
|
|
34 |
cout<<"Results of bitset1_test:"<<endl;
|
|
35 |
int failures = 0;
|
|
36 |
|
|
37 |
# if ! (defined (_STLP_MSVC) && (_MSC_VER < 1300)) && ! (defined (__SUNPRO_CC) && (__SUNPRO_CC < 0x500))
|
|
38 |
bitset<13U> b1(0xFFFF);
|
|
39 |
bitset<13U> b2(0x1111);
|
|
40 |
// Boris : MSVC just cannot take it right
|
|
41 |
cout << "b1 size = " << b1.size() << endl;
|
|
42 |
//check for failure
|
|
43 |
if (b1.size() != 13)
|
|
44 |
failures++;
|
|
45 |
# if !defined (_STLP_NON_TYPE_TMPL_PARAM_BUG)
|
|
46 |
cout << "b1 = "<<b1<<endl;
|
|
47 |
# else
|
|
48 |
cout << "b1 = "<<b1.to_string CHART ()<<endl;
|
|
49 |
# endif
|
|
50 |
if (b1 != 0xFFFF)
|
|
51 |
failures++;
|
|
52 |
|
|
53 |
cout << "b2 size = " << b2.size() << endl;
|
|
54 |
if (b2.size() != 13)
|
|
55 |
failures++;
|
|
56 |
# if defined (_STLP_NON_TYPE_TMPL_PARAM_BUG)
|
|
57 |
cout << "b2 = "<<b2.to_string CHART ()<<endl;
|
|
58 |
# else
|
|
59 |
cout << "b2 = "<<b2<<endl;
|
|
60 |
# endif
|
|
61 |
if (b2 != 0x1111)
|
|
62 |
failures++;
|
|
63 |
|
|
64 |
b1 = b1^(b2<<2);
|
|
65 |
# ifdef _STLP_NON_TYPE_TMPL_PARAM_BUG
|
|
66 |
cout << "b1 = "<<b1.to_string CHART ()<<endl;
|
|
67 |
# else
|
|
68 |
cout << "b1 = "<<b1<<endl;
|
|
69 |
# endif
|
|
70 |
if(b1 != 0x1BBB)
|
|
71 |
failures++;
|
|
72 |
# endif /* MSVC */
|
|
73 |
|
|
74 |
if (!failures)
|
|
75 |
return 0;
|
|
76 |
else
|
|
77 |
return 1;
|
|
78 |
}
|