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
827515f8
Commit
827515f8
authored
Jan 03, 2019
by
misterg
Committed by
Gennadiy Civil
Jan 03, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Googletest export
Fixes #1261 PiperOrigin-RevId: 227740670
parent
3a460a26
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
38 deletions
+48
-38
gtest_pred_impl.h
googletest/include/gtest/gtest_pred_impl.h
+37
-37
gtest_pred_impl_unittest.cc
googletest/test/gtest_pred_impl_unittest.cc
+1
-1
gtest_unittest.cc
googletest/test/gtest_unittest.cc
+10
-0
No files found.
googletest/include/gtest/gtest_pred_impl.h
View file @
827515f8
...
@@ -27,11 +27,10 @@
...
@@ -27,11 +27,10 @@
// (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.
// This file is AUTOMATICALLY GENERATED on 01/02/201
8
by command
// This file is AUTOMATICALLY GENERATED on 01/02/201
9
by command
// 'gen_gtest_pred_impl.py 5'. DO NOT EDIT BY HAND!
// 'gen_gtest_pred_impl.py 5'. DO NOT EDIT BY HAND!
//
//
// Implements a family of generic predicate assertion macros.
// Implements a family of generic predicate assertion macros.
// GOOGLETEST_CM0001 DO NOT DELETE
// GOOGLETEST_CM0001 DO NOT DELETE
#ifndef GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
#ifndef GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
...
@@ -67,6 +66,8 @@ namespace testing {
...
@@ -67,6 +66,8 @@ namespace testing {
// We also define the EXPECT_* variations.
// We also define the EXPECT_* variations.
//
//
// For now we only support predicates whose arity is at most 5.
// For now we only support predicates whose arity is at most 5.
// Please email googletestframework@googlegroups.com if you need
// support for higher arities.
// GTEST_ASSERT_ is the basic statement to which all of the assertions
// GTEST_ASSERT_ is the basic statement to which all of the assertions
// in this file reduce. Don't use this in your code.
// in this file reduce. Don't use this in your code.
...
@@ -89,9 +90,10 @@ AssertionResult AssertPred1Helper(const char* pred_text,
...
@@ -89,9 +90,10 @@ AssertionResult AssertPred1Helper(const char* pred_text,
const
T1
&
v1
)
{
const
T1
&
v1
)
{
if
(
pred
(
v1
))
return
AssertionSuccess
();
if
(
pred
(
v1
))
return
AssertionSuccess
();
return
AssertionFailure
()
<<
pred_text
<<
"("
return
AssertionFailure
()
<<
e1
<<
") evaluates to false, where"
<<
pred_text
<<
"("
<<
e1
<<
") evaluates to false, where"
<<
"
\n
"
<<
e1
<<
" evaluates to "
<<
v1
;
<<
"
\n
"
<<
e1
<<
" evaluates to "
<<
::
testing
::
PrintToString
(
v1
);
}
}
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT1.
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT1.
...
@@ -133,11 +135,12 @@ AssertionResult AssertPred2Helper(const char* pred_text,
...
@@ -133,11 +135,12 @@ AssertionResult AssertPred2Helper(const char* pred_text,
const
T2
&
v2
)
{
const
T2
&
v2
)
{
if
(
pred
(
v1
,
v2
))
return
AssertionSuccess
();
if
(
pred
(
v1
,
v2
))
return
AssertionSuccess
();
return
AssertionFailure
()
<<
pred_text
<<
"("
return
AssertionFailure
()
<<
e1
<<
", "
<<
pred_text
<<
"("
<<
e1
<<
", "
<<
e2
<<
e2
<<
") evaluates to false, where"
<<
") evaluates to false, where"
<<
"
\n
"
<<
e1
<<
" evaluates to "
<<
v1
<<
"
\n
"
<<
"
\n
"
<<
e2
<<
" evaluates to "
<<
v2
;
<<
e1
<<
" evaluates to "
<<
::
testing
::
PrintToString
(
v1
)
<<
"
\n
"
<<
e2
<<
" evaluates to "
<<
::
testing
::
PrintToString
(
v2
);
}
}
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT2.
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT2.
...
@@ -184,13 +187,13 @@ AssertionResult AssertPred3Helper(const char* pred_text,
...
@@ -184,13 +187,13 @@ AssertionResult AssertPred3Helper(const char* pred_text,
const
T3
&
v3
)
{
const
T3
&
v3
)
{
if
(
pred
(
v1
,
v2
,
v3
))
return
AssertionSuccess
();
if
(
pred
(
v1
,
v2
,
v3
))
return
AssertionSuccess
();
return
AssertionFailure
()
<<
pred_text
<<
"("
return
AssertionFailure
()
<<
e1
<<
", "
<<
pred_text
<<
"("
<<
e1
<<
", "
<<
e2
<<
", "
<<
e3
<<
e2
<<
",
"
<<
") evaluates to false, where
"
<<
e3
<<
") evaluates to false, where
"
<<
"
\n
"
<<
"
\n
"
<<
e1
<<
" evaluates to "
<<
v1
<<
e1
<<
" evaluates to "
<<
::
testing
::
PrintToString
(
v1
)
<<
"
\n
"
<<
"
\n
"
<<
e2
<<
" evaluates to "
<<
v2
<<
e2
<<
" evaluates to "
<<
::
testing
::
PrintToString
(
v2
)
<<
"
\n
"
<<
"
\n
"
<<
e3
<<
" evaluates to "
<<
v3
;
<<
e3
<<
" evaluates to "
<<
::
testing
::
PrintToString
(
v3
)
;
}
}
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT3.
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT3.
...
@@ -242,15 +245,14 @@ AssertionResult AssertPred4Helper(const char* pred_text,
...
@@ -242,15 +245,14 @@ AssertionResult AssertPred4Helper(const char* pred_text,
const
T4
&
v4
)
{
const
T4
&
v4
)
{
if
(
pred
(
v1
,
v2
,
v3
,
v4
))
return
AssertionSuccess
();
if
(
pred
(
v1
,
v2
,
v3
,
v4
))
return
AssertionSuccess
();
return
AssertionFailure
()
<<
pred_text
<<
"("
return
AssertionFailure
()
<<
e1
<<
", "
<<
pred_text
<<
"("
<<
e1
<<
", "
<<
e2
<<
", "
<<
e3
<<
", "
<<
e4
<<
e2
<<
", "
<<
") evaluates to false, where"
<<
e3
<<
", "
<<
"
\n
"
<<
e4
<<
") evaluates to false, where"
<<
e1
<<
" evaluates to "
<<
::
testing
::
PrintToString
(
v1
)
<<
"
\n
"
<<
"
\n
"
<<
e1
<<
" evaluates to "
<<
v1
<<
e2
<<
" evaluates to "
<<
::
testing
::
PrintToString
(
v2
)
<<
"
\n
"
<<
"
\n
"
<<
e2
<<
" evaluates to "
<<
v2
<<
e3
<<
" evaluates to "
<<
::
testing
::
PrintToString
(
v3
)
<<
"
\n
"
<<
"
\n
"
<<
e3
<<
" evaluates to "
<<
v3
<<
e4
<<
" evaluates to "
<<
::
testing
::
PrintToString
(
v4
);
<<
"
\n
"
<<
e4
<<
" evaluates to "
<<
v4
;
}
}
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT4.
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT4.
...
@@ -307,17 +309,15 @@ AssertionResult AssertPred5Helper(const char* pred_text,
...
@@ -307,17 +309,15 @@ AssertionResult AssertPred5Helper(const char* pred_text,
const
T5
&
v5
)
{
const
T5
&
v5
)
{
if
(
pred
(
v1
,
v2
,
v3
,
v4
,
v5
))
return
AssertionSuccess
();
if
(
pred
(
v1
,
v2
,
v3
,
v4
,
v5
))
return
AssertionSuccess
();
return
AssertionFailure
()
<<
pred_text
<<
"("
return
AssertionFailure
()
<<
e1
<<
", "
<<
pred_text
<<
"("
<<
e1
<<
", "
<<
e2
<<
", "
<<
e3
<<
", "
<<
e4
<<
e2
<<
", "
<<
", "
<<
e5
<<
") evaluates to false, where"
<<
e3
<<
", "
<<
"
\n
"
<<
e4
<<
", "
<<
e1
<<
" evaluates to "
<<
::
testing
::
PrintToString
(
v1
)
<<
"
\n
"
<<
e5
<<
") evaluates to false, where"
<<
e2
<<
" evaluates to "
<<
::
testing
::
PrintToString
(
v2
)
<<
"
\n
"
<<
"
\n
"
<<
e1
<<
" evaluates to "
<<
v1
<<
e3
<<
" evaluates to "
<<
::
testing
::
PrintToString
(
v3
)
<<
"
\n
"
<<
"
\n
"
<<
e2
<<
" evaluates to "
<<
v2
<<
e4
<<
" evaluates to "
<<
::
testing
::
PrintToString
(
v4
)
<<
"
\n
"
<<
"
\n
"
<<
e3
<<
" evaluates to "
<<
v3
<<
e5
<<
" evaluates to "
<<
::
testing
::
PrintToString
(
v5
);
<<
"
\n
"
<<
e4
<<
" evaluates to "
<<
v4
<<
"
\n
"
<<
e5
<<
" evaluates to "
<<
v5
;
}
}
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT5.
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT5.
...
...
googletest/test/gtest_pred_impl_unittest.cc
View file @
827515f8
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
// (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.
// This file is AUTOMATICALLY GENERATED on 01/02/201
8
by command
// This file is AUTOMATICALLY GENERATED on 01/02/201
9
by command
// 'gen_gtest_pred_impl.py 5'. DO NOT EDIT BY HAND!
// 'gen_gtest_pred_impl.py 5'. DO NOT EDIT BY HAND!
// Regression test for gtest_pred_impl.h
// Regression test for gtest_pred_impl.h
...
...
googletest/test/gtest_unittest.cc
View file @
827515f8
...
@@ -2357,6 +2357,16 @@ TEST(PredTest, SingleEvaluationOnFailure) {
...
@@ -2357,6 +2357,16 @@ TEST(PredTest, SingleEvaluationOnFailure) {
EXPECT_EQ
(
1
,
n4
)
<<
"Argument 4 is not evaluated exactly once."
;
EXPECT_EQ
(
1
,
n4
)
<<
"Argument 4 is not evaluated exactly once."
;
}
}
// Test predicate assertions for sets
TEST
(
PredTest
,
ExpectPredEvalFailure
)
{
std
::
set
<
int
>
set_a
=
{
2
,
1
,
3
,
4
,
5
};
std
::
set
<
int
>
set_b
=
{
0
,
4
,
8
};
const
auto
compare_sets
=
[]
(
std
::
set
<
int
>
,
std
::
set
<
int
>
)
{
return
false
;
};
EXPECT_NONFATAL_FAILURE
(
EXPECT_PRED2
(
compare_sets
,
set_a
,
set_b
),
"compare_sets(set_a, set_b) evaluates to false, where
\n
set_a evaluates "
"to { 1, 2, 3, 4, 5 }
\n
set_b evaluates to { 0, 4, 8 }"
);
}
// Some helper functions for testing using overloaded/template
// Some helper functions for testing using overloaded/template
// functions with ASSERT_PREDn and EXPECT_PREDn.
// functions with ASSERT_PREDn and EXPECT_PREDn.
...
...
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