stdcpp/tsrc/Stdcpp_test/stlport/auto/stlport_trnsfrm/src/trnsfrm2.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 trnsfrm2_test main
       
    29 #endif
       
    30 static char map_char(char a_, int b_)
       
    31 {
       
    32   return char(a_ + b_);
       
    33 }
       
    34 
       
    35 #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
       
    36 using namespace std;
       
    37 #endif
       
    38 int trnsfrm2_test(int, char**)
       
    39 {
       
    40   cout<<"Results of trnsfrm2_test:"<<endl;
       
    41 
       
    42 #if defined (__MVS__)
       
    43 int trans[] = {-11, 4, -6, -6, -18, 0, 18, -14, 6, 0, -1, -59};
       
    44 #else
       
    45 int trans[] = {-4, 4, -6, -6, -10, 0, 10, -6, 6, 0, -1, -77};
       
    46 #endif
       
    47   char n[] = "Larry Mullen";
       
    48   char arr[13];
       
    49   const unsigned count = ::strlen(n);
       
    50   ostream_iterator <char> iter(cout);
       
    51   transform(n, n + count, trans, arr, map_char);
       
    52   cout << endl;
       
    53   arr[12]='\0';
       
    54   if(strcmp(arr,"Hello World!"))
       
    55     return 1;
       
    56   else
       
    57     return 0;
       
    58 }
       
    59