diff options
author | Gennadiy Civil <misterg@google.com> | 2019-06-24 17:52:17 (GMT) |
---|---|---|
committer | Gennadiy Civil <misterg@google.com> | 2019-06-24 17:52:17 (GMT) |
commit | 437e1008c97b6bf595fec85da42c6925babd96b2 (patch) | |
tree | a3c21753bf440ceeb63ef0907be5d0beacc4bff2 /googletest/docs/advanced.md | |
parent | 834dff3b5279164c65f13cc712ed79dbb5c66950 (diff) | |
download | googletest-437e1008c97b6bf595fec85da42c6925babd96b2.zip googletest-437e1008c97b6bf595fec85da42c6925babd96b2.tar.gz googletest-437e1008c97b6bf595fec85da42c6925babd96b2.tar.bz2 |
Documentation sync in preparation to including docs with full source sync
Diffstat (limited to 'googletest/docs/advanced.md')
-rw-r--r-- | googletest/docs/advanced.md | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/googletest/docs/advanced.md b/googletest/docs/advanced.md index 6a01379..603777c 100644 --- a/googletest/docs/advanced.md +++ b/googletest/docs/advanced.md @@ -1,13 +1,14 @@ # Advanced googletest Topics +<!-- GOOGLETEST_CM0015 DO NOT DELETE --> ## Introduction -Now that you have read the [googletest Primer](primer.md) and learned how to write -tests using googletest, it's time to learn some new tricks. This document will -show you more assertions as well as how to construct complex failure messages, -propagate fatal failures, reuse and speed up your test fixtures, and use various -flags with your tests. +Now that you have read the [googletest Primer](primer.md) and learned how to +write tests using googletest, it's time to learn some new tricks. This document +will show you more assertions as well as how to construct complex failure +messages, propagate fatal failures, reuse and speed up your test fixtures, and +use various flags with your tests. ## More Assertions @@ -103,11 +104,13 @@ 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 assertion* to get the function arguments printed for free: -| Fatal assertion | Nonfatal assertion | Verifies | -| ---------------------------------- | ---------------------------------- | --------------------------- | -| `ASSERT_PRED1(pred1, val1);` | `EXPECT_PRED1(pred1, val1);` | `pred1(val1)` is true | -| `ASSERT_PRED2(pred2, val1, val2);` | `EXPECT_PRED2(pred2, val1, val2);` | `pred2(val1, val2)` is true | -| `...` | `...` | ... | +| Fatal assertion | Nonfatal assertion | Verifies | +| -------------------- | -------------------- | --------------------------- | +| `ASSERT_PRED1(pred1, | `EXPECT_PRED1(pred1, | `pred1(val1)` is true | +: val1);` : val1);` : : +| `ASSERT_PRED2(pred2, | `EXPECT_PRED2(pred2, | `pred2(val1, val2)` is true | +: val1, val2);` : val1, val2);` : : +| `...` | `...` | ... | 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 @@ -337,22 +340,23 @@ want to learn more, see #### Floating-Point Macros -| Fatal assertion | Nonfatal assertion | Verifies | -| ------------------------------- | ------------------------------ | ---------------------------------------- | -| `ASSERT_FLOAT_EQ(val1, val2);` | `EXPECT_FLOAT_EQ(val1,val2);` | the two `float` values are almost equal | -| `ASSERT_DOUBLE_EQ(val1, val2);` | `EXPECT_DOUBLE_EQ(val1, val2);`| the two `double` values are almost equal | +| Fatal assertion | Nonfatal assertion | Verifies | +| ----------------------- | ----------------------- | ----------------------- | +| `ASSERT_FLOAT_EQ(val1, | `EXPECT_FLOAT_EQ(val1, | the two `float` values | +: val2);` : val2);` : are almost equal : +| `ASSERT_DOUBLE_EQ(val1, | `EXPECT_DOUBLE_EQ(val1, | the two `double` values | +: val2);` : val2);` : are almost equal : By "almost equal" we mean the values are within 4 ULP's from each other. -NOTE: `CHECK_DOUBLE_EQ()` in `base/logging.h` uses a fixed absolute error bound, -so its result may differ from that of the googletest macros. That macro is -unsafe and has been deprecated. Please don't use it any more. - The following assertions allow you to choose the acceptable error bound: -| Fatal assertion | Nonfatal assertion | Verifies | -| ------------------------------------- | ------------------------------------- | ------------------------- | -| `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 | +| Fatal assertion | Nonfatal assertion | Verifies | +| ------------------ | ------------------------ | ------------------------- | +| `ASSERT_NEAR(val1, | `EXPECT_NEAR(val1, val2, | the difference between | +: val2, abs_error);` : abs_error);` : `val1` and `val2` doesn't : +: : : exceed the given absolute : +: : : error : **Availability**: Linux, Windows, Mac. |