| 48 | { |
| 49 | |
| 50 | void testUnorderedSet() |
| 51 | { |
| 52 | std::unordered_set< IECore::MurmurHash > set; |
| 53 | for( size_t i = 0; i < 1000000; i++ ) |
| 54 | { |
| 55 | IECore::MurmurHash h; |
| 56 | h.append( i ); |
| 57 | set.insert( h ); |
| 58 | } |
| 59 | |
| 60 | BOOST_CHECK( set.size() == 1000000 ); |
| 61 | |
| 62 | size_t maxBucketOccupancy = 0; |
| 63 | for( size_t i = 0; i < set.bucket_count(); i++ ) |
| 64 | { |
| 65 | maxBucketOccupancy = std::max( maxBucketOccupancy, set.bucket_size( i ) ); |
| 66 | } |
| 67 | |
| 68 | // If our hash function is good, then there shouldn't be any bucket that gets way too |
| 69 | // many elements in it - currently, I'm seeing a max occupancy of 8. |
| 70 | BOOST_CHECK( maxBucketOccupancy < 16 ); |
| 71 | } |
| 72 | }; |
| 73 | |
| 74 | |