summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/primer.md17
1 files changed, 8 insertions, 9 deletions
diff --git a/docs/primer.md b/docs/primer.md
index 0f90c03..61806be 100644
--- a/docs/primer.md
+++ b/docs/primer.md
@@ -273,14 +273,14 @@ First, define a fixture class. By convention, you should give it the name
```c++
class QueueTest : public testing::Test {
protected:
- void SetUp() override {
+ QueueTest() {
// q0_ remains empty
q1_.Enqueue(1);
q2_.Enqueue(2);
q2_.Enqueue(3);
}
- // void TearDown() override {}
+ // ~QueueTest() override = default;
Queue<int> q0_;
Queue<int> q1_;
@@ -288,8 +288,9 @@ class QueueTest : public testing::Test {
};
```
-In this case, `TearDown()` is not needed since we don't have to clean up after
-each test, other than what's already done by the destructor.
+In this case, we don't need to define a destructor or a `TearDown()` method,
+because the implicit destructor generated by the compiler will perform all of
+the necessary cleanup.
Now we'll write tests using `TEST_F()` and this fixture.
@@ -326,11 +327,9 @@ would lead to a segfault when `n` is `NULL`.
When these tests run, the following happens:
1. GoogleTest constructs a `QueueTest` object (let's call it `t1`).
-2. `t1.SetUp()` initializes `t1`.
-3. The first test (`IsEmptyInitially`) runs on `t1`.
-4. `t1.TearDown()` cleans up after the test finishes.
-5. `t1` is destructed.
-6. The above steps are repeated on another `QueueTest` object, this time
+2. The first test (`IsEmptyInitially`) runs on `t1`.
+3. `t1` is destructed.
+4. The above steps are repeated on another `QueueTest` object, this time
running the `DequeueWorks` test.
**Availability**: Linux, Windows, Mac.