Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorPhil Nash2011-01-18 20:09:21 +0000
committerPhil Nash2011-01-18 20:09:21 +0000
commit2b05dfaf0516df5e8fbe722e43c19d30e9310202 (patch)
tree6ac594a71103415f8166587928d48b3b5f43db11
parentdd7f13ccbb08a1161ac915f10019b485faf2abc8 (diff)
downloadcatch3-2b05dfaf0516df5e8fbe722e43c19d30e9310202.tar.gz
Incremental naming for annonymous test cases
-rw-r--r--catch.hpp2
-rw-r--r--internal/catch_test_case_info.hpp12
-rw-r--r--internal/catch_test_case_registry_impl.hpp12
3 files changed, 25 insertions, 1 deletions
diff --git a/catch.hpp b/catch.hpp
index 34b57b8e..354888e0 100644
--- a/catch.hpp
+++ b/catch.hpp
@@ -52,7 +52,7 @@
#define SECTION( name, description ) CATCH_SECTION( 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 REGISTER_REPORTER( name, reporterType ) CATCH_REGISTER_REPORTER( name, reporterType )
diff --git a/internal/catch_test_case_info.hpp b/internal/catch_test_case_info.hpp
index cdf8e900..51da0320 100644
--- a/internal/catch_test_case_info.hpp
+++ b/internal/catch_test_case_info.hpp
@@ -54,6 +54,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 =
(
const TestCaseInfo& other
diff --git a/internal/catch_test_case_registry_impl.hpp b/internal/catch_test_case_registry_impl.hpp
index 71c65cb8..63686f81 100644
--- a/internal/catch_test_case_registry_impl.hpp
+++ b/internal/catch_test_case_registry_impl.hpp
@@ -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