| 161 | } |
| 162 | |
| 163 | struct GetFromTestCache |
| 164 | { |
| 165 | public : |
| 166 | |
| 167 | GetFromTestCache( TestCache &cache, size_t numValues, size_t clearFrequency ) |
| 168 | : m_cache( cache ), m_numValues( numValues ), m_clearFrequency( clearFrequency ) |
| 169 | { |
| 170 | } |
| 171 | |
| 172 | void operator()( const blocked_range<size_t> &r ) const |
| 173 | { |
| 174 | for( size_t i=r.begin(); i!=r.end(); ++i ) |
| 175 | { |
| 176 | const int k = i % m_numValues; |
| 177 | const int v = m_cache.get( k ); |
| 178 | if( k != v ) |
| 179 | { |
| 180 | throw Exception( |
| 181 | boost::str( |
| 182 | boost::format( "Incorrect LRUCache value found (expected %d but got %d)" ) % k %v |
| 183 | ) |
| 184 | ); |
| 185 | } |
| 186 | |
| 187 | if( m_clearFrequency && (i % m_clearFrequency == 0) ) |
| 188 | { |
| 189 | m_cache.clear(); |
| 190 | } |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | private : |
| 195 | |
| 196 | TestCache &m_cache; |
| 197 | size_t m_numValues; |
| 198 | size_t m_clearFrequency; |
| 199 | |
| 200 | }; |
| 201 | |
| 202 | void testLRUCacheThreading( int numIterations, int numValues, int maxCost, int clearFrequency = 0 ) |
| 203 | { |
no outgoing calls
no test coverage detected