stdcpp/tsrc/Stdcpp_test/stlport/auto/stlport_setintr/src/setintr2.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 <algorithm>
       
    22 #include <iostream>
       
    23 #include <cstring>
       
    24 #include <iterator>
       
    25 #include <functional>
       
    26 
       
    27 #ifdef MAIN 
       
    28 #define setintr2_test main
       
    29 #endif
       
    30 
       
    31 #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
       
    32 using namespace std;
       
    33 #endif
       
    34 int setintr2_test(int, char**)
       
    35 {
       
    36   int failures=0;
       
    37   cout<<"Results of setintr2_test:"<<endl;
       
    38 char* word1 = "ABCDEFGHIJKLMNO";
       
    39 char* word2 = "LMNOPQRSTUVWXYZ";
       
    40 char word3[5];
       
    41   ostream_iterator <char> iter(cout, " ");
       
    42   cout << "word1: ";
       
    43   
       
    44   if(strcmp(word1,"ABCDEFGHIJKLMNO"))
       
    45     failures++; 
       
    46   
       
    47   copy(word1, word1 + ::strlen(word1), iter);
       
    48   cout << "\nword2: ";
       
    49   
       
    50   if(strcmp(word2,"LMNOPQRSTUVWXYZ"))
       
    51     failures++; 
       
    52 
       
    53   
       
    54   copy(word2, word2 + ::strlen(word2), iter);
       
    55   cout << endl;
       
    56   set_intersection(word1, word1 + ::strlen(word1),
       
    57                     word2, word2 + ::strlen(word2),
       
    58                     word3,
       
    59                     less<char>());
       
    60   word3[4]='\0';
       
    61    
       
    62   if(strcmp(word3,"LMNO"))
       
    63      failures++; 
       
    64   
       
    65   copy(word3,word3+ ::strlen(word3),iter);
       
    66   cout << endl;
       
    67   
       
    68   if(failures)
       
    69     return 1;
       
    70   else  
       
    71     return 0;
       
    72 }
       
    73