stdcpp/tsrc/Stdcpp_test/stlport/auto/stlport_vec/src/vec4.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 <iostream>
       
    23 #include <vector>
       
    24 #include <algorithm>
       
    25 
       
    26 #ifdef MAIN 
       
    27 #define vec4_test main
       
    28 #endif
       
    29 
       
    30 #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
       
    31 using namespace std;
       
    32 #endif
       
    33 int vec4_test(int, char**)
       
    34 {
       
    35   int failures=0;
       
    36   cout<<"Results of vec4_test:"<<endl;
       
    37   vector<int> v(4);
       
    38   v[0] = 1;
       
    39   v[1] = 4;
       
    40   v[2] = 9;
       
    41   v[3] = 16;
       
    42   cout << "front = " << v.front() << endl;
       
    43   
       
    44   if(1!=v.front() )
       
    45      failures++;
       
    46   cout << "back = " << v.back() << ", size = " << v.size() << endl;
       
    47   
       
    48   if(16!=v.back())
       
    49      failures++;
       
    50   else if(4!=v.size())
       
    51     failures++;   
       
    52   
       
    53   v.push_back(25);
       
    54   cout << "back = " << v.back() << ", size = " << v.size() << endl;
       
    55   
       
    56   if(25!=v.back())
       
    57      failures++;
       
    58   else if(5!=v.size())
       
    59     failures++;  
       
    60   
       
    61   v.pop_back();
       
    62   cout << "back = " << v.back() << ", size = " << v.size() << endl;
       
    63   if(16!=v.back())
       
    64      failures++;
       
    65   else if(4!=v.size())
       
    66     failures++;  
       
    67   if(failures)
       
    68     return 1;
       
    69   else   
       
    70     return 0;
       
    71 }
       
    72 
       
    73 /*Results of vec4_test:
       
    74 front = 1
       
    75 back = 16, size = 4
       
    76 back = 25, size = 5
       
    77 back = 16, size = 4
       
    78 */