mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-25 23:06:10 +01:00
Change how and when anonymous test cases are named
This commit is contained in:
parent
478c324534
commit
e6b9b854b5
@ -46,6 +46,11 @@ namespace Catch {
|
||||
<< "Tag names starting with non alphanumeric characters are reserved\n"
|
||||
<< _lineInfo );
|
||||
}
|
||||
|
||||
std::string makeDefaultName() {
|
||||
static size_t counter = 0;
|
||||
return "Anonymous test case " + std::to_string(++counter);
|
||||
}
|
||||
}
|
||||
|
||||
TestCase makeTestCase( ITestInvoker* _testCase,
|
||||
@ -111,7 +116,7 @@ namespace Catch {
|
||||
std::string const& _className,
|
||||
std::vector<std::string> const& _tags,
|
||||
SourceLineInfo const& _lineInfo )
|
||||
: name( _name ),
|
||||
: name( _name.empty() ? makeDefaultName() : _name ),
|
||||
className( _className ),
|
||||
lineInfo( _lineInfo ),
|
||||
properties( None )
|
||||
|
@ -73,12 +73,6 @@ namespace Catch {
|
||||
}
|
||||
|
||||
void TestRegistry::registerTest( TestCase const& testCase ) {
|
||||
std::string name = testCase.getTestCaseInfo().name;
|
||||
if( name.empty() ) {
|
||||
ReusableStringStream rss;
|
||||
rss << "Anonymous test case " << ++m_unnamedCount;
|
||||
return registerTest( testCase.withName( rss.str() ) );
|
||||
}
|
||||
m_functions.push_back( testCase );
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,6 @@ namespace Catch {
|
||||
std::vector<TestCase> m_functions;
|
||||
mutable RunTests::InWhatOrder m_currentSortOrder = RunTests::InDeclarationOrder;
|
||||
mutable std::vector<TestCase> m_sortedFunctions;
|
||||
std::size_t m_unnamedCount = 0;
|
||||
std::ios_base::Init m_ostreamInit; // Forces cout/ cerr to be initialised
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user