stdcpp/tsrc/Stdcpp_test/stlport/auto/stlport_uprbnd/src/uprbnd1.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  
       
    19 // STLport regression testsuite component.
       
    20 // To compile as a separate example, please #define MAIN.
       
    21 
       
    22 #include <algorithm>
       
    23 #include <iostream>
       
    24 
       
    25 #ifdef MAIN 
       
    26 #define uprbnd1_test main
       
    27 #endif
       
    28 
       
    29 #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
       
    30 using namespace std;
       
    31 #endif
       
    32 int uprbnd1_test(int, char**)
       
    33 {
       
    34   int x=0;
       
    35   
       
    36   cout<<"Results of uprbnd1_test:"<<endl;
       
    37   int array[20];
       
    38   for(int i = 0; i < 20; i++)
       
    39   {
       
    40     array[i] = i/4;
       
    41     cout << array[i] << ' ';
       
    42   }
       
    43   
       
    44   x=(upper_bound((int*)array, (int*)array + 20, 3) - array);
       
    45  
       
    46   cout<< "\n3 can be inserted at index: "<<x << endl;
       
    47   
       
    48   if(16!=x)
       
    49     return 1;  
       
    50   else 
       
    51    return 0;
       
    52 }
       
    53 
       
    54 /*sults of uprbnd1_test:
       
    55 0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4
       
    56 3 can be inserted at index: 16*/