stdcpp/tsrc/Stdcpp_test/stlport/auto/stlport_setintr/src/setintr2.cpp
changeset 0 e4d67989cc36
child 18 47c74d1534e1
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 
       
     2 // STLport regression testsuite component.
       
     3 // To compile as a separate example, please #define MAIN.
       
     4 
       
     5 #include <algorithm>
       
     6 #include <iostream>
       
     7 #include <cstring>
       
     8 #include <iterator>
       
     9 #include <functional>
       
    10 
       
    11 #ifdef MAIN 
       
    12 #define setintr2_test main
       
    13 #endif
       
    14 
       
    15 #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
       
    16 using namespace std;
       
    17 #endif
       
    18 int setintr2_test(int, char**)
       
    19 {
       
    20   int failures=0;
       
    21   cout<<"Results of setintr2_test:"<<endl;
       
    22 char* word1 = "ABCDEFGHIJKLMNO";
       
    23 char* word2 = "LMNOPQRSTUVWXYZ";
       
    24 char word3[5];
       
    25   ostream_iterator <char> iter(cout, " ");
       
    26   cout << "word1: ";
       
    27   
       
    28   if(strcmp(word1,"ABCDEFGHIJKLMNO"))
       
    29     failures++; 
       
    30   
       
    31   copy(word1, word1 + ::strlen(word1), iter);
       
    32   cout << "\nword2: ";
       
    33   
       
    34   if(strcmp(word2,"LMNOPQRSTUVWXYZ"))
       
    35     failures++; 
       
    36 
       
    37   
       
    38   copy(word2, word2 + ::strlen(word2), iter);
       
    39   cout << endl;
       
    40   set_intersection(word1, word1 + ::strlen(word1),
       
    41                     word2, word2 + ::strlen(word2),
       
    42                     word3,
       
    43                     less<char>());
       
    44   word3[4]='\0';
       
    45    
       
    46   if(strcmp(word3,"LMNO"))
       
    47      failures++; 
       
    48   
       
    49   copy(word3,word3+ ::strlen(word3),iter);
       
    50   cout << endl;
       
    51   
       
    52   if(failures)
       
    53     return 1;
       
    54   else  
       
    55     return 0;
       
    56 }
       
    57