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
d630a8bd
Commit
d630a8bd
authored
Jan 10, 2018
by
Gennadiy Civil
Browse files
code merges, cleanup
parent
f33902b9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
12 deletions
+71
-12
googletest/include/gtest/internal/gtest-internal.h
googletest/include/gtest/internal/gtest-internal.h
+68
-9
googletest/include/gtest/internal/gtest-string.h
googletest/include/gtest/internal/gtest-string.h
+2
-2
googletest/test/production.cc
googletest/test/production.cc
+1
-1
No files found.
googletest/include/gtest/internal/gtest-internal.h
View file @
d630a8bd
...
@@ -27,7 +27,6 @@
...
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//
// Authors: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee)
//
//
// The Google C++ Testing Framework (Google Test)
// The Google C++ Testing Framework (Google Test)
//
//
...
@@ -61,8 +60,8 @@
...
@@ -61,8 +60,8 @@
#include <vector>
#include <vector>
#include "gtest/gtest-message.h"
#include "gtest/gtest-message.h"
#include "gtest/internal/gtest-string.h"
#include "gtest/internal/gtest-filepath.h"
#include "gtest/internal/gtest-filepath.h"
#include "gtest/internal/gtest-string.h"
#include "gtest/internal/gtest-type-util.h"
#include "gtest/internal/gtest-type-util.h"
// Due to C++ preprocessor weirdness, we need double indirection to
// Due to C++ preprocessor weirdness, we need double indirection to
...
@@ -157,7 +156,28 @@ class GTEST_API_ ScopedTrace {
...
@@ -157,7 +156,28 @@ class GTEST_API_ ScopedTrace {
public:
public:
// The c'tor pushes the given source file location and message onto
// The c'tor pushes the given source file location and message onto
// a trace stack maintained by Google Test.
// a trace stack maintained by Google Test.
ScopedTrace
(
const
char
*
file
,
int
line
,
const
Message
&
message
);
// Template version. Uses Message() to convert the values into strings.
// Slow, but flexible.
template
<
typename
T
>
ScopedTrace
(
const
char
*
file
,
int
line
,
const
T
&
message
)
{
PushTrace
(
file
,
line
,
(
Message
()
<<
message
).
GetString
());
}
// Optimize for some known types.
ScopedTrace
(
const
char
*
file
,
int
line
,
const
char
*
message
)
{
PushTrace
(
file
,
line
,
message
?
message
:
"(null)"
);
}
#if GTEST_HAS_GLOBAL_STRING
ScopedTrace
(
const
char
*
file
,
int
line
,
const
::
string
&
message
)
{
PushTrace
(
file
,
line
,
message
);
}
#endif
ScopedTrace
(
const
char
*
file
,
int
line
,
const
std
::
string
&
message
)
{
PushTrace
(
file
,
line
,
message
);
}
// The d'tor pops the info pushed by the c'tor.
// The d'tor pops the info pushed by the c'tor.
//
//
...
@@ -166,6 +186,8 @@ class GTEST_API_ ScopedTrace {
...
@@ -166,6 +186,8 @@ class GTEST_API_ ScopedTrace {
~
ScopedTrace
();
~
ScopedTrace
();
private:
private:
void
PushTrace
(
const
char
*
file
,
int
line
,
std
::
string
message
);
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
ScopedTrace
);
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
ScopedTrace
);
}
GTEST_ATTRIBUTE_UNUSED_
;
// A ScopedTrace object does its job in its
}
GTEST_ATTRIBUTE_UNUSED_
;
// A ScopedTrace object does its job in its
// c'tor and d'tor. Therefore it doesn't
// c'tor and d'tor. Therefore it doesn't
...
@@ -175,7 +197,7 @@ namespace edit_distance {
...
@@ -175,7 +197,7 @@ namespace edit_distance {
// Returns the optimal edits to go from 'left' to 'right'.
// Returns the optimal edits to go from 'left' to 'right'.
// All edits cost the same, with replace having lower priority than
// All edits cost the same, with replace having lower priority than
// add/remove.
// add/remove.
// Simple implementation of the Wagner
-
Fischer algorithm.
// Simple implementation of the Wagner
–
Fischer algorithm.
// See http://en.wikipedia.org/wiki/Wagner-Fischer_algorithm
// See http://en.wikipedia.org/wiki/Wagner-Fischer_algorithm
enum
EditType
{
kMatch
,
kAdd
,
kRemove
,
kReplace
};
enum
EditType
{
kMatch
,
kAdd
,
kRemove
,
kReplace
};
GTEST_API_
std
::
vector
<
EditType
>
CalculateOptimalEdits
(
GTEST_API_
std
::
vector
<
EditType
>
CalculateOptimalEdits
(
...
@@ -628,7 +650,7 @@ class TypeParameterizedTest {
...
@@ -628,7 +650,7 @@ class TypeParameterizedTest {
// Types). Valid values for 'index' are [0, N - 1] where N is the
// Types). Valid values for 'index' are [0, N - 1] where N is the
// length of Types.
// length of Types.
static
bool
Register
(
const
char
*
prefix
,
static
bool
Register
(
const
char
*
prefix
,
CodeLocation
code_location
,
const
CodeLocation
&
code_location
,
const
char
*
case_name
,
const
char
*
test_names
,
const
char
*
case_name
,
const
char
*
test_names
,
int
index
)
{
int
index
)
{
typedef
typename
Types
::
Head
Type
;
typedef
typename
Types
::
Head
Type
;
...
@@ -659,7 +681,7 @@ class TypeParameterizedTest {
...
@@ -659,7 +681,7 @@ class TypeParameterizedTest {
template
<
GTEST_TEMPLATE_
Fixture
,
class
TestSel
>
template
<
GTEST_TEMPLATE_
Fixture
,
class
TestSel
>
class
TypeParameterizedTest
<
Fixture
,
TestSel
,
Types0
>
{
class
TypeParameterizedTest
<
Fixture
,
TestSel
,
Types0
>
{
public:
public:
static
bool
Register
(
const
char
*
/*prefix*/
,
CodeLocation
,
static
bool
Register
(
const
char
*
/*prefix*/
,
const
CodeLocation
&
,
const
char
*
/*case_name*/
,
const
char
*
/*test_names*/
,
const
char
*
/*case_name*/
,
const
char
*
/*test_names*/
,
int
/*index*/
)
{
int
/*index*/
)
{
return
true
;
return
true
;
...
@@ -705,7 +727,7 @@ class TypeParameterizedTestCase {
...
@@ -705,7 +727,7 @@ class TypeParameterizedTestCase {
template
<
GTEST_TEMPLATE_
Fixture
,
typename
Types
>
template
<
GTEST_TEMPLATE_
Fixture
,
typename
Types
>
class
TypeParameterizedTestCase
<
Fixture
,
Templates0
,
Types
>
{
class
TypeParameterizedTestCase
<
Fixture
,
Templates0
,
Types
>
{
public:
public:
static
bool
Register
(
const
char
*
/*prefix*/
,
CodeLocation
,
static
bool
Register
(
const
char
*
/*prefix*/
,
const
CodeLocation
&
,
const
TypedTestCasePState
*
/*state*/
,
const
TypedTestCasePState
*
/*state*/
,
const
char
*
/*case_name*/
,
const
char
*
/*test_names*/
)
{
const
char
*
/*case_name*/
,
const
char
*
/*test_names*/
)
{
return
true
;
return
true
;
...
@@ -918,8 +940,11 @@ struct IsAProtocolMessage
...
@@ -918,8 +940,11 @@ struct IsAProtocolMessage
// a container class by checking the type of IsContainerTest<C>(0).
// a container class by checking the type of IsContainerTest<C>(0).
// The value of the expression is insignificant.
// The value of the expression is insignificant.
//
//
// Note that we look for both C::iterator and C::const_iterator. The
// In C++11 mode we check the existence of a const_iterator and that an
// reason is that C++ injects the name of a class as a member of the
// iterator is properly implemented for the container.
//
// For pre-C++11 that we look for both C::iterator and C::const_iterator.
// The reason is that C++ injects the name of a class as a member of the
// class itself (e.g. you can refer to class iterator as either
// class itself (e.g. you can refer to class iterator as either
// 'iterator' or 'iterator::iterator'). If we look for C::iterator
// 'iterator' or 'iterator::iterator'). If we look for C::iterator
// only, for example, we would mistakenly think that a class named
// only, for example, we would mistakenly think that a class named
...
@@ -929,17 +954,51 @@ struct IsAProtocolMessage
...
@@ -929,17 +954,51 @@ struct IsAProtocolMessage
// IsContainerTest(typename C::const_iterator*) and
// IsContainerTest(typename C::const_iterator*) and
// IsContainerTest(...) doesn't work with Visual Age C++ and Sun C++.
// IsContainerTest(...) doesn't work with Visual Age C++ and Sun C++.
typedef
int
IsContainer
;
typedef
int
IsContainer
;
#if GTEST_LANG_CXX11
template
<
class
C
,
class
Iterator
=
decltype
(
::
std
::
declval
<
const
C
&
>().
begin
()),
class
=
decltype
(
::
std
::
declval
<
const
C
&>
().
end
()),
class
=
decltype
(
++::
std
::
declval
<
Iterator
&>
()),
class
=
decltype
(
*::
std
::
declval
<
Iterator
>
()),
class
=
typename
C
::
const_iterator
>
IsContainer
IsContainerTest
(
int
/* dummy */
)
{
return
0
;
}
#else
template
<
class
C
>
template
<
class
C
>
IsContainer
IsContainerTest
(
int
/* dummy */
,
IsContainer
IsContainerTest
(
int
/* dummy */
,
typename
C
::
iterator
*
/* it */
=
NULL
,
typename
C
::
iterator
*
/* it */
=
NULL
,
typename
C
::
const_iterator
*
/* const_it */
=
NULL
)
{
typename
C
::
const_iterator
*
/* const_it */
=
NULL
)
{
return
0
;
return
0
;
}
}
#endif // GTEST_LANG_CXX11
typedef
char
IsNotContainer
;
typedef
char
IsNotContainer
;
template
<
class
C
>
template
<
class
C
>
IsNotContainer
IsContainerTest
(
long
/* dummy */
)
{
return
'\0'
;
}
IsNotContainer
IsContainerTest
(
long
/* dummy */
)
{
return
'\0'
;
}
// Trait to detect whether a type T is a hash table.
// The heuristic used is that the type contains an inner type `hasher` and does
// not contain an inner type `reverse_iterator`.
// If the container is iterable in reverse, then order might actually matter.
template
<
typename
T
>
struct
IsHashTable
{
private:
template
<
typename
U
>
static
char
test
(
typename
U
::
hasher
*
,
typename
U
::
reverse_iterator
*
);
template
<
typename
U
>
static
int
test
(
typename
U
::
hasher
*
,
...);
template
<
typename
U
>
static
char
test
(...);
public:
static
const
bool
value
=
sizeof
(
test
<
T
>
(
0
,
0
))
==
sizeof
(
int
);
};
template
<
typename
T
>
const
bool
IsHashTable
<
T
>::
value
;
template
<
typename
C
,
bool
=
template
<
typename
C
,
bool
=
sizeof
(
IsContainerTest
<
C
>(
0
))
==
sizeof
(
IsContainer
)
sizeof
(
IsContainerTest
<
C
>(
0
))
==
sizeof
(
IsContainer
)
>
>
...
...
googletest/include/gtest/internal/gtest-string.h
View file @
d630a8bd
...
@@ -27,7 +27,6 @@
...
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//
// Authors: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee)
//
//
// The Google C++ Testing Framework (Google Test)
// The Google C++ Testing Framework (Google Test)
//
//
...
@@ -35,7 +34,8 @@
...
@@ -35,7 +34,8 @@
// Google Test. They are subject to change without notice. They should not used
// Google Test. They are subject to change without notice. They should not used
// by code external to Google Test.
// by code external to Google Test.
//
//
// This header file is #included by <gtest/internal/gtest-internal.h>.
// This header file is #included by
// gtest/internal/gtest-internal.h.
// It should not be #included by other files.
// It should not be #included by other files.
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
...
...
googletest/test/production.cc
View file @
d630a8bd
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
//
//
// Author: wan@google.com (Zhanyong Wan)
// Author: wan@google.com (Zhanyong Wan)
//
//
// This is part of the unit test for
include/gtest/
gtest_prod.h.
// This is part of the unit test for gtest_prod.h.
#include "production.h"
#include "production.h"
...
...
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