stdcpp/tsrc/Stdcpp_test/stlport/auto/stlport_adjfind/src/adjfind1.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 <vector>
       
    22 #include <algorithm>
       
    23 #include <iostream>
       
    24 
       
    25 #ifdef MAIN
       
    26 #define adjfind1_test main
       
    27 #endif
       
    28 
       
    29 
       
    30 #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
       
    31 using namespace std;
       
    32 #endif
       
    33 int adjfind1_test(int, char**)
       
    34 {
       
    35 
       
    36 	cout<<"Results of adjfind1_test:"<<endl;
       
    37 	int failures = 0;
       
    38 	typedef vector<int> IntVector;
       
    39 	IntVector v(10);
       
    40 	for(int i = 0; i < v.size(); i++)
       
    41 	v[i] = i;
       
    42 	IntVector::iterator location;
       
    43 	location = adjacent_find(v.begin(), v.end());
       
    44 	if(location != v.end())
       
    45 	{
       
    46 		cout << "Found adjacent pair of: " << *location << endl;
       
    47 		failures++;
       
    48 	}
       
    49 	else
       
    50 	{
       
    51 		cout << "No adjacent pairs" << endl;
       
    52 	}
       
    53 	v[6] = 7;
       
    54 	location = adjacent_find(v.begin(), v.end());
       
    55 	if(location != v.end())
       
    56 	{
       
    57 		cout << "Found adjacent pair of: " << *location << endl;
       
    58 		if (*location != 7)
       
    59 			failures++;
       
    60 	}
       
    61 	else
       
    62 	{
       
    63 		cout << "No adjacent pairs" << endl;
       
    64 		failures++;
       
    65 	}
       
    66 
       
    67 	if (!failures)
       
    68 		return 0;
       
    69 	else
       
    70 	return 1;
       
    71 }