aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2013-03-12 21:17:22 +0000
committerzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2013-03-12 21:17:22 +0000
commit726afc27a7873cb99e562df47d57188a09464fa5 (patch)
treee4390e8a41ccad9936210f3a2cf8105214318340 /include
parent4036e7d55c332d45cfb3f22ed682acce2b8390fd (diff)
downloadgtest-726afc27a7873cb99e562df47d57188a09464fa5.tar.gz
Prints a useful message when GetParam() is called in a non-parameterized test.
git-svn-id: http://googletest.googlecode.com/svn/trunk@645 861a406c-534a-0410-8894-cb66d6ee9925
Diffstat (limited to 'include')
-rw-r--r--include/gtest/gtest.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/include/gtest/gtest.h b/include/gtest/gtest.h
index 6d13ff6..e2f9a99 100644
--- a/include/gtest/gtest.h
+++ b/include/gtest/gtest.h
@@ -1755,7 +1755,12 @@ class WithParamInterface {
// references static data, to reduce the opportunity for incorrect uses
// like writing 'WithParamInterface<bool>::GetParam()' for a test that
// uses a fixture whose parameter type is int.
- const ParamType& GetParam() const { return *parameter_; }
+ const ParamType& GetParam() const {
+ GTEST_CHECK_(parameter_ != NULL)
+ << "GetParam() can only be called inside a value-parameterized test "
+ << "-- did you intend to write TEST_P instead of TEST_F?";
+ return *parameter_;
+ }
private:
// Sets parameter value. The caller is responsible for making sure the value