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
1b89db97
Commit
1b89db97
authored
Feb 28, 2013
by
zhanyong.wan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removes an unused variable; also refactors to support an up-coming
googlemock change.
parent
88fe9079
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
19 deletions
+32
-19
gtest-internal.h
include/gtest/internal/gtest-internal.h
+19
-0
gtest-internal-inl.h
src/gtest-internal-inl.h
+0
-1
gtest.cc
src/gtest.cc
+13
-18
No files found.
include/gtest/internal/gtest-internal.h
View file @
1b89db97
...
@@ -46,6 +46,10 @@
...
@@ -46,6 +46,10 @@
# include <unistd.h>
# include <unistd.h>
#endif // GTEST_OS_LINUX
#endif // GTEST_OS_LINUX
#if GTEST_HAS_EXCEPTIONS
# include <stdexcept>
#endif
#include <ctype.h>
#include <ctype.h>
#include <string.h>
#include <string.h>
#include <iomanip>
#include <iomanip>
...
@@ -166,6 +170,21 @@ char (&IsNullLiteralHelper(...))[2]; // NOLINT
...
@@ -166,6 +170,21 @@ char (&IsNullLiteralHelper(...))[2]; // NOLINT
GTEST_API_
std
::
string
AppendUserMessage
(
GTEST_API_
std
::
string
AppendUserMessage
(
const
std
::
string
&
gtest_msg
,
const
Message
&
user_msg
);
const
std
::
string
&
gtest_msg
,
const
Message
&
user_msg
);
#if GTEST_HAS_EXCEPTIONS
// This exception is thrown by (and only by) a failed Google Test
// assertion when GTEST_FLAG(throw_on_failure) is true (if exceptions
// are enabled). We derive it from std::runtime_error, which is for
// errors presumably detectable only at run time. Since
// std::runtime_error inherits from std::exception, many testing
// frameworks know how to extract and print the message inside it.
class
GTEST_API_
GoogleTestFailureException
:
public
::
std
::
runtime_error
{
public
:
explicit
GoogleTestFailureException
(
const
TestPartResult
&
failure
);
};
#endif // GTEST_HAS_EXCEPTIONS
// A helper class for creating scoped traces in user programs.
// A helper class for creating scoped traces in user programs.
class
GTEST_API_
ScopedTrace
{
class
GTEST_API_
ScopedTrace
{
public
:
public
:
...
...
src/gtest-internal-inl.h
View file @
1b89db97
...
@@ -215,7 +215,6 @@ class GTestFlagSaver {
...
@@ -215,7 +215,6 @@ class GTestFlagSaver {
bool
list_tests_
;
bool
list_tests_
;
std
::
string
output_
;
std
::
string
output_
;
bool
print_time_
;
bool
print_time_
;
bool
pretty_
;
internal
::
Int32
random_seed_
;
internal
::
Int32
random_seed_
;
internal
::
Int32
repeat_
;
internal
::
Int32
repeat_
;
bool
shuffle_
;
bool
shuffle_
;
...
...
src/gtest.cc
View file @
1b89db97
...
@@ -1903,6 +1903,8 @@ static std::string* FormatSehExceptionMessage(DWORD exception_code,
...
@@ -1903,6 +1903,8 @@ static std::string* FormatSehExceptionMessage(DWORD exception_code,
#endif // GTEST_HAS_SEH
#endif // GTEST_HAS_SEH
namespace
internal
{
#if GTEST_HAS_EXCEPTIONS
#if GTEST_HAS_EXCEPTIONS
// Adds an "exception thrown" fatal failure to the current test.
// Adds an "exception thrown" fatal failure to the current test.
...
@@ -1922,20 +1924,12 @@ static std::string FormatCxxExceptionMessage(const char* description,
...
@@ -1922,20 +1924,12 @@ static std::string FormatCxxExceptionMessage(const char* description,
static
std
::
string
PrintTestPartResultToString
(
static
std
::
string
PrintTestPartResultToString
(
const
TestPartResult
&
test_part_result
);
const
TestPartResult
&
test_part_result
);
// A failed Google Test assertion will throw an exception of this type when
GoogleTestFailureException
::
GoogleTestFailureException
(
// GTEST_FLAG(throw_on_failure) is true (if exceptions are enabled). We
const
TestPartResult
&
failure
)
// derive it from std::runtime_error, which is for errors presumably
:
::
std
::
runtime_error
(
PrintTestPartResultToString
(
failure
).
c_str
())
{}
// detectable only at run time. Since std::runtime_error inherits from
// std::exception, many testing frameworks know how to extract and print the
// message inside it.
class
GoogleTestFailureException
:
public
::
std
::
runtime_error
{
public
:
explicit
GoogleTestFailureException
(
const
TestPartResult
&
failure
)
:
::
std
::
runtime_error
(
PrintTestPartResultToString
(
failure
).
c_str
())
{}
};
#endif // GTEST_HAS_EXCEPTIONS
#endif // GTEST_HAS_EXCEPTIONS
namespace
internal
{
// We put these helper functions in the internal namespace as IBM's xlC
// We put these helper functions in the internal namespace as IBM's xlC
// compiler rejects the code if they were declared static.
// compiler rejects the code if they were declared static.
...
@@ -2001,9 +1995,10 @@ Result HandleExceptionsInMethodIfSupported(
...
@@ -2001,9 +1995,10 @@ Result HandleExceptionsInMethodIfSupported(
#if GTEST_HAS_EXCEPTIONS
#if GTEST_HAS_EXCEPTIONS
try
{
try
{
return
HandleSehExceptionsInMethodIfSupported
(
object
,
method
,
location
);
return
HandleSehExceptionsInMethodIfSupported
(
object
,
method
,
location
);
}
catch
(
const
GoogleTestFailureException
&
)
{
// NOLINT
}
catch
(
const
internal
::
GoogleTestFailureException
&
)
{
// NOLINT
// This exception doesn't originate in code under test. It makes no
// This exception type can only be thrown by a failed Google
// sense to report it as a test failure.
// Test assertion with the intention of letting another testing
// framework catch it. Therefore we just re-throw it.
throw
;
throw
;
}
catch
(
const
std
::
exception
&
e
)
{
// NOLINT
}
catch
(
const
std
::
exception
&
e
)
{
// NOLINT
internal
::
ReportFailureInUnknownLocation
(
internal
::
ReportFailureInUnknownLocation
(
...
@@ -2390,6 +2385,8 @@ static const char * TestPartResultTypeToString(TestPartResult::Type type) {
...
@@ -2390,6 +2385,8 @@ static const char * TestPartResultTypeToString(TestPartResult::Type type) {
}
}
}
}
namespace
internal
{
// Prints a TestPartResult to an std::string.
// Prints a TestPartResult to an std::string.
static
std
::
string
PrintTestPartResultToString
(
static
std
::
string
PrintTestPartResultToString
(
const
TestPartResult
&
test_part_result
)
{
const
TestPartResult
&
test_part_result
)
{
...
@@ -2421,8 +2418,6 @@ static void PrintTestPartResult(const TestPartResult& test_part_result) {
...
@@ -2421,8 +2418,6 @@ static void PrintTestPartResult(const TestPartResult& test_part_result) {
// class PrettyUnitTestResultPrinter
// class PrettyUnitTestResultPrinter
namespace
internal
{
enum
GTestColor
{
enum
GTestColor
{
COLOR_DEFAULT
,
COLOR_DEFAULT
,
COLOR_RED
,
COLOR_RED
,
...
@@ -3601,7 +3596,7 @@ void UnitTest::AddTestPartResult(
...
@@ -3601,7 +3596,7 @@ void UnitTest::AddTestPartResult(
#endif // GTEST_OS_WINDOWS
#endif // GTEST_OS_WINDOWS
}
else
if
(
GTEST_FLAG
(
throw_on_failure
))
{
}
else
if
(
GTEST_FLAG
(
throw_on_failure
))
{
#if GTEST_HAS_EXCEPTIONS
#if GTEST_HAS_EXCEPTIONS
throw
GoogleTestFailureException
(
result
);
throw
internal
::
GoogleTestFailureException
(
result
);
#else
#else
// We cannot call abort() as it generates a pop-up in debug mode
// We cannot call abort() as it generates a pop-up in debug mode
// that cannot be suppressed in VC 7.1 or below.
// that cannot be suppressed in VC 7.1 or below.
...
...
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