stdcpp/tsrc/Stdcpp_test/stlport/auto/stlport_set/src/set1.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 #include <iostream>
       
    22 #include <algorithm>
       
    23 #include <set>
       
    24 
       
    25 #ifdef MAIN 
       
    26 #define set1_test main
       
    27 #endif
       
    28 
       
    29 #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
       
    30 using namespace std;
       
    31 #endif
       
    32 int set1_test(int, char**)
       
    33 {
       
    34   int failures=0;
       
    35   cout<<"Results of set1_test:"<<endl;
       
    36   set<int, less<int> > s;
       
    37   cout << "count(42) = " << s.count(42) << endl;
       
    38    
       
    39   if(0!=s.count(42))
       
    40     failures++;
       
    41   
       
    42   s.insert(42);
       
    43   cout << "count(42) = " << s.count(42) << endl;
       
    44   
       
    45   if(1!=s.count(42))
       
    46     failures++;
       
    47   
       
    48   s.insert(42);
       
    49   cout << "count(42) = " << s.count(42) << endl;
       
    50   
       
    51   if(1!=s.count(42))
       
    52     failures++;
       
    53   
       
    54   int count = s.erase(42);
       
    55   cout << count << " elements erased" << endl;
       
    56   
       
    57   if(1!=count)
       
    58     failures++;
       
    59     
       
    60   if(failures)
       
    61     return 1;
       
    62   else 
       
    63     return 0;
       
    64 }