@@ -484,6 +484,29 @@ pub use verify_true;
484
484
/// println!("This will print");
485
485
/// }
486
486
/// ```
487
+ ///
488
+ /// One may optionally add arguments which will be formatted and appended to a
489
+ /// failure message. For example:
490
+ ///
491
+ /// ```ignore
492
+ /// use googletest::prelude::*;
493
+ ///
494
+ /// #[gtest]
495
+ /// fn should_fail() {
496
+ /// let extra_information = "Some additional information";
497
+ /// expect_true!(false, "Test failed. Extra information: {extra_information}.");
498
+ /// }
499
+ /// ```
500
+ ///
501
+ /// The output is as follows:
502
+ ///
503
+ /// ```text
504
+ /// Value of: false
505
+ /// Expected: is equal to true
506
+ /// Actual: false,
507
+ /// which isn't equal to true
508
+ /// Test failed. Extra information: Some additional information.
509
+ /// ```
487
510
#[ macro_export]
488
511
macro_rules! expect_true {
489
512
( $condition: expr) => { {
@@ -550,6 +573,29 @@ pub use verify_false;
550
573
/// println!("This will print");
551
574
/// }
552
575
/// ```
576
+ ///
577
+ /// One may optionally add arguments which will be formatted and appended to a
578
+ /// failure message. For example:
579
+ ///
580
+ /// ``` ignore
581
+ /// use googletest::prelude::*;
582
+ ///
583
+ /// #[gtest]
584
+ /// fn should_fail() {
585
+ /// let extra_information = "Some additional information";
586
+ /// expect_false!(true, "Test failed. Extra information: {extra_information}.");
587
+ /// }
588
+ /// ```
589
+ ///
590
+ /// The output is as follows:
591
+ ///
592
+ /// ```text
593
+ /// Value of: true
594
+ /// Expected: is equal to false
595
+ /// Actual: true,
596
+ /// which isn't equal to false
597
+ /// Test failed. Extra information: Some additional information.
598
+ /// ```
553
599
#[ macro_export]
554
600
macro_rules! expect_false {
555
601
( $condition: expr) => { {
@@ -1405,6 +1451,25 @@ pub use assert_that;
1405
1451
/// Asserts that the given predicate applied to the given arguments returns
1406
1452
/// true, panicking if it does not.
1407
1453
///
1454
+ /// One may optionally add arguments which will be formatted and appended to a
1455
+ /// failure message. For example:
1456
+ ///
1457
+ /// ```should_panic
1458
+ /// # use googletest::prelude::*;
1459
+ /// # fn should_fail() {
1460
+ /// let extra_information = "Some additional information";
1461
+ /// assert_pred!(1 == 2, "Test failed. Extra information: {extra_information}.");
1462
+ /// # }
1463
+ /// # should_fail();
1464
+ /// ```
1465
+ ///
1466
+ /// The output is as follows:
1467
+ ///
1468
+ /// ```text
1469
+ /// 1 == 2 was false with
1470
+ /// Test failed. Extra information: Some additional information.
1471
+ /// ```
1472
+ ///
1408
1473
/// **Note for users of [GoogleTest for C++](http://google.github.io/googletest/):**
1409
1474
/// This differs from the `ASSERT_PRED*` family of macros in that it panics
1410
1475
/// rather than triggering an early return from the invoking function. To get
@@ -1536,6 +1601,26 @@ pub use expect_that;
1536
1601
/// ```ignore
1537
1602
/// verify_pred!(predicate(...)).and_log_failure()
1538
1603
/// ```
1604
+ ///
1605
+ /// One may optionally add arguments which will be formatted and appended to a
1606
+ /// failure message. For example:
1607
+ ///
1608
+ /// ```ignore
1609
+ /// use googletest::prelude::*;
1610
+ ///
1611
+ /// #[gtest]
1612
+ /// fn should_fail() {
1613
+ /// let extra_information = "Some additional information";
1614
+ /// expect_pred!(1 == 2, "Test failed. Extra information: {extra_information}.");
1615
+ /// }
1616
+ /// ```
1617
+ ///
1618
+ /// The output is as follows:
1619
+ ///
1620
+ /// ```text
1621
+ /// 1 == 2 was false with
1622
+ /// Test failed. Extra information: Some additional information.
1623
+ /// ```
1539
1624
#[ macro_export]
1540
1625
macro_rules! expect_pred {
1541
1626
( $content: expr $( , ) ?) => { {
0 commit comments