stdcpp/tsrc/Stdcpp_test/stlport/auto/stlport_search/src/search0.cpp
changeset 0 e4d67989cc36
child 18 47c74d1534e1
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1  
       
     2 // STLport regression testsuite component.
       
     3 // To compile as a separate example, please #define MAIN.
       
     4 
       
     5 #include <algorithm>
       
     6 #include <iostream>
       
     7 
       
     8 #ifdef MAIN 
       
     9 #define search0_test main
       
    10 #endif
       
    11 
       
    12 #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
       
    13 using namespace std;
       
    14 #endif
       
    15 int search0_test(int, char**)
       
    16 {
       
    17   int failures=0;
       
    18   cout<<"Results of search0_test:"<<endl;
       
    19 int v1[6] = { 1, 1, 2, 3, 5, 8 };
       
    20 int v2[6] = { 0, 1, 2, 3, 4, 5 };
       
    21 int v3[2] = { 3, 4 };
       
    22 
       
    23   int* location;
       
    24   location = search((int*)v1, (int*)v1 + 6, (int*)v3, (int*)v3 + 2);
       
    25   if(location == v1 + 6)
       
    26     cout << "v3 not contained in v1" << endl;
       
    27   else
       
    28     cout << "Found v3 in v1 at offset: " << location - v1 << endl;
       
    29     
       
    30     if(location !=v1 + 6)
       
    31         failures++;
       
    32   
       
    33   
       
    34   location = search((int*)v2, (int*)v2 + 6, (int*)v3, (int*)v3 + 2);
       
    35   if(location == v2 + 6)
       
    36     cout << "v3 not contained in v2" << endl;
       
    37   else
       
    38     cout << "Found v3 in v2 at offset: " << location - v2 << endl;
       
    39   
       
    40   if(location == v2 + 6)
       
    41      failures++;
       
    42      
       
    43    if(failures)
       
    44       return 1;
       
    45    else
       
    46      return 0;
       
    47 }