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
0f0634a6
Commit
0f0634a6
authored
Nov 01, 2019
by
Abseil Team
Committed by
Gennadiy Civil
Nov 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Googletest export
- 277898422 BEGIN_PUBLIC by Abseil Team <absl-team@google.com> PiperOrigin-RevId: 277898422
parent
c27acebb
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
62 additions
and
146 deletions
+62
-146
gmock.pc.in
googlemock/cmake/gmock.pc.in
+1
-1
gmock_main.pc.in
googlemock/cmake/gmock_main.pc.in
+1
-1
pump_manual.md
googlemock/docs/pump_manual.md
+12
-9
gmock-function-mocker.h
googlemock/include/gmock/gmock-function-mocker.h
+20
-22
gmock-matchers.h
googlemock/include/gmock/gmock-matchers.h
+1
-1
pump.py
googlemock/scripts/pump.py
+6
-7
gmock-function-mocker_test.cc
googlemock/test/gmock-function-mocker_test.cc
+0
-29
gtest.pc.in
googletest/cmake/gtest.pc.in
+1
-1
gtest_main.pc.in
googletest/cmake/gtest_main.pc.in
+1
-1
gtest-typed-test.h
googletest/include/gtest/gtest-typed-test.h
+4
-13
gtest-internal.h
googletest/include/gtest/internal/gtest-internal.h
+3
-33
gen_gtest_pred_impl.py
googletest/scripts/gen_gtest_pred_impl.py
+10
-10
gtest-death-test.cc
googletest/src/gtest-death-test.cc
+1
-1
gtest.cc
googletest/src/gtest.cc
+1
-4
gtest_unittest.cc
googletest/test/gtest_unittest.cc
+0
-13
No files found.
googlemock/cmake/gmock.pc.in
View file @
0f0634a6
...
...
@@ -7,4 +7,4 @@ Version: @PROJECT_VERSION@
URL: https://github.com/google/googletest
Requires: gtest
Libs: -L${libdir} -lgmock @CMAKE_THREAD_LIBS_INIT@
Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@
Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@
@CMAKE_THREAD_LIBS_INIT@
googlemock/cmake/gmock_main.pc.in
View file @
0f0634a6
...
...
@@ -7,4 +7,4 @@ Version: @PROJECT_VERSION@
URL: https://github.com/google/googletest
Requires: gmock
Libs: -L${libdir} -lgmock_main @CMAKE_THREAD_LIBS_INIT@
Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@
Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@
@CMAKE_THREAD_LIBS_INIT@
googlemock/docs/pump_manual.md
View file @
0f0634a6
...
...
@@ -6,15 +6,18 @@ Template and macro libraries often need to define many classes, functions, or
macros that vary only (or almost only) in the number of arguments they take.
It's a lot of repetitive, mechanical, and error-prone work.
Our experience is that it's tedious to write custom scripts, which tend to
reflect the structure of the generated code poorly and are often hard to read
and edit. For example, a small change needed in the generated code may require
some non-intuitive, non-trivial changes in the script. This is especially
painful when experimenting with the code.
This script may be useful for generating meta code, for example a series of
macros of FOO1, FOO2, etc. Nevertheless, please make it your last resort
technique by favouring C++ template metaprogramming or variadic macros.
Variadic templates and variadic macros can alleviate the problem. However, while
both are being considered by the C++ committee, neither is in the standard yet
or widely supported by compilers. Thus they are often not a good choice,
especially when your code needs to be portable. And their capabilities are still
limited.
As a result, authors of such libraries often have to write scripts to generate
their implementation. However, our experience is that it's tedious to write such
scripts, which tend to reflect the structure of the generated code poorly and
are often hard to read and edit. For example, a small change needed in the
generated code may require some non-intuitive, non-trivial changes in the
script. This is especially painful when experimenting with the code.
# Our Solution
...
...
googlemock/include/gmock/gmock-function-mocker.h
View file @
0f0634a6
...
...
@@ -58,17 +58,16 @@ using identity_t = T;
#define GMOCK_INTERNAL_MOCK_METHOD_ARG_3(_Ret, _MethodName, _Args) \
GMOCK_INTERNAL_MOCK_METHOD_ARG_4(_Ret, _MethodName, _Args, ())
#define GMOCK_INTERNAL_MOCK_METHOD_ARG_4(_Ret, _MethodName, _Args, _Spec) \
GMOCK_INTERNAL_ASSERT_PARENTHESIS(_Args); \
GMOCK_INTERNAL_ASSERT_PARENTHESIS(_Spec); \
GMOCK_INTERNAL_ASSERT_VALID_SIGNATURE( \
GMOCK_PP_NARG0 _Args, GMOCK_INTERNAL_SIGNATURE(_Ret, _Args)); \
GMOCK_INTERNAL_ASSERT_VALID_SPEC(_Spec) \
GMOCK_INTERNAL_MOCK_METHOD_IMPL( \
GMOCK_PP_NARG0 _Args, _MethodName, GMOCK_INTERNAL_HAS_CONST(_Spec), \
GMOCK_INTERNAL_HAS_OVERRIDE(_Spec), GMOCK_INTERNAL_HAS_FINAL(_Spec), \
GMOCK_INTERNAL_GET_NOEXCEPT_SPEC(_Spec), \
GMOCK_INTERNAL_GET_CALLTYPE(_Spec), \
#define GMOCK_INTERNAL_MOCK_METHOD_ARG_4(_Ret, _MethodName, _Args, _Spec) \
GMOCK_INTERNAL_ASSERT_PARENTHESIS(_Args); \
GMOCK_INTERNAL_ASSERT_PARENTHESIS(_Spec); \
GMOCK_INTERNAL_ASSERT_VALID_SIGNATURE( \
GMOCK_PP_NARG0 _Args, GMOCK_INTERNAL_SIGNATURE(_Ret, _Args)); \
GMOCK_INTERNAL_ASSERT_VALID_SPEC(_Spec) \
GMOCK_INTERNAL_MOCK_METHOD_IMPL( \
GMOCK_PP_NARG0 _Args, _MethodName, GMOCK_INTERNAL_HAS_CONST(_Spec), \
GMOCK_INTERNAL_HAS_OVERRIDE(_Spec), GMOCK_INTERNAL_HAS_FINAL(_Spec), \
GMOCK_INTERNAL_HAS_NOEXCEPT(_Spec), GMOCK_INTERNAL_GET_CALLTYPE(_Spec), \
(GMOCK_INTERNAL_SIGNATURE(_Ret, _Args)))
#define GMOCK_INTERNAL_MOCK_METHOD_ARG_5(...) \
...
...
@@ -108,14 +107,15 @@ using identity_t = T;
GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_ASSERT_VALID_SPEC_ELEMENT, ~, _Spec)
#define GMOCK_INTERNAL_MOCK_METHOD_IMPL(_N, _MethodName, _Constness, \
_Override, _Final, _Noexcept
Spec,
\
_Override, _Final, _Noexcept
,
\
_CallType, _Signature) \
typename ::testing::internal::Function<GMOCK_PP_REMOVE_PARENS( \
_Signature)>::Result \
GMOCK_INTERNAL_EXPAND(_CallType) \
_MethodName(GMOCK_PP_REPEAT(GMOCK_INTERNAL_PARAMETER, _Signature, _N)) \
GMOCK_PP_IF(_Constness, const, ) _NoexceptSpec \
GMOCK_PP_IF(_Override, override, ) GMOCK_PP_IF(_Final, final, ) { \
GMOCK_PP_IF(_Constness, const, ) GMOCK_PP_IF(_Noexcept, noexcept, ) \
GMOCK_PP_IF(_Override, override, ) \
GMOCK_PP_IF(_Final, final, ) { \
GMOCK_MOCKER_(_N, _Constness, _MethodName) \
.SetOwnerAndName(this, #_MethodName); \
return GMOCK_MOCKER_(_N, _Constness, _MethodName) \
...
...
@@ -131,7 +131,8 @@ using identity_t = T;
::testing::MockSpec<GMOCK_PP_REMOVE_PARENS(_Signature)> gmock_##_MethodName( \
const ::testing::internal::WithoutMatchers&, \
GMOCK_PP_IF(_Constness, const, )::testing::internal::Function< \
GMOCK_PP_REMOVE_PARENS(_Signature)>*) const _NoexceptSpec { \
GMOCK_PP_REMOVE_PARENS(_Signature)>*) \
const GMOCK_PP_IF(_Noexcept, noexcept, ) { \
return GMOCK_PP_CAT(::testing::internal::AdjustConstness_, \
GMOCK_PP_IF(_Constness, const, ))(this) \
->gmock_##_MethodName(GMOCK_PP_REPEAT( \
...
...
@@ -153,13 +154,9 @@ using identity_t = T;
#define GMOCK_INTERNAL_HAS_FINAL(_Tuple) \
GMOCK_PP_HAS_COMMA(GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_DETECT_FINAL, ~, _Tuple))
#define GMOCK_INTERNAL_GET_NOEXCEPT_SPEC(_Tuple) \
GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_NOEXCEPT_SPEC_IF_NOEXCEPT, ~, _Tuple)
#define GMOCK_INTERNAL_NOEXCEPT_SPEC_IF_NOEXCEPT(_i, _, _elem) \
GMOCK_PP_IF( \
GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_NOEXCEPT(_i, _, _elem)), \
_elem, )
#define GMOCK_INTERNAL_HAS_NOEXCEPT(_Tuple) \
GMOCK_PP_HAS_COMMA( \
GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_DETECT_NOEXCEPT, ~, _Tuple))
#define GMOCK_INTERNAL_GET_CALLTYPE(_Tuple) \
GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_GET_CALLTYPE_IMPL, ~, _Tuple)
...
...
@@ -190,6 +187,7 @@ using identity_t = T;
#define GMOCK_INTERNAL_DETECT_FINAL_I_final ,
// TODO(iserna): Maybe noexcept should accept an argument here as well.
#define GMOCK_INTERNAL_DETECT_NOEXCEPT(_i, _, _elem) \
GMOCK_PP_CAT(GMOCK_INTERNAL_DETECT_NOEXCEPT_I_, _elem)
...
...
googlemock/include/gmock/gmock-matchers.h
View file @
0f0634a6
...
...
@@ -1323,7 +1323,7 @@ class PredicateFormatterFromMatcher {
<<
"Expected: "
;
matcher
.
DescribeTo
(
&
ss
);
// Rerun the matcher to "PrintAndEx
pl
ain" the failure.
// Rerun the matcher to "PrintAndExain" the failure.
StringMatchResultListener
listener
;
if
(
MatchPrintAndExplain
(
x
,
matcher
,
&
listener
))
{
ss
<<
"
\n
The matcher failed on the initial attempt; but passed when "
...
...
googlemock/scripts/pump.py
View file @
0f0634a6
#!/usr/bin/env python
#!/usr/bin/env python
2.7
#
# Copyright 2008, Google Inc.
# All rights reserved.
...
...
@@ -64,7 +64,6 @@ GRAMMAR:
from
__future__
import
print_function
import
io
import
os
import
re
import
sys
...
...
@@ -835,7 +834,7 @@ def main(argv):
sys
.
exit
(
1
)
file_path
=
argv
[
-
1
]
output_str
=
ConvertFromPumpSource
(
io
.
open
(
file_path
,
'r'
)
.
read
())
output_str
=
ConvertFromPumpSource
(
file
(
file_path
,
'r'
)
.
read
())
if
file_path
.
endswith
(
'.pump'
):
output_file_path
=
file_path
[:
-
5
]
else
:
...
...
@@ -843,11 +842,11 @@ def main(argv):
if
output_file_path
==
'-'
:
print
(
output_str
,)
else
:
output_file
=
io
.
open
(
output_file_path
,
'w'
)
output_file
.
write
(
u
'// This file was GENERATED by command:
\n
'
)
output_file
.
write
(
u
'//
%
s
%
s
\n
'
%
output_file
=
file
(
output_file_path
,
'w'
)
output_file
.
write
(
'// This file was GENERATED by command:
\n
'
)
output_file
.
write
(
'//
%
s
%
s
\n
'
%
(
os
.
path
.
basename
(
__file__
),
os
.
path
.
basename
(
file_path
)))
output_file
.
write
(
u
'// DO NOT EDIT BY HAND!!!
\n\n
'
)
output_file
.
write
(
'// DO NOT EDIT BY HAND!!!
\n\n
'
)
output_file
.
write
(
output_str
)
output_file
.
close
()
...
...
googlemock/test/gmock-function-mocker_test.cc
View file @
0f0634a6
...
...
@@ -42,8 +42,6 @@
#include <map>
#include <string>
#include <type_traits>
#include "gmock/gmock.h"
#include "gtest/gtest.h"
...
...
@@ -665,32 +663,5 @@ TEST(MockMethodMockFunctionTest, MockMethodSizeOverhead) {
EXPECT_EQ
(
sizeof
(
MockMethodSizes0
),
sizeof
(
MockMethodSizes4
));
}
void
hasTwoParams
(
int
,
int
);
void
MaybeThrows
();
void
DoesntThrow
()
noexcept
;
struct
MockMethodNoexceptSpecifier
{
MOCK_METHOD
(
void
,
func1
,
(),
(
noexcept
));
MOCK_METHOD
(
void
,
func2
,
(),
(
noexcept
(
true
)));
MOCK_METHOD
(
void
,
func3
,
(),
(
noexcept
(
false
)));
MOCK_METHOD
(
void
,
func4
,
(),
(
noexcept
(
noexcept
(
MaybeThrows
()))));
MOCK_METHOD
(
void
,
func5
,
(),
(
noexcept
(
noexcept
(
DoesntThrow
()))));
MOCK_METHOD
(
void
,
func6
,
(),
(
noexcept
(
noexcept
(
DoesntThrow
())),
const
));
MOCK_METHOD
(
void
,
func7
,
(),
(
const
,
noexcept
(
noexcept
(
DoesntThrow
()))));
// Put commas in the noexcept expression
MOCK_METHOD
(
void
,
func8
,
(),
(
noexcept
(
noexcept
(
hasTwoParams
(
1
,
2
))),
const
));
};
TEST
(
MockMethodMockFunctionTest
,
NoexceptSpecifierPreserved
)
{
EXPECT_TRUE
(
noexcept
(
std
::
declval
<
MockMethodNoexceptSpecifier
>
().
func1
()));
EXPECT_TRUE
(
noexcept
(
std
::
declval
<
MockMethodNoexceptSpecifier
>
().
func2
()));
EXPECT_FALSE
(
noexcept
(
std
::
declval
<
MockMethodNoexceptSpecifier
>
().
func3
()));
EXPECT_FALSE
(
noexcept
(
std
::
declval
<
MockMethodNoexceptSpecifier
>
().
func4
()));
EXPECT_TRUE
(
noexcept
(
std
::
declval
<
MockMethodNoexceptSpecifier
>
().
func5
()));
EXPECT_TRUE
(
noexcept
(
std
::
declval
<
MockMethodNoexceptSpecifier
>
().
func6
()));
EXPECT_TRUE
(
noexcept
(
std
::
declval
<
MockMethodNoexceptSpecifier
>
().
func7
()));
EXPECT_EQ
(
noexcept
(
std
::
declval
<
MockMethodNoexceptSpecifier
>
().
func8
()),
noexcept
(
hasTwoParams
(
1
,
2
)));
}
}
// namespace gmock_function_mocker_test
}
// namespace testing
googletest/cmake/gtest.pc.in
View file @
0f0634a6
...
...
@@ -6,4 +6,4 @@ Description: GoogleTest (without main() function)
Version: @PROJECT_VERSION@
URL: https://github.com/google/googletest
Libs: -L${libdir} -lgtest @CMAKE_THREAD_LIBS_INIT@
Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@
Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@
@CMAKE_THREAD_LIBS_INIT@
googletest/cmake/gtest_main.pc.in
View file @
0f0634a6
...
...
@@ -7,4 +7,4 @@ Version: @PROJECT_VERSION@
URL: https://github.com/google/googletest
Requires: gtest
Libs: -L${libdir} -lgtest_main @CMAKE_THREAD_LIBS_INIT@
Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@
Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@
@CMAKE_THREAD_LIBS_INIT@
googletest/include/gtest/gtest-typed-test.h
View file @
0f0634a6
...
...
@@ -169,7 +169,6 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes);
#endif // 0
#include "gtest/internal/gtest-internal.h"
#include "gtest/internal/gtest-port.h"
#include "gtest/internal/gtest-type-util.h"
...
...
@@ -195,8 +194,6 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes);
GTEST_NAME_GENERATOR_(CaseName)
#define TYPED_TEST(CaseName, TestName) \
static_assert(sizeof(GTEST_STRINGIFY_(TestName)) > 1, \
"test-name must not be empty"); \
template <typename gtest_TypeParam_> \
class GTEST_TEST_CLASS_NAME_(CaseName, TestName) \
: public CaseName<gtest_TypeParam_> { \
...
...
@@ -214,8 +211,7 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes);
CaseName)>::Register("", \
::testing::internal::CodeLocation( \
__FILE__, __LINE__), \
GTEST_STRINGIFY_(CaseName), \
GTEST_STRINGIFY_(TestName), 0, \
#CaseName, #TestName, 0, \
::testing::internal::GenerateNames< \
GTEST_NAME_GENERATOR_(CaseName), \
GTEST_TYPE_PARAMS_(CaseName)>()); \
...
...
@@ -282,14 +278,12 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes);
}; \
static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \
GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).AddTestName( \
__FILE__, __LINE__, GTEST_STRINGIFY_(SuiteName), \
GTEST_STRINGIFY_(TestName)); \
__FILE__, __LINE__, #SuiteName, #TestName); \
} \
template <typename gtest_TypeParam_> \
void GTEST_SUITE_NAMESPACE_( \
SuiteName)::TestName<gtest_TypeParam_>::TestBody()
// Note: this won't work correctly if the trailing arguments are macros.
#define REGISTER_TYPED_TEST_SUITE_P(SuiteName, ...) \
namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \
typedef ::testing::internal::Templates<__VA_ARGS__> gtest_AllTests_; \
...
...
@@ -308,16 +302,13 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes);
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
#define INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, SuiteName, Types, ...) \
static_assert(sizeof(GTEST_STRINGIFY_(Prefix)) > 1, \
"test-suit-prefix must not be empty"); \
static bool gtest_##Prefix##_##SuiteName GTEST_ATTRIBUTE_UNUSED_ = \
::testing::internal::TypeParameterizedTestSuite< \
SuiteName, GTEST_SUITE_NAMESPACE_(SuiteName)::gtest_AllTests_, \
::testing::internal::GenerateTypeList<Types>::type>:: \
Register(
GTEST_STRINGIFY_(Prefix),
\
Register(
#Prefix,
\
::testing::internal::CodeLocation(__FILE__, __LINE__), \
>EST_TYPED_TEST_SUITE_P_STATE_(SuiteName), \
GTEST_STRINGIFY_(SuiteName), \
>EST_TYPED_TEST_SUITE_P_STATE_(SuiteName), #SuiteName, \
GTEST_REGISTERED_TEST_NAMES_(SuiteName), \
::testing::internal::GenerateNames< \
::testing::internal::NameGeneratorSelector< \
...
...
googletest/include/gtest/internal/gtest-internal.h
View file @
0f0634a6
...
...
@@ -825,16 +825,6 @@ struct GTEST_API_ ConstCharPtr {
const
char
*
value
;
};
// Helper for declaring std::string within 'if' statement
// in pre C++17 build environment.
struct
GTEST_API_
TrueWithString
{
TrueWithString
()
=
default
;
explicit
TrueWithString
(
const
char
*
str
)
:
value
(
str
)
{}
explicit
TrueWithString
(
const
std
::
string
&
str
)
:
value
(
str
)
{}
explicit
operator
bool
()
const
{
return
true
;
}
std
::
string
value
;
};
// A simple Linear Congruential Generator for generating random
// numbers with a uniform distribution. Unlike rand() and srand(), it
// doesn't use global state (and therefore can't interfere with user
...
...
@@ -1294,39 +1284,19 @@ constexpr bool InstantiateTypedTestCase_P_IsDeprecated() { return true; }
GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__): \
fail(gtest_msg.value)
#if GTEST_HAS_EXCEPTIONS
#define GTEST_TEST_NO_THROW_CATCH_STD_EXCEPTION_() \
catch (std::exception const& e) { \
gtest_msg.value = ( \
"it throws std::exception-derived exception with description: \"" \
); \
gtest_msg.value += e.what(); \
gtest_msg.value += "\"."; \
goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \
}
#else // GTEST_HAS_EXCEPTIONS
#define GTEST_TEST_NO_THROW_CATCH_STD_EXCEPTION_()
#endif // GTEST_HAS_EXCEPTIONS
#define GTEST_TEST_NO_THROW_(statement, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (::testing::internal::
TrueWithString gtest_msg{}
) { \
if (::testing::internal::
AlwaysTrue()
) { \
try { \
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
} \
GTEST_TEST_NO_THROW_CATCH_STD_EXCEPTION_() \
catch (...) { \
gtest_msg.value = "it throws."; \
goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \
} \
} else \
GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__): \
fail(
(
"Expected: " #statement " doesn't throw an exception.\n" \
" Actual: " + gtest_msg.value).c_str()
)
fail("Expected: " #statement " doesn't throw an exception.\n" \
" Actual: it throws."
)
#define GTEST_TEST_ANY_THROW_(statement, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
...
...
googletest/scripts/gen_gtest_pred_impl.py
View file @
0f0634a6
...
...
@@ -78,7 +78,7 @@ def HeaderPreamble(n):
}
return
(
"""// Copyright 2006, Google Inc.
"""// Copyright 2006, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
...
...
@@ -337,7 +337,7 @@ def UnitTestPreamble():
}
return
(
"""// Copyright 2006, Google Inc.
"""// Copyright 2006, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
...
...
@@ -431,7 +431,7 @@ def TestsForArity(n):
}
tests
=
(
"""// Sample functions/functors for testing
%(arity)
s predicate assertions.
"""// Sample functions/functors for testing
%(arity)
s predicate assertions.
// A
%(arity)
s predicate function.
template <
%(types)
s>
...
...
@@ -544,10 +544,10 @@ class Predicate%(n)sTest : public testing::Test {
}
}
// true if
and only i
f the test function is expected to run to finish.
// true iff the test function is expected to run to finish.
static bool expected_to_finish_;
// true if
and only i
f the test function did run to finish.
// true iff the test function did run to finish.
static bool finished_;
"""
%
DEFS
...
...
@@ -576,12 +576,12 @@ typedef Predicate%(n)sTest ASSERT_PRED%(n)sTest;
"""Returns the test for a predicate assertion macro.
Args:
use_format: true if
and only i
f the assertion is a *_PRED_FORMAT*.
use_assert: true if
and only i
f the assertion is a ASSERT_*.
expect_failure: true if
and only i
f the assertion is expected to fail.
use_functor: true if
and only i
f the first argument of the assertion is
use_format: true iff the assertion is a *_PRED_FORMAT*.
use_assert: true iff the assertion is a ASSERT_*.
expect_failure: true iff the assertion is expected to fail.
use_functor: true iff the first argument of the assertion is
a functor (as opposed to a function)
use_user_type: true if
and only i
f the predicate functor/function takes
use_user_type: true iff the predicate functor/function takes
argument(s) of a user-defined type.
Example:
...
...
googletest/src/gtest-death-test.cc
View file @
0f0634a6
...
...
@@ -1364,7 +1364,7 @@ static pid_t ExecDeathTestSpawnChild(char* const* argv, int close_fd) {
if
(
!
use_fork
)
{
static
const
bool
stack_grows_down
=
StackGrowsDown
();
const
auto
stack_size
=
static_cast
<
size_t
>
(
getpagesize
()
*
2
);
const
auto
stack_size
=
static_cast
<
size_t
>
(
getpagesize
());
// MMAP_ANONYMOUS is not defined on Mac, so we use MAP_ANON instead.
void
*
const
stack
=
mmap
(
nullptr
,
stack_size
,
PROT_READ
|
PROT_WRITE
,
MAP_ANON
|
MAP_PRIVATE
,
-
1
,
0
);
...
...
googletest/src/gtest.cc
View file @
0f0634a6
...
...
@@ -83,11 +83,8 @@
# include <windows.h> // NOLINT
# undef min
#ifdef _MSC_VER
# include <crtdbg.h> // NOLINT
# include <debugapi.h> // NOLINT
#endif
# include <io.h> // NOLINT
# include <sys/timeb.h> // NOLINT
# include <sys/types.h> // NOLINT
...
...
@@ -4911,6 +4908,7 @@ int UnitTest::Run() {
_set_abort_behavior
(
0x0
,
// Clear the following flags:
_WRITE_ABORT_MSG
|
_CALL_REPORTFAULT
);
// pop-up window, core dump.
# endif
// In debug mode, the Windows CRT can crash with an assertion over invalid
// input (e.g. passing an invalid file descriptor). The default handling
...
...
@@ -4921,7 +4919,6 @@ int UnitTest::Run() {
_CRTDBG_MODE_FILE
|
_CRTDBG_MODE_DEBUG
);
(
void
)
_CrtSetReportFile
(
_CRT_ASSERT
,
_CRTDBG_FILE_STDERR
);
}
# endif
}
#endif // GTEST_OS_WINDOWS
...
...
googletest/test/gtest_unittest.cc
View file @
0f0634a6
...
...
@@ -3348,9 +3348,6 @@ TEST_F(SingleEvaluationTest, OtherCases) {
void
ThrowAnInteger
()
{
throw
1
;
}
void
ThrowRuntimeError
(
const
char
*
what
)
{
throw
std
::
runtime_error
(
what
);
}
// Tests that assertion arguments are evaluated exactly once.
TEST_F
(
SingleEvaluationTest
,
ExceptionTests
)
{
...
...
@@ -3830,11 +3827,6 @@ TEST(AssertionTest, ASSERT_NO_THROW) {
EXPECT_FATAL_FAILURE
(
ASSERT_NO_THROW
(
ThrowAnInteger
()),
"Expected: ThrowAnInteger() doesn't throw an exception."
"
\n
Actual: it throws."
);
EXPECT_FATAL_FAILURE
(
ASSERT_NO_THROW
(
ThrowRuntimeError
(
"A description"
)),
"Expected: ThrowRuntimeError(
\"
A description
\"
) "
"doesn't throw an exception.
\n
"
"Actual: it throws std::exception-derived exception "
"with description:
\"
A description
\"
."
);
}
// Tests ASSERT_ANY_THROW.
...
...
@@ -4572,11 +4564,6 @@ TEST(ExpectTest, EXPECT_NO_THROW) {
EXPECT_NONFATAL_FAILURE
(
EXPECT_NO_THROW
(
ThrowAnInteger
()),
"Expected: ThrowAnInteger() doesn't throw an "
"exception.
\n
Actual: it throws."
);
EXPECT_NONFATAL_FAILURE
(
EXPECT_NO_THROW
(
ThrowRuntimeError
(
"A description"
)),
"Expected: ThrowRuntimeError(
\"
A description
\"
) "
"doesn't throw an exception.
\n
"
"Actual: it throws std::exception-derived exception "
"with description:
\"
A description
\"
."
);
}
// Tests EXPECT_ANY_THROW.
...
...
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