stdcpp/tsrc/Stdcpp_test/stlport/auto/stlport_func/src/func2.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 <iostream>
       
    22 #include <vector>
       
    23 #include <algorithm>
       
    24 
       
    25 #ifdef MAIN
       
    26 #define func2_test main
       
    27 #endif
       
    28 
       
    29 #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
       
    30 using namespace std;
       
    31 #endif
       
    32 
       
    33 static bool bigger_than(int x_, int y_)
       
    34 {
       
    35   return x_ > y_;
       
    36 }
       
    37 int func2_test(int, char**)
       
    38 {
       
    39 	cout<<"Results of func2_test:"<<endl;
       
    40 	int sort_arr[3] = { 5, 4, 1};
       
    41 
       
    42 	std::vector<int>v;
       
    43 	v.push_back(4);
       
    44 	v.push_back(1);
       
    45 	v.push_back(5);
       
    46 	sort(v.begin(), v.end(), bigger_than);
       
    47 	std::vector<int>::iterator i;
       
    48 	int j;
       
    49 	int failures = 0;
       
    50 	for(i = v.begin(), j = 0; i != v.end(); i++, j++)
       
    51 	{
       
    52 		cout << *i << endl;
       
    53 		if(sort_arr[j] != (*i))
       
    54 			failures++;
       
    55 	}
       
    56 	if(!failures)
       
    57 	return 0;
       
    58 	else
       
    59 	return 1;
       
    60 }