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
b5d3a178
Commit
b5d3a178
authored
Sep 27, 2010
by
zhanyong.wan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allows EXPECT_FATAL_FAILURE() and friends to accept a string object as the second argument.
parent
345d9ebf
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
6 deletions
+29
-6
gtest-spi.h
include/gtest/gtest-spi.h
+2
-2
gtest.cc
src/gtest.cc
+4
-4
gtest_unittest.cc
test/gtest_unittest.cc
+23
-0
No files found.
include/gtest/gtest-spi.h
View file @
b5d3a178
...
@@ -98,12 +98,12 @@ class GTEST_API_ SingleFailureChecker {
...
@@ -98,12 +98,12 @@ class GTEST_API_ SingleFailureChecker {
// The constructor remembers the arguments.
// The constructor remembers the arguments.
SingleFailureChecker
(
const
TestPartResultArray
*
results
,
SingleFailureChecker
(
const
TestPartResultArray
*
results
,
TestPartResult
::
Type
type
,
TestPartResult
::
Type
type
,
const
char
*
substr
);
const
string
&
substr
);
~
SingleFailureChecker
();
~
SingleFailureChecker
();
private
:
private
:
const
TestPartResultArray
*
const
results_
;
const
TestPartResultArray
*
const
results_
;
const
TestPartResult
::
Type
type_
;
const
TestPartResult
::
Type
type_
;
const
S
tring
substr_
;
const
s
tring
substr_
;
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
SingleFailureChecker
);
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
SingleFailureChecker
);
};
};
...
...
src/gtest.cc
View file @
b5d3a178
...
@@ -607,7 +607,7 @@ AssertionResult HasOneFailure(const char* /* results_expr */,
...
@@ -607,7 +607,7 @@ AssertionResult HasOneFailure(const char* /* results_expr */,
const
char
*
/* substr_expr */
,
const
char
*
/* substr_expr */
,
const
TestPartResultArray
&
results
,
const
TestPartResultArray
&
results
,
TestPartResult
::
Type
type
,
TestPartResult
::
Type
type
,
const
char
*
substr
)
{
const
string
&
substr
)
{
const
String
expected
(
type
==
TestPartResult
::
kFatalFailure
?
const
String
expected
(
type
==
TestPartResult
::
kFatalFailure
?
"1 fatal failure"
:
"1 fatal failure"
:
"1 non-fatal failure"
);
"1 non-fatal failure"
);
...
@@ -629,7 +629,7 @@ AssertionResult HasOneFailure(const char* /* results_expr */,
...
@@ -629,7 +629,7 @@ AssertionResult HasOneFailure(const char* /* results_expr */,
return
AssertionFailure
(
msg
);
return
AssertionFailure
(
msg
);
}
}
if
(
strstr
(
r
.
message
(),
substr
)
==
NULL
)
{
if
(
strstr
(
r
.
message
(),
substr
.
c_str
()
)
==
NULL
)
{
msg
<<
"Expected: "
<<
expected
<<
" containing
\"
"
msg
<<
"Expected: "
<<
expected
<<
" containing
\"
"
<<
substr
<<
"
\"\n
"
<<
substr
<<
"
\"\n
"
<<
" Actual:
\n
"
<<
" Actual:
\n
"
...
@@ -646,7 +646,7 @@ AssertionResult HasOneFailure(const char* /* results_expr */,
...
@@ -646,7 +646,7 @@ AssertionResult HasOneFailure(const char* /* results_expr */,
SingleFailureChecker
::
SingleFailureChecker
(
SingleFailureChecker
::
SingleFailureChecker
(
const
TestPartResultArray
*
results
,
const
TestPartResultArray
*
results
,
TestPartResult
::
Type
type
,
TestPartResult
::
Type
type
,
const
char
*
substr
)
const
string
&
substr
)
:
results_
(
results
),
:
results_
(
results
),
type_
(
type
),
type_
(
type
),
substr_
(
substr
)
{}
substr_
(
substr
)
{}
...
@@ -656,7 +656,7 @@ SingleFailureChecker:: SingleFailureChecker(
...
@@ -656,7 +656,7 @@ SingleFailureChecker:: SingleFailureChecker(
// type and contains the given substring. If that's not the case, a
// type and contains the given substring. If that's not the case, a
// non-fatal failure will be generated.
// non-fatal failure will be generated.
SingleFailureChecker
::~
SingleFailureChecker
()
{
SingleFailureChecker
::~
SingleFailureChecker
()
{
EXPECT_PRED_FORMAT3
(
HasOneFailure
,
*
results_
,
type_
,
substr_
.
c_str
()
);
EXPECT_PRED_FORMAT3
(
HasOneFailure
,
*
results_
,
type_
,
substr_
);
}
}
DefaultGlobalTestPartResultReporter
::
DefaultGlobalTestPartResultReporter
(
DefaultGlobalTestPartResultReporter
::
DefaultGlobalTestPartResultReporter
(
...
...
test/gtest_unittest.cc
View file @
b5d3a178
...
@@ -1335,6 +1335,17 @@ TEST_F(ExpectFatalFailureTest, CatchesFatalFaliure) {
...
@@ -1335,6 +1335,17 @@ TEST_F(ExpectFatalFailureTest, CatchesFatalFaliure) {
EXPECT_FATAL_FAILURE
(
AddFatalFailure
(),
"Expected fatal failure."
);
EXPECT_FATAL_FAILURE
(
AddFatalFailure
(),
"Expected fatal failure."
);
}
}
#if GTEST_HAS_GLOBAL_STRING
TEST_F
(
ExpectFatalFailureTest
,
AcceptsStringObject
)
{
EXPECT_FATAL_FAILURE
(
AddFatalFailure
(),
::
string
(
"Expected fatal failure."
));
}
#endif
TEST_F
(
ExpectFatalFailureTest
,
AcceptsStdStringObject
)
{
EXPECT_FATAL_FAILURE
(
AddFatalFailure
(),
::
std
::
string
(
"Expected fatal failure."
));
}
TEST_F
(
ExpectFatalFailureTest
,
CatchesFatalFailureOnAllThreads
)
{
TEST_F
(
ExpectFatalFailureTest
,
CatchesFatalFailureOnAllThreads
)
{
// We have another test below to verify that the macro catches fatal
// We have another test below to verify that the macro catches fatal
// failures generated on another thread.
// failures generated on another thread.
...
@@ -1412,6 +1423,18 @@ TEST_F(ExpectNonfatalFailureTest, CatchesNonfatalFailure) {
...
@@ -1412,6 +1423,18 @@ TEST_F(ExpectNonfatalFailureTest, CatchesNonfatalFailure) {
"Expected non-fatal failure."
);
"Expected non-fatal failure."
);
}
}
#if GTEST_HAS_GLOBAL_STRING
TEST_F
(
ExpectNonfatalFailureTest
,
AcceptsStringObject
)
{
EXPECT_NONFATAL_FAILURE
(
AddNonfatalFailure
(),
::
string
(
"Expected non-fatal failure."
));
}
#endif
TEST_F
(
ExpectNonfatalFailureTest
,
AcceptsStdStringObject
)
{
EXPECT_NONFATAL_FAILURE
(
AddNonfatalFailure
(),
::
std
::
string
(
"Expected non-fatal failure."
));
}
TEST_F
(
ExpectNonfatalFailureTest
,
CatchesNonfatalFailureOnAllThreads
)
{
TEST_F
(
ExpectNonfatalFailureTest
,
CatchesNonfatalFailureOnAllThreads
)
{
// We have another test below to verify that the macro catches
// We have another test below to verify that the macro catches
// non-fatal failures generated on another thread.
// non-fatal failures generated on another thread.
...
...
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