stdcpp/tsrc/Stdcpp_test/stlport/auto/stlport_bitset/src/bitset1.cpp
changeset 31 ce057bb09d0b
child 34 5fae379060a7
equal deleted inserted replaced
30:e20de85af2ee 31:ce057bb09d0b
       
     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 
       
    22 #include <stdexcept>
       
    23 #include <iostream>
       
    24 #include <bitset>
       
    25 #include <algorithm>
       
    26 
       
    27 
       
    28 
       
    29 #if defined (_STLP_MSVC) && (_MSC_VER < 1300)
       
    30 # define _STLP_NON_TYPE_TMPL_PARAM_BUG
       
    31 # define _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
       
    32 #endif
       
    33 
       
    34 # ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
       
    35 # define CHART
       
    36 # else
       
    37 # define CHART <char, char_traits<char>, allocator<char> >
       
    38 # endif
       
    39 
       
    40 #ifdef MAIN
       
    41 #define bitset1_test main
       
    42 #endif
       
    43 
       
    44 #if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
       
    45 using namespace std;
       
    46 #endif
       
    47 
       
    48 int bitset1_test(int, char**)
       
    49 {
       
    50   cout<<"Results of bitset1_test:"<<endl;
       
    51   int failures = 0;
       
    52 
       
    53 # if ! (defined (_STLP_MSVC) && (_MSC_VER < 1300)) && ! (defined (__SUNPRO_CC) && (__SUNPRO_CC < 0x500))
       
    54   bitset<13U> b1(0xFFFF);
       
    55   bitset<13U> b2(0x1111);
       
    56   // Boris : MSVC just cannot take it right
       
    57   cout << "b1 size = " << b1.size() << endl;
       
    58   //check for failure
       
    59   if (b1.size() != 13)
       
    60   	failures++;
       
    61 # if !defined (_STLP_NON_TYPE_TMPL_PARAM_BUG)
       
    62   cout << "b1 = "<<b1<<endl;
       
    63 # else
       
    64   cout << "b1 = "<<b1.to_string CHART ()<<endl;
       
    65 # endif
       
    66   if (b1 != 0xFFFF)
       
    67   	failures++;
       
    68 
       
    69   cout << "b2 size = " << b2.size() << endl;
       
    70   if (b2.size() != 13)
       
    71   	failures++;
       
    72 # if defined (_STLP_NON_TYPE_TMPL_PARAM_BUG)
       
    73   cout << "b2 = "<<b2.to_string CHART ()<<endl;
       
    74 # else
       
    75   cout << "b2 = "<<b2<<endl;
       
    76 # endif
       
    77   if (b2 != 0x1111)
       
    78   	failures++;
       
    79 
       
    80   b1 = b1^(b2<<2);
       
    81 # ifdef _STLP_NON_TYPE_TMPL_PARAM_BUG
       
    82   cout << "b1 = "<<b1.to_string CHART ()<<endl;
       
    83 # else
       
    84   cout << "b1 = "<<b1<<endl;
       
    85 # endif
       
    86   if(b1 != 0x1BBB)
       
    87   	failures++;
       
    88 # endif /* MSVC */
       
    89 
       
    90   if (!failures)
       
    91     return 0;
       
    92   else
       
    93     return 1;
       
    94 }