Home | History | Annotate | Download | only in test
      1 #include <bitset>
      2 #include <deque>
      3 #include <list>
      4 #include <memory>
      5 #include <map>
      6 #include <queue>
      7 #include <set>
      8 #ifdef _STLPORT_VERSION
      9 #include <slist>
     10 #endif // _STLPORT_VERSION
     11 #include <string>
     12 #include <stack>
     13 #if _STLPORT_VERSION >= 0x520
     14 #include <unordered_map>
     15 #include <unordered_set>
     16 #endif //_STLPORT_VERSION >= 0x520
     17 #include <vector>
     18 
     19 #ifdef _STLPORT_VERSION
     20 #define STD_TR1 std::tr1
     21 #else // _STLPORT_VERSION
     22 #define STD_TR1 std
     23 #endif // _STLPORT_VERSION
     24 
     25 struct Large {
     26   char m_foo[100];
     27 };
     28 
     29 void foo() { }
     30 
     31 int main() {
     32 
     33   std::string string1 = "";
     34   std::string string2 = "a short string";
     35   std::string string3 = "a very long string ...";
     36 
     37   std::wstring wstring1 = L"";
     38   std::wstring wstring2 = L"a short string";
     39   std::wstring wstring3 = L"a very long string ...";
     40 
     41   std::vector<int> vector1;
     42   vector1.push_back( 100);
     43   vector1.push_back( 200);
     44   vector1.push_back( 300);
     45 
     46   std::vector<bool> vector2;
     47   vector2.push_back( true);
     48   vector2.push_back( false);
     49   vector2.push_back( true);
     50 
     51   std::map<int,int> map1;
     52   map1[1] = -1;
     53   map1[21] = -21;
     54   map1[42] = -42;
     55 
     56   std::multimap<int,int> multimap1;
     57   multimap1.insert (std::pair<int,int> (1, -1));
     58   multimap1.insert (std::pair<int,int> (1, -2));
     59   multimap1.insert (std::pair<int,int> (21, -21));
     60   multimap1.insert (std::pair<int,int> (21, -22));
     61   multimap1.insert (std::pair<int,int> (42, -42));
     62   multimap1.insert (std::pair<int,int> (42, -43));
     63 
     64   std::set<int> set1;
     65   set1.insert( 100);
     66   set1.insert( 200);
     67   set1.insert( 300);
     68 
     69   std::multiset<int> multiset1;
     70   multiset1.insert( 100);
     71   multiset1.insert( 100);
     72   multiset1.insert( 200);
     73   multiset1.insert( 200);
     74   multiset1.insert( 300);
     75   multiset1.insert( 300);
     76 
     77   std::list<int> list1;
     78   std::list<int> list2;
     79   list1.push_back( 100);
     80   list1.push_back( 200);
     81   list1.push_back( 300);
     82 
     83 #ifdef _STLPORT_VERSION
     84   std::slist<int> slist1;
     85   std::slist<int> slist2;
     86   slist1.push_front( 100);
     87   slist1.push_front( 200);
     88   slist1.push_front( 300);
     89 #else // _STLPORT_VERSION
     90   std::string slist1 = "std::slist not supported";
     91   std::string slist2 = "std::slist not supported";
     92 #endif // _STLPORT_VERSION
     93 
     94   std::deque<int> deque1;
     95   deque1.push_front( 100);
     96   deque1.push_front( 200);
     97   deque1.push_front( 300);
     98 
     99   std::deque<Large> deque2;
    100   deque2.push_back( Large());
    101   deque2.push_back( Large());
    102   deque2.push_front( Large());
    103 
    104   std::stack<int> stack1;
    105   stack1.push( 100);
    106   stack1.push( 200);
    107   stack1.push( 300);
    108 
    109   std::queue<int> queue1;
    110   queue1.push( 100);
    111   queue1.push( 200);
    112   queue1.push( 300);
    113 
    114   std::priority_queue<int> priority_queue1;
    115   priority_queue1.push( 200);
    116   priority_queue1.push( 100);
    117   priority_queue1.push( 300);
    118 
    119   std::bitset<100> bitset1;
    120   bitset1[2] = 1;
    121   bitset1[42] = 1;
    122   bitset1[64] = 1;
    123 
    124   std::bitset<1> bitset2;
    125   bitset2[0] = 1;
    126 
    127 #if _STLPORT_VERSION >= 0x520
    128   STD_TR1::unordered_map<int,int> unordered_map1;
    129   STD_TR1::unordered_map<int,int> unordered_map2;
    130   for( int i = 0; i < 5; ++i)
    131       unordered_map1[i*i] = -i*i;
    132 
    133   STD_TR1::unordered_multimap<int,int> unordered_multimap1;
    134   STD_TR1::unordered_multimap<int,int> unordered_multimap2;
    135   for( int i = 0; i < 5; ++i) {
    136       unordered_multimap1.insert( std::pair<int,int>( i*i, -i*i));
    137       unordered_multimap1.insert( std::pair<int,int>( i*i,  i*i));
    138   }
    139 
    140   STD_TR1::unordered_set<int> unordered_set1;
    141   STD_TR1::unordered_set<int> unordered_set2;
    142   for( int i = 0; i < 5; ++i)
    143       unordered_set1.insert( i*i);
    144 
    145   STD_TR1::unordered_multiset<int> unordered_multiset1;
    146   STD_TR1::unordered_multiset<int> unordered_multiset2;
    147   for( int i = 0; i < 5; ++i) {
    148       unordered_multiset1.insert( -i*i);
    149       unordered_multiset1.insert(  i*i);
    150   }
    151 #else // _STLPORT_VERSION < 0x520
    152   std::string unordered_map1 = "std::tr1::unordered_map not supported";
    153   std::string unordered_map2 = "std::tr1::unordered_map not supported";
    154   std::string unordered_multimap1 = "std::tr1::unordered_multimap not supported";
    155   std::string unordered_multimap2 = "std::tr1::unordered_multimap not supported";
    156   std::string unordered_set1 = "std::tr1::unordered_set not supported";
    157   std::string unordered_set2 = "std::tr1::unordered_set not supported";
    158   std::string unordered_multiset1 = "std::tr1::unordered_multiset not supported";
    159   std::string unordered_multiset2 = "std::tr1::unordered_multiset not supported";
    160 #endif // _STLPORT_VERSION < 0x520
    161 
    162   std::auto_ptr<Large> auto_ptr1( new Large());
    163   std::auto_ptr<Large> auto_ptr2;
    164 
    165 #ifdef _STLP_USE_BOOST_SUPPORT
    166   STD_TR1::shared_ptr<Large> shared_ptr1( new Large);
    167   STD_TR1::shared_ptr<Large> shared_ptr2;
    168 
    169   STD_TR1::weak_ptr<Large> weak_ptr1( shared_ptr1);
    170   STD_TR1::weak_ptr<Large> weak_ptr2;
    171 #else // _STLP_USE_BOOST_SUPPORT
    172   std::string shared_ptr1 = "std::tr1::shared_ptr not supported";
    173   std::string shared_ptr2 = "std::tr1::shared_ptr not supported";
    174 
    175   std::string weak_ptr1 = "std::tr1::weak_ptr not supported";
    176   std::string weak_ptr2 = "std::tr1::weak_ptr not supported";
    177 #endif // _STLP_USE_BOOST_SUPPORT
    178 
    179   foo();
    180   return 0;
    181 }
    182