stdcpp/tsrc/Stdcpp_test/stlport/auto/stlport_setunon/src/setunon2.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 setunon2_test main
       
    29 #endif
       
    30 
       
    31 #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
       
    32 using namespace std;
       
    33 #endif
       
    34 int setunon2_test(int, char**)
       
    35 {
       
    36  int failures=0;
       
    37   cout<<"Results of setunon2_test:"<<endl;
       
    38 char* word1 = "ABCDEFGHIJKLMNO";
       
    39 char* word2 = "LMNOPQRSTUVWXYZ";
       
    40 char word3[27];
       
    41   ostream_iterator <char> iter(cout, " ");
       
    42   cout << "word1: ";
       
    43  
       
    44  if(strcmp(word1,"ABCDEFGHIJKLMNO"))
       
    45     failures++;
       
    46   copy(word1, word1 + ::strlen(word1), iter);
       
    47   cout << "\nword2: ";
       
    48   
       
    49   if(strcmp(word2,"LMNOPQRSTUVWXYZ"))
       
    50     failures++;
       
    51   
       
    52   copy(word2, word2 + ::strlen(word2), iter);
       
    53   cout << endl;
       
    54   set_union(word1, word1 + ::strlen(word1),
       
    55              word2, word2 + ::strlen(word2),
       
    56              word3,
       
    57              less<char>());
       
    58 
       
    59   word3[26]='\0';
       
    60   if(strcmp(word3,"ABCDEFGHIJKLMNOPQRSTUVWXYZ"))
       
    61      failures++;
       
    62   copy(word3,word3+ ::strlen(word3),iter);  
       
    63   cout << endl;
       
    64   
       
    65   if(failures)
       
    66     return 1;
       
    67   else  
       
    68     return 0;
       
    69 }
       
    70