Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
827515f8
Commit
827515f8
authored
Jan 03, 2019
by
misterg
Committed by
Gennadiy Civil
Jan 03, 2019
Browse files
Googletest export
Fixes #1261 PiperOrigin-RevId: 227740670
parent
3a460a26
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
38 deletions
+48
-38
googletest/include/gtest/gtest_pred_impl.h
googletest/include/gtest/gtest_pred_impl.h
+37
-37
googletest/test/gtest_pred_impl_unittest.cc
googletest/test/gtest_pred_impl_unittest.cc
+1
-1
googletest/test/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 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// 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!
//
// Implements a family of generic predicate assertion macros.
// GOOGLETEST_CM0001 DO NOT DELETE
#ifndef GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
...
...
@@ -67,6 +66,8 @@ namespace testing {
// We also define the EXPECT_* variations.
//
// 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
// in this file reduce. Don't use this in your code.
...
...
@@ -89,9 +90,10 @@ AssertionResult AssertPred1Helper(const char* pred_text,
const
T1
&
v1
)
{
if
(
pred
(
v1
))
return
AssertionSuccess
();
return
AssertionFailure
()
<<
pred_text
<<
"("
<<
e1
<<
") evaluates to false, where"
<<
"
\n
"
<<
e1
<<
" evaluates to "
<<
v1
;
return
AssertionFailure
()
<<
pred_text
<<
"("
<<
e1
<<
") evaluates to false, where"
<<
"
\n
"
<<
e1
<<
" evaluates to "
<<
::
testing
::
PrintToString
(
v1
);
}
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT1.
...
...
@@ -133,11 +135,12 @@ AssertionResult AssertPred2Helper(const char* pred_text,
const
T2
&
v2
)
{
if
(
pred
(
v1
,
v2
))
return
AssertionSuccess
();
return
AssertionFailure
()
<<
pred_text
<<
"("
<<
e1
<<
", "
<<
e2
<<
") evaluates to false, where"
<<
"
\n
"
<<
e1
<<
" evaluates to "
<<
v1
<<
"
\n
"
<<
e2
<<
" evaluates to "
<<
v2
;
return
AssertionFailure
()
<<
pred_text
<<
"("
<<
e1
<<
", "
<<
e2
<<
") evaluates to false, where"
<<
"
\n
"
<<
e1
<<
" evaluates to "
<<
::
testing
::
PrintToString
(
v1
)
<<
"
\n
"
<<
e2
<<
" evaluates to "
<<
::
testing
::
PrintToString
(
v2
);
}
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT2.
...
...
@@ -184,13 +187,13 @@ AssertionResult AssertPred3Helper(const char* pred_text,
const
T3
&
v3
)
{
if
(
pred
(
v1
,
v2
,
v3
))
return
AssertionSuccess
();
return
AssertionFailure
()
<<
pred_text
<<
"("
<<
e
1
<<
", "
<<
e2
<<
",
"
<<
e3
<<
") evaluates to false, where
"
<<
"
\n
"
<<
e1
<<
" evaluates to "
<<
v1
<<
"
\n
"
<<
e2
<<
" evaluates to "
<<
v2
<<
"
\n
"
<<
e3
<<
" evaluates to "
<<
v3
;
return
AssertionFailure
()
<<
pred_text
<<
"("
<<
e1
<<
", "
<<
e
2
<<
", "
<<
e3
<<
") evaluates to false, where
"
<<
"
\n
"
<<
e1
<<
" evaluates to "
<<
::
testing
::
PrintToString
(
v1
)
<<
"
\n
"
<<
e2
<<
" evaluates to "
<<
::
testing
::
PrintToString
(
v2
)
<<
"
\n
"
<<
e3
<<
" evaluates to "
<<
::
testing
::
PrintToString
(
v3
)
;
}
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT3.
...
...
@@ -242,15 +245,14 @@ AssertionResult AssertPred4Helper(const char* pred_text,
const
T4
&
v4
)
{
if
(
pred
(
v1
,
v2
,
v3
,
v4
))
return
AssertionSuccess
();
return
AssertionFailure
()
<<
pred_text
<<
"("
<<
e1
<<
", "
<<
e2
<<
", "
<<
e3
<<
", "
<<
e4
<<
") evaluates to false, where"
<<
"
\n
"
<<
e1
<<
" evaluates to "
<<
v1
<<
"
\n
"
<<
e2
<<
" evaluates to "
<<
v2
<<
"
\n
"
<<
e3
<<
" evaluates to "
<<
v3
<<
"
\n
"
<<
e4
<<
" evaluates to "
<<
v4
;
return
AssertionFailure
()
<<
pred_text
<<
"("
<<
e1
<<
", "
<<
e2
<<
", "
<<
e3
<<
", "
<<
e4
<<
") evaluates to false, where"
<<
"
\n
"
<<
e1
<<
" evaluates to "
<<
::
testing
::
PrintToString
(
v1
)
<<
"
\n
"
<<
e2
<<
" evaluates to "
<<
::
testing
::
PrintToString
(
v2
)
<<
"
\n
"
<<
e3
<<
" evaluates to "
<<
::
testing
::
PrintToString
(
v3
)
<<
"
\n
"
<<
e4
<<
" evaluates to "
<<
::
testing
::
PrintToString
(
v4
);
}
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT4.
...
...
@@ -307,17 +309,15 @@ AssertionResult AssertPred5Helper(const char* pred_text,
const
T5
&
v5
)
{
if
(
pred
(
v1
,
v2
,
v3
,
v4
,
v5
))
return
AssertionSuccess
();
return
AssertionFailure
()
<<
pred_text
<<
"("
<<
e1
<<
", "
<<
e2
<<
", "
<<
e3
<<
", "
<<
e4
<<
", "
<<
e5
<<
") evaluates to false, where"
<<
"
\n
"
<<
e1
<<
" evaluates to "
<<
v1
<<
"
\n
"
<<
e2
<<
" evaluates to "
<<
v2
<<
"
\n
"
<<
e3
<<
" evaluates to "
<<
v3
<<
"
\n
"
<<
e4
<<
" evaluates to "
<<
v4
<<
"
\n
"
<<
e5
<<
" evaluates to "
<<
v5
;
return
AssertionFailure
()
<<
pred_text
<<
"("
<<
e1
<<
", "
<<
e2
<<
", "
<<
e3
<<
", "
<<
e4
<<
", "
<<
e5
<<
") evaluates to false, where"
<<
"
\n
"
<<
e1
<<
" evaluates to "
<<
::
testing
::
PrintToString
(
v1
)
<<
"
\n
"
<<
e2
<<
" evaluates to "
<<
::
testing
::
PrintToString
(
v2
)
<<
"
\n
"
<<
e3
<<
" evaluates to "
<<
::
testing
::
PrintToString
(
v3
)
<<
"
\n
"
<<
e4
<<
" evaluates to "
<<
::
testing
::
PrintToString
(
v4
)
<<
"
\n
"
<<
e5
<<
" evaluates to "
<<
::
testing
::
PrintToString
(
v5
);
}
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT5.
...
...
googletest/test/gtest_pred_impl_unittest.cc
View file @
827515f8
...
...
@@ -27,7 +27,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// 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!
// Regression test for gtest_pred_impl.h
...
...
googletest/test/gtest_unittest.cc
View file @
827515f8
...
...
@@ -2357,6 +2357,16 @@ TEST(PredTest, SingleEvaluationOnFailure) {
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
// 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