diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/gmock-printers_test.cc | 17 | ||||
-rwxr-xr-x | test/gmock_leak_test.py | 4 | ||||
-rwxr-xr-x | test/gmock_output_test.py | 3 | ||||
-rwxr-xr-x | test/gmock_test_utils.py | 11 |
4 files changed, 26 insertions, 9 deletions
diff --git a/test/gmock-printers_test.cc b/test/gmock-printers_test.cc index c72e3d3d..e1956202 100644 --- a/test/gmock-printers_test.cc +++ b/test/gmock-printers_test.cc @@ -443,8 +443,14 @@ TEST(PrintPointerToPointerTest, IntPointerPointer) { void MyFunction(int n) {} TEST(PrintPointerTest, NonMemberFunctionPointer) { - EXPECT_EQ(PrintPointer(reinterpret_cast<const void*>(&MyFunction)), - Print(&MyFunction)); + // We cannot directly cast &MyFunction to const void* because the + // standard disallows casting between pointers to functions and + // pointers to objects, and some compilers (e.g. GCC 3.4) enforce + // this limitation. + EXPECT_EQ( + PrintPointer(reinterpret_cast<const void*>( + reinterpret_cast<internal::BiggestInt>(&MyFunction))), + Print(&MyFunction)); int (*p)(bool) = NULL; // NOLINT EXPECT_EQ("NULL", Print(p)); } @@ -973,7 +979,12 @@ TEST(PrintReferenceTest, HandlesFunctionPointer) { void (*fp)(int n) = &MyFunction; const string fp_pointer_string = PrintPointer(reinterpret_cast<const void*>(&fp)); - const string fp_string = PrintPointer(reinterpret_cast<const void*>(fp)); + // We cannot directly cast &MyFunction to const void* because the + // standard disallows casting between pointers to functions and + // pointers to objects, and some compilers (e.g. GCC 3.4) enforce + // this limitation. + const string fp_string = PrintPointer(reinterpret_cast<const void*>( + reinterpret_cast<internal::BiggestInt>(fp))); EXPECT_EQ("@" + fp_pointer_string + " " + fp_string, PrintByRef(fp)); } diff --git a/test/gmock_leak_test.py b/test/gmock_leak_test.py index 429cc6ad..38ff9d01 100755 --- a/test/gmock_leak_test.py +++ b/test/gmock_leak_test.py @@ -33,8 +33,6 @@ __author__ = 'wan@google.com (Zhanyong Wan)' -import os -import unittest import gmock_test_utils @@ -45,7 +43,7 @@ TEST_WITH_ON_CALL = [PROGRAM_PATH, '--gtest_filter=*OnCall*'] TEST_MULTIPLE_LEAKS = [PROGRAM_PATH, '--gtest_filter=*MultipleLeaked*'] -class GMockLeakTest(unittest.TestCase): +class GMockLeakTest(gmock_test_utils.TestCase): def testCatchesLeakedMockByDefault(self): self.assertNotEqual( diff --git a/test/gmock_output_test.py b/test/gmock_output_test.py index c5f05b34..614a58fa 100755 --- a/test/gmock_output_test.py +++ b/test/gmock_output_test.py @@ -43,7 +43,6 @@ __author__ = 'wan@google.com (Zhanyong Wan)' import os import re import sys -import unittest import gmock_test_utils @@ -154,7 +153,7 @@ def GetNormalizedCommandOutputAndLeakyTests(cmd): return GetNormalizedOutputAndLeakyTests(GetShellCommandOutput(cmd)) -class GMockOutputTest(unittest.TestCase): +class GMockOutputTest(gmock_test_utils.TestCase): def testOutput(self): (output, leaky_tests) = GetNormalizedCommandOutputAndLeakyTests(COMMAND) golden_file = open(GOLDEN_PATH, 'rb') diff --git a/test/gmock_test_utils.py b/test/gmock_test_utils.py index ae15a108..fa896a47 100755 --- a/test/gmock_test_utils.py +++ b/test/gmock_test_utils.py @@ -36,6 +36,7 @@ __author__ = 'wan@google.com (Zhanyong Wan)' import os import sys + # Determines path to gtest_test_utils and imports it. SCRIPT_DIR = os.path.dirname(__file__) or '.' @@ -144,8 +145,16 @@ def GetExitStatus(exit_code): return -1 +# Suppresses the "Invalid const name" lint complaint +# pylint: disable-msg=C6409 + # Exposes Subprocess from gtest_test_utils. -Subprocess = gtest_test_utils.Subprocess # pylint: disable-msg=C6409 +Subprocess = gtest_test_utils.Subprocess + +# Exposes TestCase from gtest_test_utils. +TestCase = gtest_test_utils.TestCase + +# pylint: enable-msg=C6409 def Main(): |