@@ -54,7 +54,7 @@ To make an assertion using a matcher, GoogleTest offers three macros:
54
54
* [ ` assert_that! ` ] panics if the assertion fails, aborting the test.
55
55
* [ ` expect_that! ` ] logs an assertion failure, marking the test as having
56
56
failed, but allows the test to continue running (called a _ non-fatal
57
- assertion_ ). It requires the use of the [ ` googletest::test ` ] attribute macro
57
+ assertion_ ). It requires the use of the [ ` gtest ` ] attribute macro
58
58
on the test itself.
59
59
* [ ` verify_that! ` ] has no side effects and evaluates to a [ ` Result<()> ` ] whose
60
60
` Err ` variant describes the assertion failure, if there is one. In
@@ -74,7 +74,7 @@ fn fails_and_panics() {
74
74
assert_that! (value , eq (4 ));
75
75
}
76
76
77
- #[googletest :: test ]
77
+ #[gtest ]
78
78
fn two_logged_failures () {
79
79
let value = 2 ;
80
80
expect_that! (value , eq (4 )); // Test now failed, but continues executing.
@@ -107,7 +107,7 @@ Matchers are composable:
107
107
``` rust
108
108
use googletest :: prelude :: * ;
109
109
110
- #[googletest :: test ]
110
+ #[gtest ]
111
111
fn contains_at_least_one_item_at_least_3 () {
112
112
let value = vec! [1 , 2 , 3 ];
113
113
expect_that! (value , contains (ge (3 )));
@@ -119,7 +119,7 @@ They can also be logically combined:
119
119
``` rust
120
120
use googletest :: prelude :: * ;
121
121
122
- #[googletest :: test ]
122
+ #[gtest ]
123
123
fn strictly_between_9_and_11 () {
124
124
let value = 10 ;
125
125
expect_that! (value , gt (9 ). and (not (ge (11 ))));
@@ -194,7 +194,7 @@ pub fn eq_my_way<T: PartialEq + Debug>(expected: T) -> impl Matcher<T> {
194
194
The new matcher can then be used in the assertion macros:
195
195
196
196
``` rust
197
- #[googletest :: test ]
197
+ #[gtest ]
198
198
fn should_be_equal_by_my_definition () {
199
199
expect_that! (10 , eq_my_way (10 ));
200
200
}
@@ -209,12 +209,12 @@ failed, but execution continues until the test completes or otherwise aborts.
209
209
This is analogous to the ` EXPECT_* ` family of macros in GoogleTest.
210
210
211
211
To make a non-fatal assertion, use the macro [ ` expect_that! ` ] . The test must
212
- also be marked with [ ` googletest::test ` ] instead of the Rust-standard ` #[test] ` .
212
+ also be marked with [ ` gtest ` ] instead of the Rust-standard ` #[test] ` .
213
213
214
214
``` rust
215
215
use googletest :: prelude :: * ;
216
216
217
- #[googletest :: test ]
217
+ #[gtest ]
218
218
fn three_non_fatal_assertions () {
219
219
let value = 2 ;
220
220
expect_that! (value , eq (2 )); // Passes; test still considered passing.
@@ -229,7 +229,7 @@ function must also return [`Result<()>`]:
229
229
``` rust
230
230
use googletest :: prelude :: * ;
231
231
232
- #[googletest :: test ]
232
+ #[gtest ]
233
233
fn failing_non_fatal_assertion () -> Result <()> {
234
234
let value = 2 ;
235
235
expect_that! (value , eq (3 )); // Just marks the test as having failed.
@@ -242,7 +242,7 @@ fn failing_non_fatal_assertion() -> Result<()> {
242
242
``` rust
243
243
use googletest :: prelude :: * ;
244
244
245
- #[googletest :: test ]
245
+ #[gtest ]
246
246
fn failing_fatal_assertion_after_non_fatal_assertion () -> Result <()> {
247
247
let value = 2 ;
248
248
verify_that! (value , eq (3 ))? ; // Fails and aborts the test.
@@ -253,12 +253,12 @@ fn failing_fatal_assertion_after_non_fatal_assertion() -> Result<()> {
253
253
254
254
### Interoperability
255
255
256
- You can use the ` #[googletest::test ] ` macro together with many other libraries
256
+ You can use the ` #[gtest ] ` macro together with many other libraries
257
257
such as [ rstest] ( https://crates.io/crates/rstest ) . Just apply both attribute
258
258
macros to the test:
259
259
260
260
``` rust
261
- #[googletest :: test ]
261
+ #[gtest ]
262
262
#[rstest]
263
263
#[case(1)]
264
264
#[case(2)]
@@ -268,16 +268,16 @@ fn rstest_works_with_google_test(#[case] value: u32) -> Result<()> {
268
268
}
269
269
```
270
270
271
- Make sure to put ` #[googletest::test ] ` * before* ` #[rstest] ` . Otherwise the
271
+ Make sure to put ` #[gtest ] ` * before* ` #[rstest] ` . Otherwise the
272
272
annotated test will run twice, since both macros will attempt to register a test
273
273
with the Rust test harness.
274
274
275
275
The macro also works together with
276
- [ async tests with Tokio] ( https://docs.rs/tokio/latest/tokio/attr.test .html ) in
276
+ [ async tests with Tokio] ( https://docs.rs/tokio/latest/tokio/attr.gtest .html ) in
277
277
the same way:
278
278
279
279
``` rust
280
- #[googletest :: test ]
280
+ #[gtest ]
281
281
#[tokio:: test]
282
282
async fn should_work_with_tokio () -> Result <()> {
283
283
verify_that! (3 , gt (0 ))
@@ -355,7 +355,7 @@ to this project.
355
355
[ `expect_pred!` ] : https://docs.rs/googletest/*/googletest/macro.expect_pred.html
356
356
[ `expect_that!` ] : https://docs.rs/googletest/*/googletest/macro.expect_that.html
357
357
[ `fail!` ] : https://docs.rs/googletest/*/googletest/macro.fail.html
358
- [ `googletest::test ` ] : https://docs.rs/googletest/*/googletest/attr.test .html
358
+ [ `gtest ` ] : https://docs.rs/googletest/*/googletest/attr.gtest .html
359
359
[ `matches_pattern!` ] : https://docs.rs/googletest/*/googletest/macro.matches_pattern.html
360
360
[ `verify_pred!` ] : https://docs.rs/googletest/*/googletest/macro.verify_pred.html
361
361
[ `verify_that!` ] : https://docs.rs/googletest/*/googletest/macro.verify_that.html
0 commit comments