packages/Utils/gtest/Test.cc
//---------------------------------------------------------------------------//
/*!
 * \brief Generate test-unique filename.
 */
\brief Generate test-unique filename.
\ brief Generate test - unique filename .
std::string Test::make_unique_filename(const char* ext)
{
    REQUIRE(ext);
    const ::testing::TestInfo* const test_info =
        ::testing::UnitTest::GetInstance()->current_test_info();
    CHECK(test_info);
    std::string case_name = profugus::lower(test_info->test_case_name());
    auto pos = case_name.find("test");
    if (pos != std::string::npos)
    {
        case_name.replace(pos, 4, "", 0);
    }
    if (!case_name.empty() && case_name.front() == '_')
    {
        case_name.erase(case_name.begin(), case_name.begin() + 1);
    }
    std::ostringstream os;
    os << case_name << '-' << test_info->name();
    if (d_filename_counter)
    {
        os << '-' << d_filename_counter;
    }
    ++d_filename_counter;
#ifdef USE_MPI
    os << "-np" << nodes;
#endif
    os << ext;
    return os.str();
}
std :: string Test :: make_unique_filename ( const char * ext ) { REQUIRE ( ext ) ; const :: testing :: TestInfo * const test_info = :: testing :: UnitTest :: GetInstance ( ) -> current_test_info ( ) ; CHECK ( test_info ) ; std :: string case_name = profugus :: lower ( test_info -> test_case_name ( ) ) ; auto pos = case_name . find ( " " ) ; if ( pos != std :: string :: npos ) { case_name . replace ( pos , 4 , " " , 0 ) ; } if ( ! case_name . empty ( ) && case_name . front ( ) == ' ' ) { case_name . erase ( case_name . begin ( ) , case_name . begin ( ) + 1 ) ; } std :: ostringstream os ; os << case_name << ' ' << test_info -> name ( ) ; if ( d_filename_counter ) { os << ' ' << d_filename_counter ; } ++ d_filename_counter ; #ifdef USE_MPI os << " " << nodes ; #endif os << ext ; return os . str ( ) ; }
\brief Generate test-unique filename.
\ brief Generate test - unique filename .
// Get filename based on unit test name // Convert test case to lowercase // Delete "Test" if present // Delete leading underscore