summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2011-01-07 01:14:05 +0000
committerzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2011-01-07 01:14:05 +0000
commitbe1cdf34af6ad71c91488e9a09ad3b9a960c5e48 (patch)
treef2efed81249d99af8092208acd8f1109e2676fdf
parent71874246c3a054977d94fd4729576484c2af62e9 (diff)
downloadgoogletest-be1cdf34af6ad71c91488e9a09ad3b9a960c5e48.tar.gz
Suppresses self-assignment warnings.
git-svn-id: http://googletest.googlecode.com/svn/trunk@529 861a406c-534a-0410-8894-cb66d6ee9925
-rw-r--r--test/gtest-linked_ptr_test.cc3
-rwxr-xr-xtest/gtest_nc_test.py93
-rw-r--r--test/gtest_unittest.cc3
3 files changed, 51 insertions, 48 deletions
diff --git a/test/gtest-linked_ptr_test.cc b/test/gtest-linked_ptr_test.cc
index efd6b1e..0d5508a 100644
--- a/test/gtest-linked_ptr_test.cc
+++ b/test/gtest-linked_ptr_test.cc
@@ -77,7 +77,8 @@ class LinkedPtrTest : public testing::Test {
TEST_F(LinkedPtrTest, GeneralTest) {
{
linked_ptr<A> a0, a1, a2;
- a0 = a0;
+ // Use explicit function call notation here to suppress self-assign warning.
+ a0.operator=(a0);
a1 = a2;
ASSERT_EQ(a0.get(), static_cast<A*>(NULL));
ASSERT_EQ(a1.get(), static_cast<A*>(NULL));
diff --git a/test/gtest_nc_test.py b/test/gtest_nc_test.py
index bf09234..c60b96e 100755
--- a/test/gtest_nc_test.py
+++ b/test/gtest_nc_test.py
@@ -46,68 +46,69 @@ if not IS_LINUX:
class GTestNCTest(unittest.TestCase):
"""Negative compilation test for Google Test."""
- def testCompilerError(self):
- """Verifies that erroneous code leads to expected compiler
- messages."""
+ # The class body is intentionally empty. The actual test*() methods
+ # will be defined at run time by a call to
+ # DefineNegativeCompilationTests() later.
+ pass
- # Defines a list of test specs, where each element is a tuple
- # (test name, list of regexes for matching the compiler errors).
- test_specs = [
- ('CANNOT_IGNORE_RUN_ALL_TESTS_RESULT',
- [r'ignoring return value']),
+# Defines a list of test specs, where each element is a tuple
+# (test name, list of regexes for matching the compiler errors).
+TEST_SPECS = [
+ ('CANNOT_IGNORE_RUN_ALL_TESTS_RESULT',
+ [r'ignoring return value']),
- ('USER_CANNOT_INCLUDE_GTEST_INTERNAL_INL_H',
- [r'must not be included except by Google Test itself']),
+ ('USER_CANNOT_INCLUDE_GTEST_INTERNAL_INL_H',
+ [r'must not be included except by Google Test itself']),
- ('CATCHES_DECLARING_SETUP_IN_TEST_FIXTURE_WITH_TYPO',
- [r'Setup_should_be_spelled_SetUp']),
+ ('CATCHES_DECLARING_SETUP_IN_TEST_FIXTURE_WITH_TYPO',
+ [r'Setup_should_be_spelled_SetUp']),
- ('CATCHES_CALLING_SETUP_IN_TEST_WITH_TYPO',
- [r'Setup_should_be_spelled_SetUp']),
+ ('CATCHES_CALLING_SETUP_IN_TEST_WITH_TYPO',
+ [r'Setup_should_be_spelled_SetUp']),
- ('CATCHES_DECLARING_SETUP_IN_ENVIRONMENT_WITH_TYPO',
- [r'Setup_should_be_spelled_SetUp']),
+ ('CATCHES_DECLARING_SETUP_IN_ENVIRONMENT_WITH_TYPO',
+ [r'Setup_should_be_spelled_SetUp']),
- ('CATCHES_CALLING_SETUP_IN_ENVIRONMENT_WITH_TYPO',
- [r'Setup_should_be_spelled_SetUp']),
+ ('CATCHES_CALLING_SETUP_IN_ENVIRONMENT_WITH_TYPO',
+ [r'Setup_should_be_spelled_SetUp']),
- ('CATCHES_WRONG_CASE_IN_TYPED_TEST_P',
- [r'BarTest.*was not declared', # GCC
- r'undeclared identifier .*BarTest', # Clang
- ]),
+ ('CATCHES_WRONG_CASE_IN_TYPED_TEST_P',
+ [r'BarTest.*was not declared', # GCC
+ r'undeclared identifier .*BarTest', # Clang
+ ]),
- ('CATCHES_WRONG_CASE_IN_REGISTER_TYPED_TEST_CASE_P',
- [r'BarTest.*was not declared', # GCC
- r'undeclared identifier .*BarTest', # Clang
- ]),
+ ('CATCHES_WRONG_CASE_IN_REGISTER_TYPED_TEST_CASE_P',
+ [r'BarTest.*was not declared', # GCC
+ r'undeclared identifier .*BarTest', # Clang
+ ]),
- ('CATCHES_WRONG_CASE_IN_INSTANTIATE_TYPED_TEST_CASE_P',
- [r'BarTest.*not declared', # GCC
- r'undeclared identifier .*BarTest', # Clang
- ]),
+ ('CATCHES_WRONG_CASE_IN_INSTANTIATE_TYPED_TEST_CASE_P',
+ [r'BarTest.*not declared', # GCC
+ r'undeclared identifier .*BarTest', # Clang
+ ]),
- ('CATCHES_INSTANTIATE_TYPED_TESET_CASE_P_WITH_SAME_NAME_PREFIX',
- [r'redefinition of.*My.*FooTest']),
+ ('CATCHES_INSTANTIATE_TYPED_TESET_CASE_P_WITH_SAME_NAME_PREFIX',
+ [r'redefinition of.*My.*FooTest']),
- ('STATIC_ASSERT_TYPE_EQ_IS_NOT_A_TYPE',
- [r'StaticAssertTypeEq.* does not name a type', # GCC
- r'requires a type.*\n.*StaticAssertTypeEq', # Clang
- ]),
+ ('STATIC_ASSERT_TYPE_EQ_IS_NOT_A_TYPE',
+ [r'StaticAssertTypeEq.* does not name a type', # GCC
+ r'requires a type.*\n.*StaticAssertTypeEq', # Clang
+ ]),
- ('STATIC_ASSERT_TYPE_EQ_WORKS_IN_NAMESPACE',
- [r'StaticAssertTypeEq.*int.*const int']),
+ ('STATIC_ASSERT_TYPE_EQ_WORKS_IN_NAMESPACE',
+ [r'StaticAssertTypeEq.*int.*const int']),
- ('STATIC_ASSERT_TYPE_EQ_WORKS_IN_CLASS',
- [r'StaticAssertTypeEq.*int.*bool']),
+ ('STATIC_ASSERT_TYPE_EQ_WORKS_IN_CLASS',
+ [r'StaticAssertTypeEq.*int.*bool']),
- ('STATIC_ASSERT_TYPE_EQ_WORKS_IN_FUNCTION',
- [r'StaticAssertTypeEq.*const int.*int']),
+ ('STATIC_ASSERT_TYPE_EQ_WORKS_IN_FUNCTION',
+ [r'StaticAssertTypeEq.*const int.*int']),
- ('SANITY',
- None)
- ]
+ ('SANITY',
+ None)
+ ]
- # TODO(wan@google.com): verify that the test specs are satisfied.
+# TODO(wan@google.com): verify that the test specs are satisfied.
if __name__ == '__main__':
diff --git a/test/gtest_unittest.cc b/test/gtest_unittest.cc
index 5a93ff2..89a4a0e 100644
--- a/test/gtest_unittest.cc
+++ b/test/gtest_unittest.cc
@@ -1150,7 +1150,8 @@ TEST(StringTest, CanBeAssignedNonEmpty) {
TEST(StringTest, CanBeAssignedSelf) {
String dest("hello");
- dest = dest;
+ // Use explicit function call notation here to suppress self-assign warning.
+ dest.operator=(dest);
EXPECT_STREQ("hello", dest.c_str());
}