Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Googletest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Meng
Googletest
Commits
78d3bfeb
Unverified
Commit
78d3bfeb
authored
6 years ago
by
Gennadiy Civil
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Formatting
parent
67d3c0f6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
googletest/include/gtest/internal/gtest-internal.h
+64
-61
64 additions, 61 deletions
googletest/include/gtest/internal/gtest-internal.h
with
64 additions
and
61 deletions
googletest/include/gtest/internal/gtest-internal.h
+
64
−
61
View file @
78d3bfeb
...
...
@@ -32,12 +32,14 @@
// This header file declares functions and macros used internally by
// Google Test. They are subject to change without notice.
// GOOGLETEST_CM0001 DO NOT DELETE
// IWYU pragma: private, include "testing/base/public/gunit.h"
// IWYU pragma: friend third_party/googletest/googletest/.*
// IWYU pragma: friend third_party/googletest/googlemock/.*
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
#include
"gtest/internal/gtest-port.h"
#include
"
third_party/googletest/googletest/include/
gtest/internal/gtest-port.h"
#if GTEST_OS_LINUX
# include <stdlib.h>
...
...
@@ -60,10 +62,10 @@
#include
<string>
#include
<vector>
#include
"gtest/gtest-message.h"
#include
"gtest/internal/gtest-filepath.h"
#include
"gtest/internal/gtest-string.h"
#include
"gtest/internal/gtest-type-util.h"
#include
"
third_party/googletest/googletest/include/
gtest/gtest-message.h"
#include
"
third_party/googletest/googletest/include/
gtest/internal/gtest-filepath.h"
#include
"
third_party/googletest/googletest/include/
gtest/internal/gtest-string.h"
#include
"
third_party/googletest/googletest/include/
gtest/internal/gtest-type-util.h"
// Due to C++ preprocessor weirdness, we need double indirection to
// concatenate two tokens when one of them is __LINE__. Writing
...
...
@@ -752,7 +754,7 @@ class TypeParameterizedTestCase<Fixture, Templates0, Types> {
// Returns the current OS stack trace as an std::string.
//
// The maximum number of stack frames to be included is specified by
// the g
tes
t_stack_trace_depth flag. The skip_count parameter
// the g
uni
t_stack_trace_depth flag. The skip_count parameter
// specifies the number of top frames to be skipped, which doesn't
// count against the number of frames to be included.
//
...
...
@@ -1189,16 +1191,15 @@ class NativeArray {
GTEST_DISALLOW_ASSIGN_
(
NativeArray
);
};
class
AdditionalMessage
{
public:
class
AdditionalMessage
{
public:
AdditionalMessage
(
const
char
*
message
)
:
msg
(
message
)
{}
void
set
(
const
std
::
string
&
message
)
{
msg
=
message
;
}
operator
bool
()
const
{
return
true
;
}
const
std
::
string
&
get
()
const
{
return
msg
;
}
private
:
private
:
std
::
string
msg
;
};
...
...
@@ -1227,58 +1228,60 @@ private:
#define GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) \
if (::testing::internal::AlwaysTrue()) { statement; }
#define GTEST_TEST_THROW_(statement, expected_exception, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (::testing::internal::AdditionalMessage message = "") { \
bool gtest_caught_expected = false; \
try { \
try { \
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
} \
catch (expected_exception const&) {
\
gtest_caught_expected = true;
\
throw;
\
}
\
}
\
catch (const std::exception& e) {
\
if (!gtest_caught_expected) {
\
message.set("it throws a different type "
\
"with message: " +
std::string(e.what())); \
#define GTEST_TEST_THROW_(statement, expected_exception, fail)
\
GTEST_AMBIGUOUS_ELSE_BLOCKER_
\
if (::testing::internal::AdditionalMessage message = "") {
\
bool gtest_caught_expected = false;
\
try {
\
try {
\
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement);
\
}
catch (expected_exception const&) {
\
gtest_caught_expected = true;
\
throw;
\
}
\
} catch (const std::exception& e) {
\
if (!gtest_caught_expected) {
\
message.set(
\
"it throws a different type "
\
"with message: " +
\
std::string(e.what()));
\
goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
} \
} \
catch (...) { \
if (!gtest_caught_expected) { \
message.set("it throws a different type."); \
} \
} catch (...) { \
if (!gtest_caught_expected) { \
message.set("it throws a different type."); \
goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
} \
} \
if (!gtest_caught_expected) { \
message.set("it throws nothing."); \
goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
} \
} else \
GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__): \
fail(("Expected: " #statement " throws an exception of type " \
#expected_exception ".\n Actual: " + message.get()).c_str())
#define GTEST_TEST_NO_THROW_(statement, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (::testing::internal::AdditionalMessage message = ".") { \
try { \
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
} \
catch (const std::exception& e) { \
message.set(std::string(": ") + e.what()); \
goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \
} \
catch (...) { \
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: it throws" + message.get()).c_str())
} \
} \
if (!gtest_caught_expected) { \
message.set("it throws nothing."); \
goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
} \
} else \
GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__) \
: fail(("Expected: " #statement \
" throws an exception of type " #expected_exception \
".\n Actual: " + \
message.get()) \
.c_str())
#define GTEST_TEST_NO_THROW_(statement, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (::testing::internal::AdditionalMessage message = ".") { \
try { \
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
} catch (const std::exception& e) { \
message.set(std::string(": ") + e.what()); \
goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \
} catch (...) { \
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: it throws" + \
message.get()) \
.c_str())
#define GTEST_TEST_ANY_THROW_(statement, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment