Home | History | Annotate | Download | only in eh
      1 /***********************************************************************************
      2   test_hash_resize.h
      3 
      4  * Copyright (c) 1997
      5  * Mark of the Unicorn, Inc.
      6  *
      7  * Permission to use, copy, modify, distribute and sell this software
      8  * and its documentation for any purpose is hereby granted without fee,
      9  * provided that the above copyright notice appear in all copies and
     10  * that both that copyright notice and this permission notice appear
     11  * in supporting documentation.  Mark of the Unicorn makes no
     12  * representations about the suitability of this software for any
     13  * purpose.  It is provided "as is" without express or implied warranty.
     14 
     15 ***********************************************************************************/
     16 #ifndef test_hash_resize__
     17 #define test_hash_resize__
     18 
     19 #include "random_number.h"
     20 #include "nc_alloc.h"
     21 
     22 template <class T>
     23 struct test_hash_resize
     24 {
     25     test_hash_resize()
     26     {
     27       gTestController.SetCurrentTestName("hash resize");
     28     }
     29 
     30   void operator()( T& t ) const
     31   {
     32     t.resize( 1+random_number(random_base) + t.bucket_count() );
     33   }
     34 };
     35 
     36 template <class T>
     37 struct test_construct_iter_range_n
     38 {
     39   test_construct_iter_range_n( const T& src )
     40     : fItems( src )
     41   {
     42         gTestController.SetCurrentTestName("iterator range n-size constructor");
     43     }
     44 
     45   void operator()( int ) const
     46   {
     47     T t( fItems.begin(), fItems.end(), fItems.size() );
     48     // prevent simulated failures during verification
     49     gTestController.CancelFailureCountdown();
     50     CheckInvariant(t);
     51   }
     52 
     53   const T& fItems;
     54 };
     55 
     56 #endif //__test_hash_resize__
     57