Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
googletest
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
googletest
Commits
587c1b37
Commit
587c1b37
authored
May 20, 2011
by
vladlosev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds support for building Google Mock as a shared library (DLL).
parent
47be72a9
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
79 additions
and
58 deletions
+79
-58
CMakeLists.txt
CMakeLists.txt
+25
-9
gmock-cardinalities.h
include/gmock/gmock-cardinalities.h
+6
-6
gmock-matchers.h
include/gmock/gmock-matchers.h
+4
-3
gmock-spec-builders.h
include/gmock/gmock-spec-builders.h
+9
-9
gmock.h
include/gmock/gmock.h
+2
-2
gmock-internal-utils.h
include/gmock/internal/gmock-internal-utils.h
+6
-4
gmock-port.h
include/gmock/internal/gmock-port.h
+6
-6
gmock-cardinalities.cc
src/gmock-cardinalities.cc
+5
-5
gmock-internal-utils.cc
src/gmock-internal-utils.cc
+5
-4
gmock-matchers.cc
src/gmock-matchers.cc
+3
-2
gmock-spec-builders.cc
src/gmock-spec-builders.cc
+3
-3
gmock.cc
src/gmock.cc
+2
-2
gmock_main.cc
src/gmock_main.cc
+2
-2
gmock-matchers_test.cc
test/gmock-matchers_test.cc
+1
-1
No files found.
CMakeLists.txt
View file @
587c1b37
...
@@ -9,11 +9,6 @@
...
@@ -9,11 +9,6 @@
# make it prominent in the GUI.
# make it prominent in the GUI.
option
(
BUILD_SHARED_LIBS
"Build shared libraries (DLLs)."
OFF
)
option
(
BUILD_SHARED_LIBS
"Build shared libraries (DLLs)."
OFF
)
# Forces BUILD_SHARED_LIBS to OFF as Google Mock currently does not support
# working in a DLL.
# TODO(vladl@google.com): Implement building gMock as a DLL.
set
(
BUILD_SHARED_LIBS OFF
)
option
(
gmock_build_tests
"Build all of Google Mock's own tests."
OFF
)
option
(
gmock_build_tests
"Build all of Google Mock's own tests."
OFF
)
# A directory to find Google Test sources.
# A directory to find Google Test sources.
...
@@ -76,11 +71,16 @@ include_directories("${gmock_SOURCE_DIR}/include"
...
@@ -76,11 +71,16 @@ include_directories("${gmock_SOURCE_DIR}/include"
# Google Mock libraries. We build them using more strict warnings than what
# Google Mock libraries. We build them using more strict warnings than what
# are used for other targets, to ensure that Google Mock can be compiled by
# are used for other targets, to ensure that Google Mock can be compiled by
# a user aggressive about warnings.
# a user aggressive about warnings.
cxx_library
(
gmock
"
${
cxx_strict
}
"
src/gmock-all.cc
)
cxx_library
(
gmock
target_link_libraries
(
gmock gtest
)
"
${
cxx_strict
}
"
"
${
gtest_dir
}
/src/gtest-all.cc"
src/gmock-all.cc
)
cxx_library
(
gmock_main
"
${
cxx_strict
}
"
src/gmock_main.cc
)
cxx_library
(
gmock_main
target_link_libraries
(
gmock_main gmock
)
"
${
cxx_strict
}
"
"
${
gtest_dir
}
/src/gtest-all.cc"
src/gmock-all.cc
src/gmock_main.cc
)
########################################################################
########################################################################
#
#
...
@@ -129,8 +129,10 @@ if (gmock_build_tests)
...
@@ -129,8 +129,10 @@ if (gmock_build_tests)
cxx_library
(
gmock_main_no_exception
"
${
cxx_no_exception
}
"
cxx_library
(
gmock_main_no_exception
"
${
cxx_no_exception
}
"
"
${
gtest_dir
}
/src/gtest-all.cc"
src/gmock-all.cc src/gmock_main.cc
)
"
${
gtest_dir
}
/src/gtest-all.cc"
src/gmock-all.cc src/gmock_main.cc
)
cxx_library
(
gmock_main_no_rtti
"
${
cxx_no_rtti
}
"
cxx_library
(
gmock_main_no_rtti
"
${
cxx_no_rtti
}
"
"
${
gtest_dir
}
/src/gtest-all.cc"
src/gmock-all.cc src/gmock_main.cc
)
"
${
gtest_dir
}
/src/gtest-all.cc"
src/gmock-all.cc src/gmock_main.cc
)
cxx_library
(
gmock_main_use_own_tuple
"
${
cxx_use_own_tuple
}
"
cxx_library
(
gmock_main_use_own_tuple
"
${
cxx_use_own_tuple
}
"
"
${
gtest_dir
}
/src/gtest-all.cc"
src/gmock-all.cc src/gmock_main.cc
)
"
${
gtest_dir
}
/src/gtest-all.cc"
src/gmock-all.cc src/gmock_main.cc
)
...
@@ -143,6 +145,20 @@ if (gmock_build_tests)
...
@@ -143,6 +145,20 @@ if (gmock_build_tests)
cxx_test_with_flags
(
gmock_use_own_tuple_test
"
${
cxx_use_own_tuple
}
"
cxx_test_with_flags
(
gmock_use_own_tuple_test
"
${
cxx_use_own_tuple
}
"
gmock_main_use_own_tuple test/gmock-spec-builders_test.cc
)
gmock_main_use_own_tuple test/gmock-spec-builders_test.cc
)
cxx_shared_library
(
shared_gmock_main
"
${
cxx_default
}
"
"
${
gtest_dir
}
/src/gtest-all.cc"
src/gmock-all.cc src/gmock_main.cc
)
# Tests that a binary can be built with Google Mock as a shared library. On
# some system configurations, it may not possible to run the binary without
# knowing more details about the system configurations. We do not try to run
# this binary. To get a more robust shared library coverage, configure with
# -DBUILD_SHARED_LIBS=ON.
cxx_executable_with_flags
(
shared_gmock_test_
"
${
cxx_default
}
"
shared_gmock_main test/gmock-spec-builders_test.cc
)
set_target_properties
(
shared_gmock_test_
PROPERTIES
COMPILE_DEFINITIONS
"GTEST_LINKED_AS_SHARED_LIBRARY=1"
)
############################################################
############################################################
# Python tests.
# Python tests.
...
...
include/gmock/gmock-cardinalities.h
View file @
587c1b37
...
@@ -80,7 +80,7 @@ class CardinalityInterface {
...
@@ -80,7 +80,7 @@ class CardinalityInterface {
// be called. The implementation of Cardinality is just a linked_ptr
// be called. The implementation of Cardinality is just a linked_ptr
// to const CardinalityInterface, so copying is fairly cheap.
// to const CardinalityInterface, so copying is fairly cheap.
// Don't inherit from Cardinality!
// Don't inherit from Cardinality!
class
Cardinality
{
class
GTEST_API_
Cardinality
{
public
:
public
:
// Constructs a null cardinality. Needed for storing Cardinality
// Constructs a null cardinality. Needed for storing Cardinality
// objects in STL containers.
// objects in STL containers.
...
@@ -122,19 +122,19 @@ class Cardinality {
...
@@ -122,19 +122,19 @@ class Cardinality {
};
};
// Creates a cardinality that allows at least n calls.
// Creates a cardinality that allows at least n calls.
Cardinality
AtLeast
(
int
n
);
GTEST_API_
Cardinality
AtLeast
(
int
n
);
// Creates a cardinality that allows at most n calls.
// Creates a cardinality that allows at most n calls.
Cardinality
AtMost
(
int
n
);
GTEST_API_
Cardinality
AtMost
(
int
n
);
// Creates a cardinality that allows any number of calls.
// Creates a cardinality that allows any number of calls.
Cardinality
AnyNumber
();
GTEST_API_
Cardinality
AnyNumber
();
// Creates a cardinality that allows between min and max calls.
// Creates a cardinality that allows between min and max calls.
Cardinality
Between
(
int
min
,
int
max
);
GTEST_API_
Cardinality
Between
(
int
min
,
int
max
);
// Creates a cardinality that allows exactly n calls.
// Creates a cardinality that allows exactly n calls.
Cardinality
Exactly
(
int
n
);
GTEST_API_
Cardinality
Exactly
(
int
n
);
// Creates a cardinality from its implementation.
// Creates a cardinality from its implementation.
inline
Cardinality
MakeCardinality
(
const
CardinalityInterface
*
c
)
{
inline
Cardinality
MakeCardinality
(
const
CardinalityInterface
*
c
)
{
...
...
include/gmock/gmock-matchers.h
View file @
587c1b37
...
@@ -268,7 +268,7 @@ class Matcher : public internal::MatcherBase<T> {
...
@@ -268,7 +268,7 @@ class Matcher : public internal::MatcherBase<T> {
// instead of Eq(str) and "foo" instead of Eq("foo") when a string
// instead of Eq(str) and "foo" instead of Eq("foo") when a string
// matcher is expected.
// matcher is expected.
template
<>
template
<>
class
Matcher
<
const
internal
::
string
&>
class
GTEST_API_
Matcher
<
const
internal
::
string
&>
:
public
internal
::
MatcherBase
<
const
internal
::
string
&>
{
:
public
internal
::
MatcherBase
<
const
internal
::
string
&>
{
public
:
public
:
Matcher
()
{}
Matcher
()
{}
...
@@ -285,7 +285,7 @@ class Matcher<const internal::string&>
...
@@ -285,7 +285,7 @@ class Matcher<const internal::string&>
};
};
template
<>
template
<>
class
Matcher
<
internal
::
string
>
class
GTEST_API_
Matcher
<
internal
::
string
>
:
public
internal
::
MatcherBase
<
internal
::
string
>
{
:
public
internal
::
MatcherBase
<
internal
::
string
>
{
public
:
public
:
Matcher
()
{}
Matcher
()
{}
...
@@ -2548,7 +2548,8 @@ class ElementsAreArrayMatcher {
...
@@ -2548,7 +2548,8 @@ class ElementsAreArrayMatcher {
// 'negation' is false; otherwise returns the description of the
// 'negation' is false; otherwise returns the description of the
// negation of the matcher. 'param_values' contains a list of strings
// negation of the matcher. 'param_values' contains a list of strings
// that are the print-out of the matcher's parameters.
// that are the print-out of the matcher's parameters.
string
FormatMatcherDescription
(
bool
negation
,
const
char
*
matcher_name
,
GTEST_API_
string
FormatMatcherDescription
(
bool
negation
,
const
char
*
matcher_name
,
const
Strings
&
param_values
);
const
Strings
&
param_values
);
}
// namespace internal
}
// namespace internal
...
...
include/gmock/gmock-spec-builders.h
View file @
587c1b37
...
@@ -111,7 +111,7 @@ template <typename F> class FunctionMockerBase;
...
@@ -111,7 +111,7 @@ template <typename F> class FunctionMockerBase;
// expectations when InSequence() is used, and thus affect which
// expectations when InSequence() is used, and thus affect which
// expectation gets picked. Therefore, we sequence all mock function
// expectation gets picked. Therefore, we sequence all mock function
// calls to ensure the integrity of the mock objects' states.
// calls to ensure the integrity of the mock objects' states.
GTEST_DECLARE_STATIC_MUTEX_
(
g_gmock_mutex
);
GTEST_
API_
GTEST_
DECLARE_STATIC_MUTEX_
(
g_gmock_mutex
);
// Untyped base class for ActionResultHolder<R>.
// Untyped base class for ActionResultHolder<R>.
class
UntypedActionResultHolderBase
;
class
UntypedActionResultHolderBase
;
...
@@ -119,7 +119,7 @@ class UntypedActionResultHolderBase;
...
@@ -119,7 +119,7 @@ class UntypedActionResultHolderBase;
// Abstract base class of FunctionMockerBase. This is the
// Abstract base class of FunctionMockerBase. This is the
// type-agnostic part of the function mocker interface. Its pure
// type-agnostic part of the function mocker interface. Its pure
// virtual methods are implemented by FunctionMockerBase.
// virtual methods are implemented by FunctionMockerBase.
class
UntypedFunctionMockerBase
{
class
GTEST_API_
UntypedFunctionMockerBase
{
public
:
public
:
UntypedFunctionMockerBase
();
UntypedFunctionMockerBase
();
virtual
~
UntypedFunctionMockerBase
();
virtual
~
UntypedFunctionMockerBase
();
...
@@ -363,7 +363,7 @@ enum CallReaction {
...
@@ -363,7 +363,7 @@ enum CallReaction {
}
// namespace internal
}
// namespace internal
// Utilities for manipulating mock objects.
// Utilities for manipulating mock objects.
class
Mock
{
class
GTEST_API_
Mock
{
public
:
public
:
// The following public methods can be called concurrently.
// The following public methods can be called concurrently.
...
@@ -471,7 +471,7 @@ class Mock {
...
@@ -471,7 +471,7 @@ class Mock {
// ExpectationBase available yet, leading to incorrect destruction
// ExpectationBase available yet, leading to incorrect destruction
// in the linked_ptr (or compilation errors if using a checking
// in the linked_ptr (or compilation errors if using a checking
// linked_ptr).
// linked_ptr).
class
Expectation
{
class
GTEST_API_
Expectation
{
public
:
public
:
// Constructs a null object that doesn't reference any expectation.
// Constructs a null object that doesn't reference any expectation.
Expectation
();
Expectation
();
...
@@ -603,7 +603,7 @@ class ExpectationSet {
...
@@ -603,7 +603,7 @@ class ExpectationSet {
// Sequence objects are used by a user to specify the relative order
// Sequence objects are used by a user to specify the relative order
// in which the expectations should match. They are copyable (we rely
// in which the expectations should match. They are copyable (we rely
// on the compiler-defined copy constructor and assignment operator).
// on the compiler-defined copy constructor and assignment operator).
class
Sequence
{
class
GTEST_API_
Sequence
{
public
:
public
:
// Constructs an empty sequence.
// Constructs an empty sequence.
Sequence
()
:
last_expectation_
(
new
Expectation
)
{}
Sequence
()
:
last_expectation_
(
new
Expectation
)
{}
...
@@ -644,7 +644,7 @@ class Sequence {
...
@@ -644,7 +644,7 @@ class Sequence {
// thread. However, for clarity of your tests we recommend you to set
// thread. However, for clarity of your tests we recommend you to set
// up mocks in the main thread unless you have a good reason not to do
// up mocks in the main thread unless you have a good reason not to do
// so.
// so.
class
InSequence
{
class
GTEST_API_
InSequence
{
public
:
public
:
InSequence
();
InSequence
();
~
InSequence
();
~
InSequence
();
...
@@ -658,7 +658,7 @@ namespace internal {
...
@@ -658,7 +658,7 @@ namespace internal {
// Points to the implicit sequence introduced by a living InSequence
// Points to the implicit sequence introduced by a living InSequence
// object (if any) in the current thread or NULL.
// object (if any) in the current thread or NULL.
extern
ThreadLocal
<
Sequence
*>
g_gmock_implicit_sequence
;
GTEST_API_
extern
ThreadLocal
<
Sequence
*>
g_gmock_implicit_sequence
;
// Base class for implementing expectations.
// Base class for implementing expectations.
//
//
...
@@ -674,7 +674,7 @@ extern ThreadLocal<Sequence*> g_gmock_implicit_sequence;
...
@@ -674,7 +674,7 @@ extern ThreadLocal<Sequence*> g_gmock_implicit_sequence;
// on the template argument of Expectation to the base class.
// on the template argument of Expectation to the base class.
//
//
// This class is internal and mustn't be used by user code directly.
// This class is internal and mustn't be used by user code directly.
class
ExpectationBase
{
class
GTEST_API_
ExpectationBase
{
public
:
public
:
// source_text is the EXPECT_CALL(...) source that created this Expectation.
// source_text is the EXPECT_CALL(...) source that created this Expectation.
ExpectationBase
(
const
char
*
file
,
int
line
,
const
string
&
source_text
);
ExpectationBase
(
const
char
*
file
,
int
line
,
const
string
&
source_text
);
...
@@ -1222,7 +1222,7 @@ class TypedExpectation : public ExpectationBase {
...
@@ -1222,7 +1222,7 @@ class TypedExpectation : public ExpectationBase {
// ::testing::internal and import it into ::testing.
// ::testing::internal and import it into ::testing.
// Logs a message including file and line number information.
// Logs a message including file and line number information.
void
LogWithLocation
(
testing
::
internal
::
LogSeverity
severity
,
GTEST_API_
void
LogWithLocation
(
testing
::
internal
::
LogSeverity
severity
,
const
char
*
file
,
int
line
,
const
char
*
file
,
int
line
,
const
string
&
message
);
const
string
&
message
);
...
...
include/gmock/gmock.h
View file @
587c1b37
...
@@ -82,11 +82,11 @@ GMOCK_DECLARE_string_(verbose);
...
@@ -82,11 +82,11 @@ GMOCK_DECLARE_string_(verbose);
// Since Google Test is needed for Google Mock to work, this function
// Since Google Test is needed for Google Mock to work, this function
// also initializes Google Test and parses its flags, if that hasn't
// also initializes Google Test and parses its flags, if that hasn't
// been done.
// been done.
void
InitGoogleMock
(
int
*
argc
,
char
**
argv
);
GTEST_API_
void
InitGoogleMock
(
int
*
argc
,
char
**
argv
);
// This overloaded version can be used in Windows programs compiled in
// This overloaded version can be used in Windows programs compiled in
// UNICODE mode.
// UNICODE mode.
void
InitGoogleMock
(
int
*
argc
,
wchar_t
**
argv
);
GTEST_API_
void
InitGoogleMock
(
int
*
argc
,
wchar_t
**
argv
);
}
// namespace testing
}
// namespace testing
...
...
include/gmock/internal/gmock-internal-utils.h
View file @
587c1b37
...
@@ -53,7 +53,7 @@ namespace internal {
...
@@ -53,7 +53,7 @@ namespace internal {
// words. Each maximum substring of the form [A-Za-z][a-z]*|\d+ is
// words. Each maximum substring of the form [A-Za-z][a-z]*|\d+ is
// treated as one word. For example, both "FooBar123" and
// treated as one word. For example, both "FooBar123" and
// "foo_bar_123" are converted to "foo bar 123".
// "foo_bar_123" are converted to "foo bar 123".
string
ConvertIdentifierNameToWords
(
const
char
*
id_name
);
GTEST_API_
string
ConvertIdentifierNameToWords
(
const
char
*
id_name
);
// PointeeOf<Pointer>::type is the type of a value pointed to by a
// PointeeOf<Pointer>::type is the type of a value pointed to by a
// Pointer, which can be either a smart pointer or a raw pointer. The
// Pointer, which can be either a smart pointer or a raw pointer. The
...
@@ -271,7 +271,7 @@ class FailureReporterInterface {
...
@@ -271,7 +271,7 @@ class FailureReporterInterface {
};
};
// Returns the failure reporter used by Google Mock.
// Returns the failure reporter used by Google Mock.
FailureReporterInterface
*
GetFailureReporter
();
GTEST_API_
FailureReporterInterface
*
GetFailureReporter
();
// Asserts that condition is true; aborts the process with the given
// Asserts that condition is true; aborts the process with the given
// message if condition is false. We cannot use LOG(FATAL) or CHECK()
// message if condition is false. We cannot use LOG(FATAL) or CHECK()
...
@@ -319,7 +319,7 @@ const char kErrorVerbosity[] = "error";
...
@@ -319,7 +319,7 @@ const char kErrorVerbosity[] = "error";
// Returns true iff a log with the given severity is visible according
// Returns true iff a log with the given severity is visible according
// to the --gmock_verbose flag.
// to the --gmock_verbose flag.
bool
LogIsVisible
(
LogSeverity
severity
);
GTEST_API_
bool
LogIsVisible
(
LogSeverity
severity
);
// Prints the given message to stdout iff 'severity' >= the level
// Prints the given message to stdout iff 'severity' >= the level
// specified by the --gmock_verbose flag. If stack_frames_to_skip >=
// specified by the --gmock_verbose flag. If stack_frames_to_skip >=
...
@@ -328,7 +328,9 @@ bool LogIsVisible(LogSeverity severity);
...
@@ -328,7 +328,9 @@ bool LogIsVisible(LogSeverity severity);
// stack_frames_to_skip is treated as 0, since we don't know which
// stack_frames_to_skip is treated as 0, since we don't know which
// function calls will be inlined by the compiler and need to be
// function calls will be inlined by the compiler and need to be
// conservative.
// conservative.
void
Log
(
LogSeverity
severity
,
const
string
&
message
,
int
stack_frames_to_skip
);
GTEST_API_
void
Log
(
LogSeverity
severity
,
const
string
&
message
,
int
stack_frames_to_skip
);
// TODO(wan@google.com): group all type utilities together.
// TODO(wan@google.com): group all type utilities together.
...
...
include/gmock/internal/gmock-port.h
View file @
587c1b37
...
@@ -61,18 +61,18 @@
...
@@ -61,18 +61,18 @@
#define GMOCK_FLAG(name) FLAGS_gmock_##name
#define GMOCK_FLAG(name) FLAGS_gmock_##name
// Macros for declaring flags.
// Macros for declaring flags.
#define GMOCK_DECLARE_bool_(name) extern bool GMOCK_FLAG(name)
#define GMOCK_DECLARE_bool_(name) extern
GTEST_API_
bool GMOCK_FLAG(name)
#define GMOCK_DECLARE_int32_(name) \
#define GMOCK_DECLARE_int32_(name) \
extern ::testing::internal::Int32 GMOCK_FLAG(name)
extern
GTEST_API_
::testing::internal::Int32 GMOCK_FLAG(name)
#define GMOCK_DECLARE_string_(name) \
#define GMOCK_DECLARE_string_(name) \
extern ::testing::internal::String GMOCK_FLAG(name)
extern
GTEST_API_
::testing::internal::String GMOCK_FLAG(name)
// Macros for defining flags.
// Macros for defining flags.
#define GMOCK_DEFINE_bool_(name, default_val, doc) \
#define GMOCK_DEFINE_bool_(name, default_val, doc) \
bool GMOCK_FLAG(name) = (default_val)
GTEST_API_
bool GMOCK_FLAG(name) = (default_val)
#define GMOCK_DEFINE_int32_(name, default_val, doc) \
#define GMOCK_DEFINE_int32_(name, default_val, doc) \
::testing::internal::Int32 GMOCK_FLAG(name) = (default_val)
GTEST_API_
::testing::internal::Int32 GMOCK_FLAG(name) = (default_val)
#define GMOCK_DEFINE_string_(name, default_val, doc) \
#define GMOCK_DEFINE_string_(name, default_val, doc) \
::testing::internal::String GMOCK_FLAG(name) = (default_val)
GTEST_API_
::testing::internal::String GMOCK_FLAG(name) = (default_val)
#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
src/gmock-cardinalities.cc
View file @
587c1b37
...
@@ -136,20 +136,20 @@ void Cardinality::DescribeActualCallCountTo(int actual_call_count,
...
@@ -136,20 +136,20 @@ void Cardinality::DescribeActualCallCountTo(int actual_call_count,
}
}
// Creates a cardinality that allows at least n calls.
// Creates a cardinality that allows at least n calls.
Cardinality
AtLeast
(
int
n
)
{
return
Between
(
n
,
INT_MAX
);
}
GTEST_API_
Cardinality
AtLeast
(
int
n
)
{
return
Between
(
n
,
INT_MAX
);
}
// Creates a cardinality that allows at most n calls.
// Creates a cardinality that allows at most n calls.
Cardinality
AtMost
(
int
n
)
{
return
Between
(
0
,
n
);
}
GTEST_API_
Cardinality
AtMost
(
int
n
)
{
return
Between
(
0
,
n
);
}
// Creates a cardinality that allows any number of calls.
// Creates a cardinality that allows any number of calls.
Cardinality
AnyNumber
()
{
return
AtLeast
(
0
);
}
GTEST_API_
Cardinality
AnyNumber
()
{
return
AtLeast
(
0
);
}
// Creates a cardinality that allows between min and max calls.
// Creates a cardinality that allows between min and max calls.
Cardinality
Between
(
int
min
,
int
max
)
{
GTEST_API_
Cardinality
Between
(
int
min
,
int
max
)
{
return
Cardinality
(
new
BetweenCardinalityImpl
(
min
,
max
));
return
Cardinality
(
new
BetweenCardinalityImpl
(
min
,
max
));
}
}
// Creates a cardinality that allows exactly n calls.
// Creates a cardinality that allows exactly n calls.
Cardinality
Exactly
(
int
n
)
{
return
Between
(
n
,
n
);
}
GTEST_API_
Cardinality
Exactly
(
int
n
)
{
return
Between
(
n
,
n
);
}
}
// namespace testing
}
// namespace testing
src/gmock-internal-utils.cc
View file @
587c1b37
...
@@ -51,7 +51,7 @@ namespace internal {
...
@@ -51,7 +51,7 @@ namespace internal {
// words. Each maximum substring of the form [A-Za-z][a-z]*|\d+ is
// words. Each maximum substring of the form [A-Za-z][a-z]*|\d+ is
// treated as one word. For example, both "FooBar123" and
// treated as one word. For example, both "FooBar123" and
// "foo_bar_123" are converted to "foo bar 123".
// "foo_bar_123" are converted to "foo bar 123".
string
ConvertIdentifierNameToWords
(
const
char
*
id_name
)
{
GTEST_API_
string
ConvertIdentifierNameToWords
(
const
char
*
id_name
)
{
string
result
;
string
result
;
char
prev_char
=
'\0'
;
char
prev_char
=
'\0'
;
for
(
const
char
*
p
=
id_name
;
*
p
!=
'\0'
;
prev_char
=
*
(
p
++
))
{
for
(
const
char
*
p
=
id_name
;
*
p
!=
'\0'
;
prev_char
=
*
(
p
++
))
{
...
@@ -91,7 +91,7 @@ class GoogleTestFailureReporter : public FailureReporterInterface {
...
@@ -91,7 +91,7 @@ class GoogleTestFailureReporter : public FailureReporterInterface {
// Returns the global failure reporter. Will create a
// Returns the global failure reporter. Will create a
// GoogleTestFailureReporter and return it the first time called.
// GoogleTestFailureReporter and return it the first time called.
FailureReporterInterface
*
GetFailureReporter
()
{
GTEST_API_
FailureReporterInterface
*
GetFailureReporter
()
{
// Points to the global failure reporter used by Google Mock. gcc
// Points to the global failure reporter used by Google Mock. gcc
// guarantees that the following use of failure_reporter is
// guarantees that the following use of failure_reporter is
// thread-safe. We may need to add additional synchronization to
// thread-safe. We may need to add additional synchronization to
...
@@ -107,7 +107,7 @@ static GTEST_DEFINE_STATIC_MUTEX_(g_log_mutex);
...
@@ -107,7 +107,7 @@ static GTEST_DEFINE_STATIC_MUTEX_(g_log_mutex);
// Returns true iff a log with the given severity is visible according
// Returns true iff a log with the given severity is visible according
// to the --gmock_verbose flag.
// to the --gmock_verbose flag.
bool
LogIsVisible
(
LogSeverity
severity
)
{
GTEST_API_
bool
LogIsVisible
(
LogSeverity
severity
)
{
if
(
GMOCK_FLAG
(
verbose
)
==
kInfoVerbosity
)
{
if
(
GMOCK_FLAG
(
verbose
)
==
kInfoVerbosity
)
{
// Always show the log if --gmock_verbose=info.
// Always show the log if --gmock_verbose=info.
return
true
;
return
true
;
...
@@ -128,7 +128,8 @@ bool LogIsVisible(LogSeverity severity) {
...
@@ -128,7 +128,8 @@ bool LogIsVisible(LogSeverity severity) {
// stack_frames_to_skip is treated as 0, since we don't know which
// stack_frames_to_skip is treated as 0, since we don't know which
// function calls will be inlined by the compiler and need to be
// function calls will be inlined by the compiler and need to be
// conservative.
// conservative.
void
Log
(
LogSeverity
severity
,
const
string
&
message
,
GTEST_API_
void
Log
(
LogSeverity
severity
,
const
string
&
message
,
int
stack_frames_to_skip
)
{
int
stack_frames_to_skip
)
{
if
(
!
LogIsVisible
(
severity
))
if
(
!
LogIsVisible
(
severity
))
return
;
return
;
...
...
src/gmock-matchers.cc
View file @
587c1b37
...
@@ -67,7 +67,7 @@ namespace internal {
...
@@ -67,7 +67,7 @@ namespace internal {
// Joins a vector of strings as if they are fields of a tuple; returns
// Joins a vector of strings as if they are fields of a tuple; returns
// the joined string.
// the joined string.
string
JoinAsTuple
(
const
Strings
&
fields
)
{
GTEST_API_
string
JoinAsTuple
(
const
Strings
&
fields
)
{
switch
(
fields
.
size
())
{
switch
(
fields
.
size
())
{
case
0
:
case
0
:
return
""
;
return
""
;
...
@@ -89,7 +89,8 @@ string JoinAsTuple(const Strings& fields) {
...
@@ -89,7 +89,8 @@ string JoinAsTuple(const Strings& fields) {
// 'negation' is false; otherwise returns the description of the
// 'negation' is false; otherwise returns the description of the
// negation of the matcher. 'param_values' contains a list of strings
// negation of the matcher. 'param_values' contains a list of strings
// that are the print-out of the matcher's parameters.
// that are the print-out of the matcher's parameters.
string
FormatMatcherDescription
(
bool
negation
,
const
char
*
matcher_name
,
GTEST_API_
string
FormatMatcherDescription
(
bool
negation
,
const
char
*
matcher_name
,
const
Strings
&
param_values
)
{
const
Strings
&
param_values
)
{
string
result
=
ConvertIdentifierNameToWords
(
matcher_name
);
string
result
=
ConvertIdentifierNameToWords
(
matcher_name
);
if
(
param_values
.
size
()
>=
1
)
if
(
param_values
.
size
()
>=
1
)
...
...
src/gmock-spec-builders.cc
View file @
587c1b37
...
@@ -53,10 +53,10 @@ namespace internal {
...
@@ -53,10 +53,10 @@ namespace internal {
// Protects the mock object registry (in class Mock), all function
// Protects the mock object registry (in class Mock), all function
// mockers, and all expectations.
// mockers, and all expectations.
GTEST_DEFINE_STATIC_MUTEX_
(
g_gmock_mutex
);
GTEST_
API_
GTEST_
DEFINE_STATIC_MUTEX_
(
g_gmock_mutex
);
// Logs a message including file and line number information.
// Logs a message including file and line number information.
void
LogWithLocation
(
testing
::
internal
::
LogSeverity
severity
,
GTEST_API_
void
LogWithLocation
(
testing
::
internal
::
LogSeverity
severity
,
const
char
*
file
,
int
line
,
const
char
*
file
,
int
line
,
const
string
&
message
)
{
const
string
&
message
)
{
::
std
::
ostringstream
s
;
::
std
::
ostringstream
s
;
...
@@ -240,7 +240,7 @@ void ExpectationBase::UntypedTimes(const Cardinality& a_cardinality) {
...
@@ -240,7 +240,7 @@ void ExpectationBase::UntypedTimes(const Cardinality& a_cardinality) {
// Points to the implicit sequence introduced by a living InSequence
// Points to the implicit sequence introduced by a living InSequence
// object (if any) in the current thread or NULL.
// object (if any) in the current thread or NULL.
ThreadLocal
<
Sequence
*>
g_gmock_implicit_sequence
;
GTEST_API_
ThreadLocal
<
Sequence
*>
g_gmock_implicit_sequence
;
// Reports an uninteresting call (whose description is in msg) in the
// Reports an uninteresting call (whose description is in msg) in the
// manner specified by 'reaction'.
// manner specified by 'reaction'.
...
...
src/gmock.cc
View file @
587c1b37
...
@@ -169,13 +169,13 @@ void InitGoogleMockImpl(int* argc, CharType** argv) {
...
@@ -169,13 +169,13 @@ void InitGoogleMockImpl(int* argc, CharType** argv) {
// Since Google Test is needed for Google Mock to work, this function
// Since Google Test is needed for Google Mock to work, this function
// also initializes Google Test and parses its flags, if that hasn't
// also initializes Google Test and parses its flags, if that hasn't
// been done.
// been done.
void
InitGoogleMock
(
int
*
argc
,
char
**
argv
)
{
GTEST_API_
void
InitGoogleMock
(
int
*
argc
,
char
**
argv
)
{
internal
::
InitGoogleMockImpl
(
argc
,
argv
);
internal
::
InitGoogleMockImpl
(
argc
,
argv
);
}
}
// This overloaded version can be used in Windows programs compiled in
// This overloaded version can be used in Windows programs compiled in
// UNICODE mode.
// UNICODE mode.
void
InitGoogleMock
(
int
*
argc
,
wchar_t
**
argv
)
{
GTEST_API_
void
InitGoogleMock
(
int
*
argc
,
wchar_t
**
argv
)
{
internal
::
InitGoogleMockImpl
(
argc
,
argv
);
internal
::
InitGoogleMockImpl
(
argc
,
argv
);
}
}
...
...
src/gmock_main.cc
View file @
587c1b37
...
@@ -41,9 +41,9 @@
...
@@ -41,9 +41,9 @@
#if GTEST_OS_WINDOWS_MOBILE
#if GTEST_OS_WINDOWS_MOBILE
# include <tchar.h> // NOLINT
# include <tchar.h> // NOLINT
int
_tmain
(
int
argc
,
TCHAR
**
argv
)
{
GTEST_API_
int
_tmain
(
int
argc
,
TCHAR
**
argv
)
{
#else
#else
int
main
(
int
argc
,
char
**
argv
)
{
GTEST_API_
int
main
(
int
argc
,
char
**
argv
)
{
#endif // GTEST_OS_WINDOWS_MOBILE
#endif // GTEST_OS_WINDOWS_MOBILE
std
::
cout
<<
"Running main() from gmock_main.cc
\n
"
;
std
::
cout
<<
"Running main() from gmock_main.cc
\n
"
;
// Since Google Mock depends on Google Test, InitGoogleMock() is
// Since Google Mock depends on Google Test, InitGoogleMock() is
...
...
test/gmock-matchers_test.cc
View file @
587c1b37
...
@@ -52,7 +52,7 @@
...
@@ -52,7 +52,7 @@
namespace
testing
{
namespace
testing
{
namespace
internal
{
namespace
internal
{
string
JoinAsTuple
(
const
Strings
&
fields
);
GTEST_API_
string
JoinAsTuple
(
const
Strings
&
fields
);
}
// namespace internal
}
// namespace internal
namespace
gmock_matchers_test
{
namespace
gmock_matchers_test
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment