aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2011-02-02 00:49:33 +0000
committerzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2011-02-02 00:49:33 +0000
commit9bcf4d0a654b27732e2fa901fe98c09aba71773a (patch)
treed2072cc7bdd2f9df2f35f85258d8c0e10e80691a /include
parentc8efea670544c86a169f920c567a9dae86227e95 (diff)
downloadgoogletest-9bcf4d0a654b27732e2fa901fe98c09aba71773a.tar.gz
googletest-9bcf4d0a654b27732e2fa901fe98c09aba71773a.tar.bz2
googletest-9bcf4d0a654b27732e2fa901fe98c09aba71773a.zip
Adds type_param and value_param as <testcase> attributes to the XML
report; also removes the comment() and test_case_comment() fields of TestInfo. Proposed and initally implemented by Joey Oravec. Re-implemented by Vlad Losev.
Diffstat (limited to 'include')
-rw-r--r--include/gtest/gtest.h50
-rw-r--r--include/gtest/internal/gtest-internal.h17
-rw-r--r--include/gtest/internal/gtest-param-util.h5
3 files changed, 48 insertions, 24 deletions
diff --git a/include/gtest/gtest.h b/include/gtest/gtest.h
index 79e604ca..741a3607 100644
--- a/include/gtest/gtest.h
+++ b/include/gtest/gtest.h
@@ -634,11 +634,21 @@ class GTEST_API_ TestInfo {
// Returns the test name.
const char* name() const { return name_.c_str(); }
- // Returns the test case comment.
- const char* test_case_comment() const { return test_case_comment_.c_str(); }
+ // Returns the name of the parameter type, or NULL if this is not a typed
+ // or a type-parameterized test.
+ const char* type_param() const {
+ if (type_param_.get() != NULL)
+ return type_param_->c_str();
+ return NULL;
+ }
- // Returns the test comment.
- const char* comment() const { return comment_.c_str(); }
+ // Returns the text representation of the value parameter, or NULL if this
+ // is not a value-parameterized test.
+ const char* value_param() const {
+ if (value_param_.get() != NULL)
+ return value_param_->c_str();
+ return NULL;
+ }
// Returns true if this test should run, that is if the test is not disabled
// (or it is disabled but the also_run_disabled_tests flag has been specified)
@@ -670,7 +680,8 @@ class GTEST_API_ TestInfo {
friend class internal::UnitTestImpl;
friend TestInfo* internal::MakeAndRegisterTestInfo(
const char* test_case_name, const char* name,
- const char* test_case_comment, const char* comment,
+ const char* type_param,
+ const char* value_param,
internal::TypeId fixture_class_id,
Test::SetUpTestCaseFunc set_up_tc,
Test::TearDownTestCaseFunc tear_down_tc,
@@ -679,7 +690,8 @@ class GTEST_API_ TestInfo {
// Constructs a TestInfo object. The newly constructed instance assumes
// ownership of the factory object.
TestInfo(const char* test_case_name, const char* name,
- const char* test_case_comment, const char* comment,
+ const char* a_type_param,
+ const char* a_value_param,
internal::TypeId fixture_class_id,
internal::TestFactoryBase* factory);
@@ -700,8 +712,12 @@ class GTEST_API_ TestInfo {
// These fields are immutable properties of the test.
const std::string test_case_name_; // Test case name
const std::string name_; // Test name
- const std::string test_case_comment_; // Test case comment
- const std::string comment_; // Test comment
+ // Name of the parameter type, or NULL if this is not a typed or a
+ // type-parameterized test.
+ const internal::scoped_ptr<const ::std::string> type_param_;
+ // Text representation of the value parameter, or NULL if this is not a
+ // value-parameterized test.
+ const internal::scoped_ptr<const ::std::string> value_param_;
const internal::TypeId fixture_class_id_; // ID of the test fixture class
bool should_run_; // True iff this test should run
bool is_disabled_; // True iff this test is disabled
@@ -730,9 +746,11 @@ class GTEST_API_ TestCase {
// Arguments:
//
// name: name of the test case
+ // a_type_param: the name of the test's type parameter, or NULL if
+ // this is not a type-parameterized test.
// set_up_tc: pointer to the function that sets up the test case
// tear_down_tc: pointer to the function that tears down the test case
- TestCase(const char* name, const char* comment,
+ TestCase(const char* name, const char* a_type_param,
Test::SetUpTestCaseFunc set_up_tc,
Test::TearDownTestCaseFunc tear_down_tc);
@@ -742,8 +760,13 @@ class GTEST_API_ TestCase {
// Gets the name of the TestCase.
const char* name() const { return name_.c_str(); }
- // Returns the test case comment.
- const char* comment() const { return comment_.c_str(); }
+ // Returns the name of the parameter type, or NULL if this is not a
+ // type-parameterized test case.
+ const char* type_param() const {
+ if (type_param_.get() != NULL)
+ return type_param_->c_str();
+ return NULL;
+ }
// Returns true if any test in this test case should run.
bool should_run() const { return should_run_; }
@@ -846,8 +869,9 @@ class GTEST_API_ TestCase {
// Name of the test case.
internal::String name_;
- // Comment on the test case.
- internal::String comment_;
+ // Name of the parameter type, or NULL if this is not a typed or a
+ // type-parameterized test.
+ const internal::scoped_ptr<const ::std::string> type_param_;
// The vector of TestInfos in their original order. It owns the
// elements in the vector.
std::vector<TestInfo*> test_info_list_;
diff --git a/include/gtest/internal/gtest-internal.h b/include/gtest/internal/gtest-internal.h
index 2c082382..23fcef78 100644
--- a/include/gtest/internal/gtest-internal.h
+++ b/include/gtest/internal/gtest-internal.h
@@ -561,10 +561,10 @@ typedef void (*TearDownTestCaseFunc)();
//
// test_case_name: name of the test case
// name: name of the test
-// test_case_comment: a comment on the test case that will be included in
-// the test output
-// comment: a comment on the test that will be included in the
-// test output
+// type_param the name of the test's type parameter, or NULL if
+// this is not a typed or a type-parameterized test.
+// value_param text representation of the test's value parameter,
+// or NULL if this is not a type-parameterized test.
// fixture_class_id: ID of the test fixture class
// set_up_tc: pointer to the function that sets up the test case
// tear_down_tc: pointer to the function that tears down the test case
@@ -573,7 +573,8 @@ typedef void (*TearDownTestCaseFunc)();
// ownership of the factory object.
GTEST_API_ TestInfo* MakeAndRegisterTestInfo(
const char* test_case_name, const char* name,
- const char* test_case_comment, const char* comment,
+ const char* type_param,
+ const char* value_param,
TypeId fixture_class_id,
SetUpTestCaseFunc set_up_tc,
TearDownTestCaseFunc tear_down_tc,
@@ -662,8 +663,8 @@ class TypeParameterizedTest {
String::Format("%s%s%s/%d", prefix, prefix[0] == '\0' ? "" : "/",
case_name, index).c_str(),
GetPrefixUntilComma(test_names).c_str(),
- String::Format("TypeParam = %s", GetTypeName<Type>().c_str()).c_str(),
- "",
+ GetTypeName<Type>().c_str(),
+ NULL, // No value parameter.
GetTypeId<FixtureClass>(),
TestClass::SetUpTestCase,
TestClass::TearDownTestCase,
@@ -1197,7 +1198,7 @@ class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) : public parent_class {\
::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_case_name, test_name)\
::test_info_ =\
::testing::internal::MakeAndRegisterTestInfo(\
- #test_case_name, #test_name, "", "", \
+ #test_case_name, #test_name, NULL, NULL, \
(parent_id), \
parent_class::SetUpTestCase, \
parent_class::TearDownTestCase, \
diff --git a/include/gtest/internal/gtest-param-util.h b/include/gtest/internal/gtest-param-util.h
index d923b7d8..61c3e378 100644
--- a/include/gtest/internal/gtest-param-util.h
+++ b/include/gtest/internal/gtest-param-util.h
@@ -505,12 +505,11 @@ class ParameterizedTestCaseInfo : public ParameterizedTestCaseInfoBase {
param_it != generator.end(); ++param_it, ++i) {
Message test_name_stream;
test_name_stream << test_info->test_base_name.c_str() << "/" << i;
- std::string comment = "GetParam() = " + PrintToString(*param_it);
MakeAndRegisterTestInfo(
test_case_name_stream.GetString().c_str(),
test_name_stream.GetString().c_str(),
- "", // test_case_comment
- comment.c_str(),
+ NULL, // No type parameter.
+ PrintToString(*param_it).c_str(),
GetTestCaseTypeId(),
TestCase::SetUpTestCase,
TestCase::TearDownTestCase,