Beispiel #1
0
int UnitTest::RunAllInGroup( const char* group )
{
  printf( "GROUP %s\n", group );
  int error_count = 0;
  const char dashes[] = "------------------------------";
  
  // Because of (naughty) reliance of static constructor to register tests, the order in the list is out of my
  // control. A little extra code to make them run in alphabetical order.
  
  UnitTest* test = FindNext( group, NULL );
  while( test )
  {
    size_t offset = strlen( test->m_Name );
    if( offset >= sizeof( dashes ) )
    {
      offset = sizeof( dashes ) - 1;
    }
    printf( "  %s %s ", test->m_Name, dashes + offset );
    test->m_ErrorCount = 0;
    test->Test();
    if( test->m_ErrorCount == 0 )
    {
      printf( "pass\n" );
    }
    error_count += test->m_ErrorCount;
    test->m_Done = true;
    test = FindNext( group, test );
  }
  return error_count;
}