mirror of
https://github.com/google/googletest.git
synced 2024-12-28 19:15:24 +08:00
Fixes Cygwin compatibility (by Vlad Losev); Improves Python tests (by Vlad Losev); Fixes ambiguous call to implicit_cast; Uses gtest's SkipPrefix() instead gmock's own (by Vlad Losev).
This commit is contained in:
parent
19eb9e9e3d
commit
f6d6a22b8e
@ -123,7 +123,7 @@ inline To down_cast(From* f) { // so we only accept pointers
|
|||||||
// completely.
|
// completely.
|
||||||
if (false) {
|
if (false) {
|
||||||
const To to = NULL;
|
const To to = NULL;
|
||||||
implicit_cast<From*>(to);
|
::testing::internal::implicit_cast<From*>(to);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if GTEST_HAS_RTTI
|
#if GTEST_HAS_RTTI
|
||||||
|
@ -194,9 +194,6 @@ GtestTest(env, 'gmock_test', [gtest, gmock_main])
|
|||||||
# gmock_all_test is commented to save time building and running tests.
|
# gmock_all_test is commented to save time building and running tests.
|
||||||
# Uncomment if necessary.
|
# Uncomment if necessary.
|
||||||
#GtestTest(env, 'gmock_all_test', [gtest, gmock_main])
|
#GtestTest(env, 'gmock_all_test', [gtest, gmock_main])
|
||||||
# TODO (vladl): Add a test verifying that gmock can be built from
|
|
||||||
# testing/base/gunit.cc and testing/base/internal/gmock-all.cc after merging
|
|
||||||
# into the main branch. This is the API for Windows users.
|
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# Tests targets using custom environments.
|
# Tests targets using custom environments.
|
||||||
|
@ -83,18 +83,6 @@ int GetParamIndex(const char* param_names[], const string& param_name) {
|
|||||||
return kInvalidInterpolation;
|
return kInvalidInterpolation;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If *pstr starts with the given prefix, modifies *pstr to be right
|
|
||||||
// past the prefix and returns true; otherwise leaves *pstr unchanged
|
|
||||||
// and returns false. None of pstr, *pstr, and prefix can be NULL.
|
|
||||||
bool SkipPrefix(const char* prefix, const char** pstr) {
|
|
||||||
const size_t prefix_len = strlen(prefix);
|
|
||||||
if (strncmp(*pstr, prefix, prefix_len) == 0) {
|
|
||||||
*pstr += prefix_len;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helper function used by ValidateMatcherDescription() to format
|
// Helper function used by ValidateMatcherDescription() to format
|
||||||
// error messages.
|
// error messages.
|
||||||
string FormatMatcherDescriptionSyntaxError(const char* description,
|
string FormatMatcherDescriptionSyntaxError(const char* description,
|
||||||
|
@ -443,8 +443,14 @@ TEST(PrintPointerToPointerTest, IntPointerPointer) {
|
|||||||
void MyFunction(int n) {}
|
void MyFunction(int n) {}
|
||||||
|
|
||||||
TEST(PrintPointerTest, NonMemberFunctionPointer) {
|
TEST(PrintPointerTest, NonMemberFunctionPointer) {
|
||||||
EXPECT_EQ(PrintPointer(reinterpret_cast<const void*>(&MyFunction)),
|
// We cannot directly cast &MyFunction to const void* because the
|
||||||
Print(&MyFunction));
|
// 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
|
int (*p)(bool) = NULL; // NOLINT
|
||||||
EXPECT_EQ("NULL", Print(p));
|
EXPECT_EQ("NULL", Print(p));
|
||||||
}
|
}
|
||||||
@ -973,7 +979,12 @@ TEST(PrintReferenceTest, HandlesFunctionPointer) {
|
|||||||
void (*fp)(int n) = &MyFunction;
|
void (*fp)(int n) = &MyFunction;
|
||||||
const string fp_pointer_string =
|
const string fp_pointer_string =
|
||||||
PrintPointer(reinterpret_cast<const void*>(&fp));
|
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,
|
EXPECT_EQ("@" + fp_pointer_string + " " + fp_string,
|
||||||
PrintByRef(fp));
|
PrintByRef(fp));
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,6 @@
|
|||||||
|
|
||||||
__author__ = 'wan@google.com (Zhanyong Wan)'
|
__author__ = 'wan@google.com (Zhanyong Wan)'
|
||||||
|
|
||||||
import os
|
|
||||||
import unittest
|
|
||||||
|
|
||||||
import gmock_test_utils
|
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*']
|
TEST_MULTIPLE_LEAKS = [PROGRAM_PATH, '--gtest_filter=*MultipleLeaked*']
|
||||||
|
|
||||||
|
|
||||||
class GMockLeakTest(unittest.TestCase):
|
class GMockLeakTest(gmock_test_utils.TestCase):
|
||||||
|
|
||||||
def testCatchesLeakedMockByDefault(self):
|
def testCatchesLeakedMockByDefault(self):
|
||||||
self.assertNotEqual(
|
self.assertNotEqual(
|
||||||
|
@ -43,7 +43,6 @@ __author__ = 'wan@google.com (Zhanyong Wan)'
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import unittest
|
|
||||||
|
|
||||||
import gmock_test_utils
|
import gmock_test_utils
|
||||||
|
|
||||||
@ -154,7 +153,7 @@ def GetNormalizedCommandOutputAndLeakyTests(cmd):
|
|||||||
return GetNormalizedOutputAndLeakyTests(GetShellCommandOutput(cmd))
|
return GetNormalizedOutputAndLeakyTests(GetShellCommandOutput(cmd))
|
||||||
|
|
||||||
|
|
||||||
class GMockOutputTest(unittest.TestCase):
|
class GMockOutputTest(gmock_test_utils.TestCase):
|
||||||
def testOutput(self):
|
def testOutput(self):
|
||||||
(output, leaky_tests) = GetNormalizedCommandOutputAndLeakyTests(COMMAND)
|
(output, leaky_tests) = GetNormalizedCommandOutputAndLeakyTests(COMMAND)
|
||||||
golden_file = open(GOLDEN_PATH, 'rb')
|
golden_file = open(GOLDEN_PATH, 'rb')
|
||||||
|
@ -36,6 +36,7 @@ __author__ = 'wan@google.com (Zhanyong Wan)'
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
# Determines path to gtest_test_utils and imports it.
|
# Determines path to gtest_test_utils and imports it.
|
||||||
SCRIPT_DIR = os.path.dirname(__file__) or '.'
|
SCRIPT_DIR = os.path.dirname(__file__) or '.'
|
||||||
|
|
||||||
@ -144,8 +145,16 @@ def GetExitStatus(exit_code):
|
|||||||
return -1
|
return -1
|
||||||
|
|
||||||
|
|
||||||
|
# Suppresses the "Invalid const name" lint complaint
|
||||||
|
# pylint: disable-msg=C6409
|
||||||
|
|
||||||
# Exposes Subprocess from gtest_test_utils.
|
# 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():
|
def Main():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user