|
44 | 44 | /// # .unwrap();
|
45 | 45 | /// ```
|
46 | 46 | ///
|
47 |
| -/// It is not required to include all named fields in the specification. Omitted |
48 |
| -/// fields have no effect on the output of the matcher. |
| 47 | +/// If any fields are provided in the pattern, then all fields must be |
| 48 | +/// specified, or the pattern must end with `..`, just like regular match |
| 49 | +/// patterns. Omitted fields have no effect on the output of the matcher. |
49 | 50 | ///
|
50 | 51 | /// ```
|
51 | 52 | /// # use googletest::prelude::*;
|
|
61 | 62 | /// # };
|
62 | 63 | /// verify_that!(my_struct, matches_pattern!(MyStruct {
|
63 | 64 | /// a_field: starts_with("Something"),
|
64 |
| -/// // another_field is missing, so it may be anything. |
| 65 | +/// .. // another_field is missing, so it may be anything. |
65 | 66 | /// }))
|
66 | 67 | /// # .unwrap();
|
67 | 68 | /// ```
|
@@ -367,3 +368,34 @@ pub mod internal {
|
367 | 368 | }
|
368 | 369 | }
|
369 | 370 | }
|
| 371 | + |
| 372 | +mod compile_fail_tests { |
| 373 | + /// ```compile_fail |
| 374 | + /// use ::googletest::prelude::*; |
| 375 | + /// #[derive(Debug)] |
| 376 | + /// struct Foo { a: u32, b: u32 } |
| 377 | + /// let actual = Foo { a: 1, b: 2 }; |
| 378 | + /// verify_that!(actual, matches_pattern!(Foo { a: eq(&1), .., })); |
| 379 | + /// ``` |
| 380 | + fn _dot_dot_supported_only_at_end_of_struct_pattern() {} |
| 381 | + |
| 382 | + /// ```compile_fail |
| 383 | + /// use ::googletest::prelude::*; |
| 384 | + /// #[derive(Debug)] |
| 385 | + /// struct Foo { a: u32, b: u32 } |
| 386 | + /// let actual = Foo { a: 1, b: 2 }; |
| 387 | + /// verify_that!(actual, matches_pattern!(Foo { a: eq(&1) })); |
| 388 | + /// ``` |
| 389 | + fn _unexhaustive_struct_field_check_requires_dot_dot() {} |
| 390 | + |
| 391 | + /// ```compile_fail |
| 392 | + /// use ::googletest::prelude::*; |
| 393 | + /// #[derive(Debug)] |
| 394 | + /// struct Foo { |
| 395 | + /// Bar { a: u32, b: u32 } |
| 396 | + /// } |
| 397 | + /// let actual = Foo::Bar { a: 1, b: 2 }; |
| 398 | + /// verify_that!(actual, matches_pattern!(Foo::Bar { a: eq(&1) })); |
| 399 | + /// ``` |
| 400 | + fn _unexhaustive_enum_struct_field_check_requires_dot_dot() {} |
| 401 | +} |
0 commit comments