Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
78579756
Unverified
Commit
78579756
authored
Mar 26, 2018
by
Gennadiy Civil
Committed by
GitHub
Mar 26, 2018
Browse files
Merge pull request #1512 from gennadiycivil/master
merges, gmock - 1
parents
dfa853b6
6aae206b
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
662 additions
and
119 deletions
+662
-119
googlemock/include/gmock/gmock-matchers.h
googlemock/include/gmock/gmock-matchers.h
+587
-83
googlemock/src/gmock-matchers.cc
googlemock/src/gmock-matchers.cc
+42
-35
googlemock/test/gmock-internal-utils_test.cc
googlemock/test/gmock-internal-utils_test.cc
+28
-0
googlemock/test/gmock_output_test_.cc
googlemock/test/gmock_output_test_.cc
+5
-1
No files found.
googlemock/include/gmock/gmock-matchers.h
View file @
78579756
This diff is collapsed.
Click to expand it.
googlemock/src/gmock-matchers.cc
View file @
78579756
...
...
@@ -44,60 +44,67 @@
namespace
testing
{
// Constructs a matcher that matches a const string& whose value is
// Constructs a matcher that matches a const
std::
string& whose value is
// equal to s.
Matcher
<
const
internal
::
string
&>::
Matcher
(
const
internal
::
string
&
s
)
{
*
this
=
Eq
(
s
);
Matcher
<
const
std
::
string
&>::
Matcher
(
const
std
::
string
&
s
)
{
*
this
=
Eq
(
s
);
}
#if GTEST_HAS_GLOBAL_STRING
// Constructs a matcher that matches a const std::string& whose value is
// equal to s.
Matcher
<
const
std
::
string
&>::
Matcher
(
const
::
string
&
s
)
{
*
this
=
Eq
(
static_cast
<
std
::
string
>
(
s
));
}
#endif // GTEST_HAS_GLOBAL_STRING
// Constructs a matcher that matches a const string& whose value is
// Constructs a matcher that matches a const
std::
string& whose value is
// equal to s.
Matcher
<
const
internal
::
string
&>::
Matcher
(
const
char
*
s
)
{
*
this
=
Eq
(
internal
::
string
(
s
));
Matcher
<
const
std
::
string
&>::
Matcher
(
const
char
*
s
)
{
*
this
=
Eq
(
std
::
string
(
s
));
}
// Constructs a matcher that matches a string whose value is equal to s.
Matcher
<
internal
::
string
>::
Matcher
(
const
internal
::
string
&
s
)
{
*
this
=
Eq
(
s
);
}
// Constructs a matcher that matches a std::string whose value is equal to
// s.
Matcher
<
std
::
string
>::
Matcher
(
const
std
::
string
&
s
)
{
*
this
=
Eq
(
s
);
}
// Constructs a matcher that matches a string whose value is equal to s.
Matcher
<
internal
::
string
>::
Matcher
(
const
char
*
s
)
{
*
this
=
Eq
(
internal
::
string
(
s
));
#if GTEST_HAS_GLOBAL_STRING
// Constructs a matcher that matches a std::string whose value is equal to
// s.
Matcher
<
std
::
string
>::
Matcher
(
const
::
string
&
s
)
{
*
this
=
Eq
(
static_cast
<
std
::
string
>
(
s
));
}
#endif // GTEST_HAS_GLOBAL_STRING
// Constructs a matcher that matches a std::string whose value is equal to
// s.
Matcher
<
std
::
string
>::
Matcher
(
const
char
*
s
)
{
*
this
=
Eq
(
std
::
string
(
s
));
}
#if GTEST_HAS_
STRING_PIECE_
// Constructs a matcher that matches a const
S
tring
Piece
& whose value is
#if GTEST_HAS_
GLOBAL_STRING
// Constructs a matcher that matches a const
::s
tring& whose value is
// equal to s.
Matcher
<
const
S
tring
Piece
&>::
Matcher
(
const
internal
::
string
&
s
)
{
*
this
=
Eq
(
s
);
Matcher
<
const
::
s
tring
&>::
Matcher
(
const
std
::
string
&
s
)
{
*
this
=
Eq
(
s
tatic_cast
<::
string
>
(
s
)
);
}
// Constructs a matcher that matches a const
S
tring
Piece
& whose value is
// Constructs a matcher that matches a const
::s
tring& whose value is
// equal to s.
Matcher
<
const
StringPiece
&>::
Matcher
(
const
char
*
s
)
{
*
this
=
Eq
(
internal
::
string
(
s
));
}
Matcher
<
const
::
string
&>::
Matcher
(
const
::
string
&
s
)
{
*
this
=
Eq
(
s
);
}
// Constructs a matcher that matches a const
S
tring
Piece
& whose value is
// Constructs a matcher that matches a const
::s
tring& whose value is
// equal to s.
Matcher
<
const
StringPiece
&>::
Matcher
(
StringPiece
s
)
{
*
this
=
Eq
(
s
.
ToString
());
}
Matcher
<
const
::
string
&>::
Matcher
(
const
char
*
s
)
{
*
this
=
Eq
(
::
string
(
s
));
}
// Constructs a matcher that matches a
S
tring
Piece
whose value is equal to s.
Matcher
<
S
tring
Piece
>::
Matcher
(
const
internal
::
string
&
s
)
{
*
this
=
Eq
(
s
);
// Constructs a matcher that matches a
::s
tring whose value is equal to s.
Matcher
<
::
s
tring
>::
Matcher
(
const
std
::
string
&
s
)
{
*
this
=
Eq
(
s
tatic_cast
<::
string
>
(
s
)
);
}
// Constructs a matcher that matches a StringPiece whose value is equal to s.
Matcher
<
StringPiece
>::
Matcher
(
const
char
*
s
)
{
*
this
=
Eq
(
internal
::
string
(
s
));
}
// Constructs a matcher that matches a ::string whose value is equal to s.
Matcher
<::
string
>::
Matcher
(
const
::
string
&
s
)
{
*
this
=
Eq
(
s
);
}
// Constructs a matcher that matches a string whose value is equal to s.
Matcher
<::
string
>::
Matcher
(
const
char
*
s
)
{
*
this
=
Eq
(
::
string
(
s
));
}
#endif // GTEST_HAS_GLOBAL_STRING
// Constructs a matcher that matches a StringPiece whose value is equal to s.
Matcher
<
StringPiece
>::
Matcher
(
StringPiece
s
)
{
*
this
=
Eq
(
s
.
ToString
());
}
#endif // GTEST_HAS_STRING_PIECE_
namespace
internal
{
...
...
googlemock/test/gmock-internal-utils_test.cc
View file @
78579756
...
...
@@ -44,7 +44,15 @@
#include "gmock/internal/gmock-port.h"
#include "gtest/gtest.h"
#include "gtest/gtest-spi.h"
// Indicates that this translation unit is part of Google Test's
// implementation. It must come before gtest-internal-inl.h is
// included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in
// their code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
#if GTEST_OS_CYGWIN
# include <sys/types.h> // For ssize_t. NOLINT
...
...
@@ -61,6 +69,26 @@ namespace internal {
namespace
{
TEST
(
JoinAsTupleTest
,
JoinsEmptyTuple
)
{
EXPECT_EQ
(
""
,
JoinAsTuple
(
Strings
()));
}
TEST
(
JoinAsTupleTest
,
JoinsOneTuple
)
{
const
char
*
fields
[]
=
{
"1"
};
EXPECT_EQ
(
"1"
,
JoinAsTuple
(
Strings
(
fields
,
fields
+
1
)));
}
TEST
(
JoinAsTupleTest
,
JoinsTwoTuple
)
{
const
char
*
fields
[]
=
{
"1"
,
"a"
};
EXPECT_EQ
(
"(1, a)"
,
JoinAsTuple
(
Strings
(
fields
,
fields
+
2
)));
}
TEST
(
JoinAsTupleTest
,
JoinsTenTuple
)
{
const
char
*
fields
[]
=
{
"1"
,
"2"
,
"3"
,
"4"
,
"5"
,
"6"
,
"7"
,
"8"
,
"9"
,
"10"
};
EXPECT_EQ
(
"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)"
,
JoinAsTuple
(
Strings
(
fields
,
fields
+
10
)));
}
TEST
(
ConvertIdentifierNameToWordsTest
,
WorksWhenNameContainsNoWord
)
{
EXPECT_EQ
(
""
,
ConvertIdentifierNameToWords
(
""
));
EXPECT_EQ
(
""
,
ConvertIdentifierNameToWords
(
"_"
));
...
...
googlemock/test/gmock_output_test_.cc
View file @
78579756
...
...
@@ -47,6 +47,7 @@ using testing::NaggyMock;
using
testing
::
Ref
;
using
testing
::
Return
;
using
testing
::
Sequence
;
using
testing
::
Value
;
class
MockFoo
{
public:
...
...
@@ -268,6 +269,10 @@ TEST_F(GMockOutputTest, CatchesLeakedMocks) {
// Both foo1 and foo2 are deliberately leaked.
}
MATCHER_P2
(
IsPair
,
first
,
second
,
""
)
{
return
Value
(
arg
.
first
,
first
)
&&
Value
(
arg
.
second
,
second
);
}
void
TestCatchesLeakedMocksInAdHocTests
()
{
MockFoo
*
foo
=
new
MockFoo
;
...
...
@@ -280,7 +285,6 @@ void TestCatchesLeakedMocksInAdHocTests() {
int
main
(
int
argc
,
char
**
argv
)
{
testing
::
InitGoogleMock
(
&
argc
,
argv
);
// Ensures that the tests pass no matter what value of
// --gmock_catch_leaked_mocks and --gmock_verbose the user specifies.
testing
::
GMOCK_FLAG
(
catch_leaked_mocks
)
=
true
;
...
...
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