stdcpp/tsrc/Stdcpp_test/stlport/auto/stlport_list/src/list1.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 <list>
       
    23 
       
    24 #ifdef MAIN 
       
    25 #define list1_test main
       
    26 #endif
       
    27 
       
    28 #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
       
    29 using namespace std;
       
    30 #endif
       
    31 int list1_test(int, char**)
       
    32 {
       
    33   cout<<"Results of list1_test:"<<endl;
       
    34 int array1 [] = { 9, 16, 36 };
       
    35 int array2 [] = { 1, 4 };
       
    36 int array3[5];
       
    37 int failures = 0;int a=0;
       
    38   list<int> l1(array1, array1 + 3);
       
    39   list<int> l2(array2, array2 + 2);
       
    40   std::list<int>::iterator i1 = l1.begin();
       
    41   l1.splice(i1, l2);
       
    42   std::list<int>::iterator i2 = l1.begin();
       
    43   while(i2 != l1.end())
       
    44   {
       
    45   	array3[a] = *i2;
       
    46   	cout << *i2++ << endl;
       
    47   	a++;
       
    48   
       
    49   }
       
    50     
       
    51     if(array3[0] != 1)
       
    52     failures++;
       
    53     if(array3[1] != 4)
       
    54     failures++;
       
    55     if(array3[2] != 9)
       
    56     failures++;
       
    57     if(array3[3] != 16)
       
    58     failures++;
       
    59      if(array3[4] != 36)
       
    60     failures++;
       
    61   return failures;
       
    62 }