@@ -524,6 +524,66 @@ macro_rules! expect_true {
524524}
525525pub use expect_true;
526526
527+ /// Marks the test as failed and panics if the given value is `false`.
528+ ///
529+ /// This is a *fatal* assertion: the test panics
530+ /// in the event of assertion failure.
531+ ///
532+ /// This can only be invoked inside tests with the
533+ /// [`gtest`][crate::gtest] attribute. The assertion must
534+ /// occur in the same thread as that running the test itself.
535+ ///
536+ /// Example:
537+ ///
538+ /// ```ignore
539+ /// use googletest::prelude::*;
540+ ///
541+ /// #[gtest]
542+ /// fn should_fail() {
543+ /// assert_true!(false); // panic!
544+ /// }
545+ /// ```
546+ ///
547+ /// One may optionally add arguments which will be formatted and appended to a
548+ /// failure message. For example:
549+ ///
550+ /// ```ignore
551+ /// use googletest::prelude::*;
552+ ///
553+ /// #[gtest]
554+ /// fn should_fail() {
555+ /// let extra_information = "Some additional information";
556+ /// assert_true!(false, "Test failed. Extra information: {extra_information}.");
557+ /// }
558+ /// ```
559+ ///
560+ /// The output is as follows:
561+ ///
562+ /// ```text
563+ /// Value of: false
564+ /// Expected: is equal to true
565+ /// Actual: false,
566+ /// which isn't equal to true
567+ /// Test failed. Extra information: Some additional information.
568+ /// ```
569+ #[ macro_export]
570+ macro_rules! assert_true {
571+ ( $condition: expr) => {
572+ if let Err ( e) = $crate:: verify_true!( $condition) {
573+ panic!( "\n {}" , e) ;
574+ }
575+ } ;
576+ ( $condition: expr, $( $format_args: expr) ,* $( , ) ?) => {
577+ if let Err ( e) = $crate:: GoogleTestSupport :: with_failure_message(
578+ $crate:: verify_true!( $condition) ,
579+ || format!( $( $format_args) ,* ) )
580+ {
581+ panic!( "\n {}" , e) ;
582+ }
583+ } ;
584+ }
585+ pub use assert_true;
586+
527587/// Verify if the condition evaluates to false and returns `Result`.
528588///
529589/// Evaluates to `Result::Ok(())` if the condition is false and
@@ -613,6 +673,65 @@ macro_rules! expect_false {
613673}
614674pub use expect_false;
615675
676+ /// Marks the test as failed and panics if the given value is `true`.
677+ ///
678+ /// This is a *fatal* assertion: the test panics
679+ /// in the event of assertion failure.
680+ ///
681+ /// This can only be invoked inside tests with the
682+ /// [`gtest`][crate::gtest] attribute. The assertion must
683+ /// occur in the same thread as that running the test itself.
684+ ///
685+ /// Example:
686+ /// ```ignore
687+ /// use googletest::prelude::*;
688+ ///
689+ /// #[gtest]
690+ /// fn should_fail() {
691+ /// assert_false!(true); // panic!
692+ /// }
693+ /// ```
694+ ///
695+ /// One may optionally add arguments which will be formatted and appended to a
696+ /// failure message. For example:
697+ ///
698+ /// ``` ignore
699+ /// use googletest::prelude::*;
700+ ///
701+ /// #[gtest]
702+ /// fn should_fail() {
703+ /// let extra_information = "Some additional information";
704+ /// assert_false!(true, "Test failed. Extra information: {extra_information}.");
705+ /// }
706+ /// ```
707+ ///
708+ /// The output is as follows:
709+ ///
710+ /// ```text
711+ /// Value of: true
712+ /// Expected: is equal to false
713+ /// Actual: true,
714+ /// which isn't equal to false
715+ /// Test failed. Extra information: Some additional information.
716+ /// ```
717+ #[ macro_export]
718+ macro_rules! assert_false {
719+ ( $condition: expr) => {
720+ if let Err ( e) = $crate:: verify_false!( $condition) {
721+ panic!( "\n {}" , e) ;
722+ }
723+ } ;
724+ ( $condition: expr, $( $format_args: expr) ,* $( , ) ?) => {
725+ if let Err ( e) = $crate:: GoogleTestSupport :: with_failure_message(
726+ $crate:: verify_false!( $condition) ,
727+ || format!( $( $format_args) ,* ) )
728+ {
729+ panic!( "\n {}" , e) ;
730+ }
731+ } ;
732+ }
733+ pub use assert_false;
734+
616735/// Checks whether the second argument is equal to the first argument.
617736///
618737/// Evaluates to `Result::Ok(())` if they are equal and
0 commit comments