{
less_by_reference<SortClass> throw_cmp( partitionPoint );
SortClass* d = EH_STD::stable_partition( buf.begin(), buf.end(), throw_cmp );
// Suppress warning about unused variable.d;
// If we get here no exception occurred during the operation.// Stop any potential failures that might occur during verification.gTestController.CancelFailureCountdown();
// Prepare an array of counts of the occurrence of each value in// the legal range.unsigned counts[SortClass::kRange];
EH_STD::fill_n( counts, (int)SortClass::kRange, 0 );
for ( constSortClass *q = orig.begin(); q != orig.end(); q++ )
counts[ q->value() ]++;
less_by_reference<TestClass> cmp( partitionPoint );
for ( constSortClass* p = buf.begin(); p != buf.end(); p++ )
{
// Check that adjacent items with the same value haven't been// reordered. This could be a more thorough test.if ( p != buf.begin() && p->value() == p[-1].value() ) {
EH_ASSERT( p->GetAddress() > p[-1].GetAddress() );
}
// Check that the partitioning worked.EH_ASSERT( (p < d) == cmp( *p ) );
// Decrement the appropriate count for each value.
counts[ p->value() ]--;
}
// Check that the values were only rearranged, and none were lost.for ( unsigned j = 0; j < SortClass::kRange; j++ ) {
EH_ASSERT( counts[j] == 0 );
}
}
Generated on Fri May 25 2012 06:42:35 for ReactOS by
1.7.6.1
ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.