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
47092933
Commit
47092933
authored
Aug 02, 2019
by
Gennadiy Civil
Browse files
Merge pull request #2361 from guillemglez:master
PiperOrigin-RevId: 261340959
parents
6a2adc0e
210239e8
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
46 deletions
+51
-46
googlemock/scripts/upload.py
googlemock/scripts/upload.py
+1
-1
googletest/docs/advanced.md
googletest/docs/advanced.md
+41
-36
googletest/scripts/gen_gtest_pred_impl.py
googletest/scripts/gen_gtest_pred_impl.py
+7
-7
googletest/scripts/pump.py
googletest/scripts/pump.py
+1
-1
googletest/scripts/upload.py
googletest/scripts/upload.py
+1
-1
No files found.
googlemock/scripts/upload.py
View file @
47092933
...
@@ -631,7 +631,7 @@ class VersionControlSystem(object):
...
@@ -631,7 +631,7 @@ class VersionControlSystem(object):
new_content: For text files, this is empty. For binary files, this is
new_content: For text files, this is empty. For binary files, this is
the contents of the new file, since the diff output won't contain
the contents of the new file, since the diff output won't contain
information to reconstruct the current file.
information to reconstruct the current file.
is_binary: True if
f
the file is binary.
is_binary: True if the file is binary.
status: The status of the file.
status: The status of the file.
"""
"""
...
...
googletest/docs/advanced.md
View file @
47092933
...
@@ -101,14 +101,15 @@ If you already have a function or functor that returns `bool` (or a type that
...
@@ -101,14 +101,15 @@ If you already have a function or functor that returns `bool` (or a type that
can be implicitly converted to
`bool`
), you can use it in a
*
predicate
can be implicitly converted to
`bool`
), you can use it in a
*
predicate
assertion
*
to get the function arguments printed for free:
assertion
*
to get the function arguments printed for free:
<!-- mdformat off(github rendering does not support multiline tables) -->
| Fatal assertion | Nonfatal assertion | Verifies |
| Fatal assertion | Nonfatal assertion | Verifies |
| -------------------- | -------------------- | --------------------------- |
| --------------------------------- | --------------------------------- | --------------------------- |
|
`ASSERT_PRED1(pred1, | `
EXPECT_PRED1(pred1, |
`pred1(val1)`
is true |
|
`ASSERT_PRED1(pred1, val1)`
|
`EXPECT_PRED1(pred1, val1)`
|
`pred1(val1)`
is true |
: val1);
` : val1);`
: :
|
`ASSERT_PRED2(pred2, val1, val2)`
|
`EXPECT_PRED2(pred2, val1, val2)`
|
`pred1(val1, val2)`
is true |
|
`ASSERT_PRED2(pred2, | `
EXPECT_PRED2(pred2, |
`pred2(val1, val2)`
is true |
|
`...`
|
`...`
|
`...`
|
: val1, val2);
` : val1, val2);`
: :
|
`...`
|
`...`
| ... |
<!-- mdformat on-->
In the above,
`predn`
is an
`n`
-ary predicate function or functor, where
`val1`
,
In the above,
`predn`
is an
`n`
-ary predicate function or functor, where
`val1`
,
`val2`
, ..., and
`valn`
are its arguments. The assertion succeeds if the
`val2`
, ..., and
`valn`
are its arguments. The assertion succeeds if the
predicate returns
`true`
when applied to the given arguments, and fails
predicate returns
`true`
when applied to the given arguments, and fails
...
@@ -330,23 +331,26 @@ want to learn more, see
...
@@ -330,23 +331,26 @@ want to learn more, see
#### Floating-Point Macros
#### Floating-Point Macros
<!-- mdformat off(github rendering does not support multiline tables) -->
| Fatal assertion | Nonfatal assertion | Verifies |
| Fatal assertion | Nonfatal assertion | Verifies |
| -----------------------
|
----------------------- | ----------------------- |
| -----------------------
-------- | --------
----------------------- | -----------------------
-----------------
|
|
`ASSERT_FLOAT_EQ(val1, | `
EXPECT_FLOAT_EQ(val1, | the two
`float`
values |
|
`ASSERT_FLOAT_EQ(val1,
val2);`
|
`EXPECT_FLOAT_EQ(val1,
val2);`
| the two
`float`
values
are almost equal
|
: val2);
` : val2);`
:
are almost equal
:
|
`ASSERT_DOUBLE_EQ(val1, val2);`
|
`EXPECT_DOUBLE_EQ(val1, val2);`
| the two
`double`
values
are almost equal
|
|
`ASSERT_DOUBLE_EQ(val1, | `
EXPECT_DOUBLE_EQ(val1, | the two
`double`
values |
: val2);
` : val2);`
: are almost equal :
<!-- mdformat on-->
By "almost equal" we mean the values are within 4 ULP's from each other.
By "almost equal" we mean the values are within 4 ULP's from each other.
The following assertions allow you to choose the acceptable error bound:
The following assertions allow you to choose the acceptable error bound:
<!-- mdformat off(github rendering does not support multiline tables) -->
| Fatal assertion | Nonfatal assertion | Verifies |
| Fatal assertion | Nonfatal assertion | Verifies |
| ------------------ | ------------------------ | ------------------------- |
| ------------------------------------- | ------------------------------------- | -------------------------------------------------------------------------------- |
|
`ASSERT_NEAR(val1, | `
EXPECT_NEAR(val1, val2, | the difference between |
|
`ASSERT_NEAR(val1, val2, abs_error);`
|
`EXPECT_NEAR(val1, val2, abs_error);`
| the difference between
`val1`
and
`val2`
doesn't exceed the given absolute error |
: val2, abs_error);
` : abs_error);`
:
`val1`
and
`val2`
doesn't :
: : : exceed the given absolute :
<!-- mdformat on-->
: : : error :
#### Floating-Point Predicate-Format Functions
#### Floating-Point Predicate-Format Functions
...
@@ -369,10 +373,13 @@ Verifies that `val1` is less than, or almost equal to, `val2`. You can replace
...
@@ -369,10 +373,13 @@ Verifies that `val1` is less than, or almost equal to, `val2`. You can replace
arguments passed to mock objects. A gMock
*matcher*
is basically a predicate
arguments passed to mock objects. A gMock
*matcher*
is basically a predicate
that knows how to describe itself. It can be used in these assertion macros:
that knows how to describe itself. It can be used in these assertion macros:
<!-- mdformat off(github rendering does not support multiline tables) -->
| Fatal assertion | Nonfatal assertion | Verifies |
| Fatal assertion | Nonfatal assertion | Verifies |
| ------------------- | ------------------------------ | --------------------- |
| ------------------------------ | ------------------------------ | --------------------- |
|
`ASSERT_THAT(value, | `
EXPECT_THAT(value, matcher);
` | value matches matcher |
|
`ASSERT_THAT(value, matcher);`
|
`EXPECT_THAT(value, matcher);`
| value matches matcher |
: matcher);`
: : :
<!-- mdformat on-->
For example,
`StartsWith(prefix)`
is a matcher that matches a string starting
For example,
`StartsWith(prefix)`
is a matcher that matches a string starting
with
`prefix`
, and you can write:
with
`prefix`
, and you can write:
...
@@ -1342,19 +1349,17 @@ for generating test parameters. They return what we call (surprise!) *parameter
...
@@ -1342,19 +1349,17 @@ for generating test parameters. They return what we call (surprise!) *parameter
generators
*
. Here is a summary of them, which are all in the
`testing`
generators
*
. Here is a summary of them, which are all in the
`testing`
namespace:
namespace:
<!-- mdformat off(github rendering does not support multiline tables) -->
| Parameter Generator | Behavior |
| Parameter Generator | Behavior |
| ---------------------------- | ------------------------------------------- |
| ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
|
`Range(begin, end [, step])`
| Yields values
`{begin, begin+step, |
|
`Range(begin, end [, step])`
| Yields values
`{begin, begin+step, begin+step+step, ...}`
. The values do not include
`end`
.
`step`
defaults to 1. |
: : begin+step+step, ...}`
. The values do not :
: : include
`end`
.
`step`
defaults to 1. :
|
`Values(v1, v2, ..., vN)`
| Yields values
`{v1, v2, ..., vN}`
. |
|
`Values(v1, v2, ..., vN)`
| Yields values
`{v1, v2, ..., vN}`
. |
|
`ValuesIn(container)`
and | Yields values from a C-style array, an |
|
`ValuesIn(container)`
and
`ValuesIn(begin,end)`
| Yields values from a C-style array, an STL-style container, or an iterator range
`[begin, end)`
|
:
`ValuesIn(begin,end)`
: STL-style container, or an iterator range :
: :
`[begin, end)`
. :
|
`Bool()`
| Yields sequence
`{false, true}`
. |
|
`Bool()`
| Yields sequence
`{false, true}`
. |
|
`Combine(g1, g2, ..., gN)`
| Yields all combinations (Cartesian product)
|
|
`Combine(g1, g2, ..., gN)`
| Yields all combinations (Cartesian product) as std
\:\:
tuples of the values generated by the
`N`
generators.
|
: : as std
\:\:
tuples of the values generated by :
: : the
`N`
generators. :
<!-- mdformat on-->
For more details, see the comments at the definitions of these functions.
For more details, see the comments at the definitions of these functions.
...
...
googletest/scripts/gen_gtest_pred_impl.py
View file @
47092933
...
@@ -540,10 +540,10 @@ class Predicate%(n)sTest : public testing::Test {
...
@@ -540,10 +540,10 @@ class Predicate%(n)sTest : public testing::Test {
}
}
}
}
// true if
f
the test function is expected to run to finish.
// true if the test function is expected to run to finish.
static bool expected_to_finish_;
static bool expected_to_finish_;
// true if
f
the test function did run to finish.
// true if the test function did run to finish.
static bool finished_;
static bool finished_;
"""
%
DEFS
"""
%
DEFS
...
@@ -572,12 +572,12 @@ typedef Predicate%(n)sTest ASSERT_PRED%(n)sTest;
...
@@ -572,12 +572,12 @@ typedef Predicate%(n)sTest ASSERT_PRED%(n)sTest;
"""Returns the test for a predicate assertion macro.
"""Returns the test for a predicate assertion macro.
Args:
Args:
use_format: true if
f
the assertion is a *_PRED_FORMAT*.
use_format: true if the assertion is a *_PRED_FORMAT*.
use_assert: true if
f
the assertion is a ASSERT_*.
use_assert: true if the assertion is a ASSERT_*.
expect_failure: true if
f
the assertion is expected to fail.
expect_failure: true if the assertion is expected to fail.
use_functor: true if
f
the first argument of the assertion is
use_functor: true if the first argument of the assertion is
a functor (as opposed to a function)
a functor (as opposed to a function)
use_user_type: true if
f
the predicate functor/function takes
use_user_type: true if the predicate functor/function takes
argument(s) of a user-defined type.
argument(s) of a user-defined type.
Example:
Example:
...
...
googletest/scripts/pump.py
View file @
47092933
...
@@ -161,7 +161,7 @@ class Token:
...
@@ -161,7 +161,7 @@ class Token:
def
StartsWith
(
lines
,
pos
,
string
):
def
StartsWith
(
lines
,
pos
,
string
):
"""Returns True if
f
the given position in lines starts with 'string'."""
"""Returns True if the given position in lines starts with 'string'."""
return
lines
[
pos
.
line
][
pos
.
column
:].
startswith
(
string
)
return
lines
[
pos
.
line
][
pos
.
column
:].
startswith
(
string
)
...
...
googletest/scripts/upload.py
View file @
47092933
...
@@ -631,7 +631,7 @@ class VersionControlSystem(object):
...
@@ -631,7 +631,7 @@ class VersionControlSystem(object):
new_content: For text files, this is empty. For binary files, this is
new_content: For text files, this is empty. For binary files, this is
the contents of the new file, since the diff output won't contain
the contents of the new file, since the diff output won't contain
information to reconstruct the current file.
information to reconstruct the current file.
is_binary: True if
f
the file is binary.
is_binary: True if the file is binary.
status: The status of the file.
status: The status of the file.
"""
"""
...
...
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