mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 21:05:39 +02:00
Incremental naming for annonymous test cases
This commit is contained in:
@@ -53,6 +53,18 @@ namespace Catch
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
TestCaseInfo
|
||||
(
|
||||
const TestCaseInfo& other,
|
||||
const std::string& name
|
||||
)
|
||||
: m_test( other.m_test->clone() ),
|
||||
m_name( name ),
|
||||
m_description( other.m_description )
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
TestCaseInfo& operator =
|
||||
(
|
||||
|
@@ -16,15 +16,26 @@
|
||||
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
|
||||
namespace Catch
|
||||
{
|
||||
class TestRegistry : public ITestCaseRegistry
|
||||
{
|
||||
public:
|
||||
TestRegistry()
|
||||
: m_unnamedCount( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
virtual void registerTest( const TestCaseInfo& testInfo )
|
||||
{
|
||||
if( testInfo.getName() == "" )
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << testInfo.getName() << "unnamed/" << ++m_unnamedCount;
|
||||
return registerTest( TestCaseInfo( testInfo, oss.str() ) );
|
||||
}
|
||||
if( m_functions.find( testInfo ) == m_functions.end() )
|
||||
{
|
||||
m_functions.insert( testInfo );
|
||||
@@ -41,6 +52,7 @@ namespace Catch
|
||||
|
||||
std::set<TestCaseInfo> m_functions;
|
||||
std::vector<TestCaseInfo> m_functionsInOrder;
|
||||
size_t m_unnamedCount;
|
||||
};
|
||||
|
||||
struct FreeFunctionTestCase : ITestCase
|
||||
|
Reference in New Issue
Block a user