mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 15:26:11 +01:00
Incremental naming for annonymous test cases
This commit is contained in:
parent
dd7f13ccbb
commit
2b05dfaf05
@ -52,7 +52,7 @@
|
|||||||
#define SECTION( name, description ) CATCH_SECTION( name, description )
|
#define SECTION( name, description ) CATCH_SECTION( name, description )
|
||||||
|
|
||||||
#define TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
|
#define TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
|
||||||
#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "anon", "Anonymous test case" )
|
#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "Anonymous test case" )
|
||||||
#define METHOD_AS_TEST_CASE( method, name, description ) CATCH_METHOD_AS_TEST_CASE( method, name, description )
|
#define METHOD_AS_TEST_CASE( method, name, description ) CATCH_METHOD_AS_TEST_CASE( method, name, description )
|
||||||
|
|
||||||
#define REGISTER_REPORTER( name, reporterType ) CATCH_REGISTER_REPORTER( name, reporterType )
|
#define REGISTER_REPORTER( name, reporterType ) CATCH_REGISTER_REPORTER( name, reporterType )
|
||||||
|
@ -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 =
|
TestCaseInfo& operator =
|
||||||
(
|
(
|
||||||
|
@ -16,15 +16,26 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
namespace Catch
|
namespace Catch
|
||||||
{
|
{
|
||||||
class TestRegistry : public ITestCaseRegistry
|
class TestRegistry : public ITestCaseRegistry
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
TestRegistry()
|
||||||
|
: m_unnamedCount( 0 )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
virtual void registerTest( const TestCaseInfo& testInfo )
|
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() )
|
if( m_functions.find( testInfo ) == m_functions.end() )
|
||||||
{
|
{
|
||||||
m_functions.insert( testInfo );
|
m_functions.insert( testInfo );
|
||||||
@ -41,6 +52,7 @@ namespace Catch
|
|||||||
|
|
||||||
std::set<TestCaseInfo> m_functions;
|
std::set<TestCaseInfo> m_functions;
|
||||||
std::vector<TestCaseInfo> m_functionsInOrder;
|
std::vector<TestCaseInfo> m_functionsInOrder;
|
||||||
|
size_t m_unnamedCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FreeFunctionTestCase : ITestCase
|
struct FreeFunctionTestCase : ITestCase
|
||||||
|
Loading…
Reference in New Issue
Block a user