umd/external/protobuf-2.6/gtest/fused-src/gtest/gtest-all.cc
TestCase* UnitTestImpl::GetTestCase(const char* test_case_name,
                                    const char* comment,
                                    Test::SetUpTestCaseFunc set_up_tc,
                                    Test::TearDownTestCaseFunc tear_down_tc) {
  // Can we find a TestCase with the given name?
  const std::vector<TestCase*>::const_iterator test_case =
      std::find_if(test_cases_.begin(), test_cases_.end(),
                   TestCaseNameIs(test_case_name));

  if (test_case != test_cases_.end())
    return *test_case;

  // No.  Let's create one.
  TestCase* const new_test_case =
      new TestCase(test_case_name, comment, set_up_tc, tear_down_tc);

  // Is this a death test case?
  if (internal::UnitTestOptions::MatchesFilter(String(test_case_name),
                                               kDeathTestCaseFilter)) {
    // Yes.  Inserts the test case after the last death test case
    // defined so far.  This only works when the test cases haven't
    // been shuffled.  Otherwise we may end up running a death test
    // after a non-death test.
    ++last_death_test_case_;
    test_cases_.insert(test_cases_.begin() + last_death_test_case_,
                       new_test_case);
  } else {
    // No.  Appends to the end of the list.
    test_cases_.push_back(new_test_case);
  }

  test_case_indices_.push_back(static_cast<int>(test_case_indices_.size()));
  return new_test_case;
}
// Finds and returns a TestCase with the given name.  If one doesn't
// exist, creates one and returns it.  It's the CALLER'S
// RESPONSIBILITY to ensure that this function is only called WHEN THE
// TESTS ARE NOT SHUFFLED.
//
// Arguments:
//
//   test_case_name: name of the test case
//   set_up_tc:      pointer to the function that sets up the test case
//   tear_down_tc:   pointer to the function that tears down the test case
Finds and returns a TestCase with the given name.  If one doesn't
exist, creates one and returns it.



name of the test case
set_up_tc:      pointer to the function that sets up the test case
tear_down_tc:   pointer to the function that tears down the test case
Finds and returns a TestCase with the given name . If one doesn ' t exist creates one and returns it . name of the test case set_up_tc : pointer to the function that sets up the test case tear_down_tc : pointer to the function that tears down the test case
TestCase* UnitTestImpl::GetTestCase(const char* test_case_name,
                                    const char* comment,
                                    Test::SetUpTestCaseFunc set_up_tc,
                                    Test::TearDownTestCaseFunc tear_down_tc) {
  const std::vector<TestCase*>::const_iterator test_case =
      std::find_if(test_cases_.begin(), test_cases_.end(),
                   TestCaseNameIs(test_case_name));
  if (test_case != test_cases_.end())
    return *test_case;
  TestCase* const new_test_case =
      new TestCase(test_case_name, comment, set_up_tc, tear_down_tc);
  if (internal::UnitTestOptions::MatchesFilter(String(test_case_name),
                                               kDeathTestCaseFilter)) {
    ++last_death_test_case_;
    test_cases_.insert(test_cases_.begin() + last_death_test_case_,
                       new_test_case);
  } else {
    test_cases_.push_back(new_test_case);
  }
  test_case_indices_.push_back(static_cast<int>(test_case_indices_.size()));
  return new_test_case;
}
TestCase * UnitTestImpl :: GetTestCase ( const char * test_case_name , const char * comment , Test :: SetUpTestCaseFunc set_up_tc , Test :: TearDownTestCaseFunc tear_down_tc ) { const std :: vector < TestCase * > :: const_iterator test_case = std :: find_if ( test_cases_ . begin ( ) , test_cases_ . end ( ) , TestCaseNameIs ( test_case_name ) ) ; if ( test_case != test_cases_ . end ( ) ) return * test_case ; TestCase * const new_test_case = new TestCase ( test_case_name , comment , set_up_tc , tear_down_tc ) ; if ( internal :: UnitTestOptions :: MatchesFilter ( String ( test_case_name ) , kDeathTestCaseFilter ) ) { ++ last_death_test_case_ ; test_cases_ . insert ( test_cases_ . begin ( ) + last_death_test_case_ , new_test_case ) ; } else { test_cases_ . push_back ( new_test_case ) ; } test_case_indices_ . push_back ( static_cast < int > ( test_case_indices_ . size ( ) ) ) ; return new_test_case ; }
Finds and returns a TestCase with the given name.
Finds and returns a TestCase with the given name .
// Can we find a TestCase with the given name? // No.  Let's create one. // Is this a death test case? // Yes.  Inserts the test case after the last death test case // defined so far.  This only works when the test cases haven't // been shuffled.  Otherwise we may end up running a death test // after a non-death test. // No.  Appends to the end of the list.