ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

void assert_sorted_version ( const SortBuffer orig,
const SortBuffer buf 
)

Definition at line 146 of file test_algo.cpp.

Referenced by test_stable_sort_1::operator()(), test_stable_sort_2::operator()(), test_inplace_merge_1::operator()(), and test_inplace_merge_2::operator()().

{
  // 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 ( const SortClass *q = orig.begin(); q != orig.end(); q++ )
        counts[ q->value() ]++;

  // Check that each element is greater than the previous one, or if they are
  // equal, that their order has been preserved.
    for ( const SortClass* p = buf.begin(); p != buf.end(); p++ )
    {
        if ( p != buf.begin() ) {
            EH_ASSERT( p->value() > p[-1].value()
                    || p->value() == p[-1].value() && p->GetAddress() > p[-1].GetAddress() );
        }
    // 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 Sun May 27 2012 06:02:59 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.