os/ossrv/stdcpp/tsrc/Stdcpp_test/stlport/auto/stlport_vec/src/vec1.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 
     2 // STLport regression testsuite component.
     3 // To compile as a separate example, please #define MAIN.
     4 #include <cstdlib>
     5 #include <iostream>
     6 #include <algorithm>
     7 #include <vector>
     8 
     9 #ifdef MAIN 
    10 #define vec1_test main
    11 #endif
    12 
    13 #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
    14 using namespace std;
    15 #endif
    16 int vec1_test(int, char**)
    17 {
    18   int failures=0;
    19   //   cout<<"Sizeof(vector) is "<<sizeof(vector<int>)<<endl;
    20   //  cout<<"Sizeof(fw) is "<<sizeof(forward_iterator_tag)<<endl;
    21   //  cout<<"Sizeof(ra) is "<<sizeof(random_access_iterator_tag)<<endl;
    22   cout<<"Results of vec1_test:"<<endl;
    23   vector<int> v1; // Empty vector of integers.
    24   cout << "empty = " << v1.empty() << endl;
    25   cout << "size = " << v1.size() << endl;
    26   cout << "max_size = " << v1.max_size() << endl;
    27   
    28   if(1!=v1.empty())
    29     failures++;
    30   else if(0!=v1.size())
    31     failures++;
    32   else if(1073741823!=v1.max_size())
    33     failures++;
    34   
    35   v1.push_back(42); // Add an integer to the vector.
    36   cout << "size = " << v1.size() << endl;
    37   cout << "v1[0] = " << v1[0] << endl;
    38   
    39   if(1!=v1.size())
    40     failures++;
    41   else if(42!=v1[0])
    42      failures++;  
    43   
    44   if(failures)
    45     return 1;
    46   else  
    47     return 0;
    48 }