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
78579756
Unverified
Commit
78579756
authored
Mar 26, 2018
by
Gennadiy Civil
Committed by
GitHub
Mar 26, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1512 from gennadiycivil/master
merges, gmock - 1
parents
dfa853b6
6aae206b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
36 deletions
+75
-36
gmock-matchers.h
googlemock/include/gmock/gmock-matchers.h
+0
-0
gmock-matchers.cc
googlemock/src/gmock-matchers.cc
+42
-35
gmock-internal-utils_test.cc
googlemock/test/gmock-internal-utils_test.cc
+28
-0
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 @@
...
@@ -44,60 +44,67 @@
namespace
testing
{
namespace
testing
{
// Constructs a matcher that matches a const string& whose value is
// Constructs a matcher that matches a const st
d::st
ring& whose value is
// equal to s.
// equal to s.
Matcher
<
const
internal
::
string
&>::
Matcher
(
const
internal
::
string
&
s
)
{
Matcher
<
const
std
::
string
&>::
Matcher
(
const
std
::
string
&
s
)
{
*
this
=
Eq
(
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 st
d::st
ring& whose value is
// equal to s.
// equal to s.
Matcher
<
const
internal
::
string
&>::
Matcher
(
const
char
*
s
)
{
Matcher
<
const
std
::
string
&>::
Matcher
(
const
char
*
s
)
{
*
this
=
Eq
(
internal
::
string
(
s
));
*
this
=
Eq
(
std
::
string
(
s
));
}
}
// Constructs a matcher that matches a string whose value is equal to s.
// Constructs a matcher that matches a std::string whose value is equal to
Matcher
<
internal
::
string
>::
Matcher
(
const
internal
::
string
&
s
)
{
*
this
=
Eq
(
s
);
}
// 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.
#if GTEST_HAS_GLOBAL_STRING
Matcher
<
internal
::
string
>::
Matcher
(
const
char
*
s
)
{
// Constructs a matcher that matches a std::string whose value is equal to
*
this
=
Eq
(
internal
::
string
(
s
));
// 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_
#if GTEST_HAS_
GLOBAL_STRING
// Constructs a matcher that matches a const
StringPiece
& whose value is
// Constructs a matcher that matches a const
::string
& whose value is
// equal to s.
// equal to s.
Matcher
<
const
StringPiece
&>::
Matcher
(
const
internal
::
string
&
s
)
{
Matcher
<
const
::
string
&>::
Matcher
(
const
std
::
string
&
s
)
{
*
this
=
Eq
(
s
);
*
this
=
Eq
(
s
tatic_cast
<::
string
>
(
s
)
);
}
}
// Constructs a matcher that matches a const
StringPiece
& whose value is
// Constructs a matcher that matches a const
::string
& whose value is
// equal to s.
// equal to s.
Matcher
<
const
StringPiece
&>::
Matcher
(
const
char
*
s
)
{
Matcher
<
const
::
string
&>::
Matcher
(
const
::
string
&
s
)
{
*
this
=
Eq
(
s
);
}
*
this
=
Eq
(
internal
::
string
(
s
));
}
// Constructs a matcher that matches a const
StringPiece
& whose value is
// Constructs a matcher that matches a const
::string
& whose value is
// equal to s.
// equal to s.
Matcher
<
const
StringPiece
&>::
Matcher
(
StringPiece
s
)
{
Matcher
<
const
::
string
&>::
Matcher
(
const
char
*
s
)
{
*
this
=
Eq
(
::
string
(
s
));
}
*
this
=
Eq
(
s
.
ToString
());
}
// Constructs a matcher that matches a
StringPiece
whose value is equal to s.
// Constructs a matcher that matches a
::string
whose value is equal to s.
Matcher
<
StringPiece
>::
Matcher
(
const
internal
::
string
&
s
)
{
Matcher
<
::
string
>::
Matcher
(
const
std
::
string
&
s
)
{
*
this
=
Eq
(
s
);
*
this
=
Eq
(
s
tatic_cast
<::
string
>
(
s
)
);
}
}
// Constructs a matcher that matches a StringPiece whose value is equal to s.
// Constructs a matcher that matches a ::string whose value is equal to s.
Matcher
<
StringPiece
>::
Matcher
(
const
char
*
s
)
{
Matcher
<::
string
>::
Matcher
(
const
::
string
&
s
)
{
*
this
=
Eq
(
s
);
}
*
this
=
Eq
(
internal
::
string
(
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
{
namespace
internal
{
...
...
googlemock/test/gmock-internal-utils_test.cc
View file @
78579756
...
@@ -44,7 +44,15 @@
...
@@ -44,7 +44,15 @@
#include "gmock/internal/gmock-port.h"
#include "gmock/internal/gmock-port.h"
#include "gtest/gtest.h"
#include "gtest/gtest.h"
#include "gtest/gtest-spi.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"
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
#if GTEST_OS_CYGWIN
#if GTEST_OS_CYGWIN
# include <sys/types.h> // For ssize_t. NOLINT
# include <sys/types.h> // For ssize_t. NOLINT
...
@@ -61,6 +69,26 @@ namespace internal {
...
@@ -61,6 +69,26 @@ namespace internal {
namespace
{
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
)
{
TEST
(
ConvertIdentifierNameToWordsTest
,
WorksWhenNameContainsNoWord
)
{
EXPECT_EQ
(
""
,
ConvertIdentifierNameToWords
(
""
));
EXPECT_EQ
(
""
,
ConvertIdentifierNameToWords
(
""
));
EXPECT_EQ
(
""
,
ConvertIdentifierNameToWords
(
"_"
));
EXPECT_EQ
(
""
,
ConvertIdentifierNameToWords
(
"_"
));
...
...
googlemock/test/gmock_output_test_.cc
View file @
78579756
...
@@ -47,6 +47,7 @@ using testing::NaggyMock;
...
@@ -47,6 +47,7 @@ using testing::NaggyMock;
using
testing
::
Ref
;
using
testing
::
Ref
;
using
testing
::
Return
;
using
testing
::
Return
;
using
testing
::
Sequence
;
using
testing
::
Sequence
;
using
testing
::
Value
;
class
MockFoo
{
class
MockFoo
{
public
:
public
:
...
@@ -268,6 +269,10 @@ TEST_F(GMockOutputTest, CatchesLeakedMocks) {
...
@@ -268,6 +269,10 @@ TEST_F(GMockOutputTest, CatchesLeakedMocks) {
// Both foo1 and foo2 are deliberately leaked.
// Both foo1 and foo2 are deliberately leaked.
}
}
MATCHER_P2
(
IsPair
,
first
,
second
,
""
)
{
return
Value
(
arg
.
first
,
first
)
&&
Value
(
arg
.
second
,
second
);
}
void
TestCatchesLeakedMocksInAdHocTests
()
{
void
TestCatchesLeakedMocksInAdHocTests
()
{
MockFoo
*
foo
=
new
MockFoo
;
MockFoo
*
foo
=
new
MockFoo
;
...
@@ -280,7 +285,6 @@ void TestCatchesLeakedMocksInAdHocTests() {
...
@@ -280,7 +285,6 @@ void TestCatchesLeakedMocksInAdHocTests() {
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
testing
::
InitGoogleMock
(
&
argc
,
argv
);
testing
::
InitGoogleMock
(
&
argc
,
argv
);
// Ensures that the tests pass no matter what value of
// Ensures that the tests pass no matter what value of
// --gmock_catch_leaked_mocks and --gmock_verbose the user specifies.
// --gmock_catch_leaked_mocks and --gmock_verbose the user specifies.
testing
::
GMOCK_FLAG
(
catch_leaked_mocks
)
=
true
;
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