@@ -334,7 +334,7 @@ macro_rules! succeed {
334
334
///
335
335
/// This can only be invoked inside tests with the
336
336
/// [`googletest::test`][crate::test] attribute. The failure must be generated
337
- /// in the same thread as that running the thread itself.
337
+ /// in the same thread as that running the test itself.
338
338
///
339
339
/// ```ignore
340
340
/// use googletest::prelude::*;
@@ -377,7 +377,7 @@ macro_rules! add_failure {
377
377
///
378
378
/// This can only be invoked inside tests with the
379
379
/// [`googletest::test`][crate::test] attribute. The failure must be generated
380
- /// in the same thread as that running the thread itself.
380
+ /// in the same thread as that running the test itself.
381
381
///
382
382
/// ```ignore
383
383
/// use googletest::prelude::*;
@@ -456,7 +456,7 @@ macro_rules! verify_true {
456
456
///
457
457
/// This can only be invoked inside tests with the
458
458
/// [`googletest::test`][crate::test] attribute. The failure must be generated
459
- /// in the same thread as that running the thread itself.
459
+ /// in the same thread as that running the test itself.
460
460
///
461
461
/// Example:
462
462
/// ```ignore
@@ -482,7 +482,7 @@ macro_rules! assert_true {
482
482
///
483
483
/// This can only be invoked inside tests with the
484
484
/// [`googletest::test`][crate::test] attribute. The failure must be generated
485
- /// in the same thread as that running the thread itself.
485
+ /// in the same thread as that running the test itself.
486
486
///
487
487
/// Example:
488
488
/// ```ignore
@@ -541,7 +541,7 @@ macro_rules! verify_false {
541
541
///
542
542
/// This can only be invoked inside tests with the
543
543
/// [`googletest::test`][crate::test] attribute. The failure must be generated
544
- /// in the same thread as that running the thread itself.
544
+ /// in the same thread as that running the test itself.
545
545
///
546
546
/// Example:
547
547
/// ```ignore
@@ -567,7 +567,7 @@ macro_rules! assert_false {
567
567
///
568
568
/// This can only be invoked inside tests with the
569
569
/// [`googletest::test`][crate::test] attribute. The failure must be generated
570
- /// in the same thread as that running the thread itself.
570
+ /// in the same thread as that running the test itself.
571
571
///
572
572
/// Example:
573
573
/// ```ignore
@@ -637,7 +637,7 @@ macro_rules! verify_eq {
637
637
///
638
638
/// This can only be invoked inside tests with the
639
639
/// [`googletest::test`][crate::test] attribute. The failure must be generated
640
- /// in the same thread as that running the thread itself.
640
+ /// in the same thread as that running the test itself.
641
641
///
642
642
/// Example:
643
643
/// ```ignore
@@ -701,7 +701,7 @@ macro_rules! assert_eq {
701
701
///
702
702
/// This can only be invoked inside tests with the
703
703
/// [`googletest::test`][crate::test] attribute. The failure must be generated
704
- /// in the same thread as that running the thread itself.
704
+ /// in the same thread as that running the test itself.
705
705
///
706
706
/// Example:
707
707
/// ```ignore
@@ -805,7 +805,7 @@ macro_rules! verify_ne {
805
805
///
806
806
/// This can only be invoked inside tests with the
807
807
/// [`googletest::test`][crate::test] attribute. The failure must be generated
808
- /// in the same thread as that running the thread itself.
808
+ /// in the same thread as that running the test itself.
809
809
///
810
810
/// Example:
811
811
/// ```ignore
@@ -883,7 +883,7 @@ macro_rules! verify_lt {
883
883
///
884
884
/// This can only be invoked inside tests with the
885
885
/// [`googletest::test`][crate::test] attribute. The failure must be generated
886
- /// in the same thread as that running the thread itself.
886
+ /// in the same thread as that running the test itself.
887
887
///
888
888
/// Example:
889
889
/// ```ignore
@@ -921,6 +921,85 @@ macro_rules! expect_lt {
921
921
} ;
922
922
}
923
923
924
+ /// Checks whether the first argument is less than or equal to the second
925
+ /// argument.
926
+ ///
927
+ /// Evaluates to `Result::Ok(())` if the first argument is less than or equal to
928
+ /// the second and `Result::Err(TestAssertionFailure)` if it is greater. The
929
+ /// caller must then decide how to handle the `Err` variant. It has a few
930
+ /// options:
931
+ /// * Abort the current function with the `?` operator. This requires that the
932
+ /// function return a suitable `Result`.
933
+ /// * Log the test failure and continue by calling the method
934
+ /// `and_log_failure`.
935
+ ///
936
+ /// Of course, one can also use all other standard methods on `Result`.
937
+ ///
938
+ /// **Invoking this macro by itself does not cause a test failure to be recorded
939
+ /// or output.** The resulting `Result` must be handled as described above to
940
+ /// cause the test to be recorded as a failure.
941
+ ///
942
+ /// Example:
943
+ /// ```ignore
944
+ /// use googletest::prelude::*;
945
+ ///
946
+ /// #[test]
947
+ /// fn should_fail() -> Result<()> {
948
+ /// verify_le!(2, 1)
949
+ /// }
950
+ #[ macro_export]
951
+ macro_rules! verify_le {
952
+ ( $actual: expr, $expected: expr $( , ) ?) => {
953
+ verify_that!( $actual, $crate:: matchers:: le( $expected) )
954
+ } ;
955
+ }
956
+
957
+ /// Marks test as failed and continues execution if the first argument is
958
+ /// greater than the second argument.
959
+ ///
960
+ /// This is a **not-fatal** failure. The test continues execution even after the
961
+ /// macro execution.
962
+ ///
963
+ /// This can only be invoked inside tests with the
964
+ /// [`googletest::test`][crate::test] attribute. The failure must be generated
965
+ /// in the same thread as that running the test itself.
966
+ ///
967
+ /// Example:
968
+ /// ```ignore
969
+ /// use googletest::prelude::*;
970
+ ///
971
+ /// #[googletest::test]
972
+ /// fn should_fail() {
973
+ /// expect_le!(2, 1);
974
+ /// println!("This will print!");
975
+ /// }
976
+ /// ```
977
+ ///
978
+ /// One may include formatted arguments in the failure message:
979
+ ///```ignore
980
+ /// use googletest::prelude::*;
981
+ ///
982
+ /// #[googletest::test]
983
+ /// fn should_fail() {
984
+ /// let argument = "argument"
985
+ /// expect_le!(2, 1, "custom failure message: {argument}");
986
+ /// println!("This will print!");
987
+ /// }
988
+ /// ```
989
+ #[ macro_export]
990
+ macro_rules! expect_le {
991
+ ( $actual: expr, $expected: expr, $( $format_args: expr) ,+ $( , ) ?) => {
992
+ use $crate:: GoogleTestSupport ;
993
+ verify_le!( $actual, $expected)
994
+ . with_failure_message( || format!( $( $format_args) ,* ) )
995
+ . and_log_failure( ) ;
996
+ } ;
997
+ ( $actual: expr, $expected: expr $( , ) ?) => {
998
+ use $crate:: GoogleTestSupport ;
999
+ verify_le!( $actual, $expected) . and_log_failure( ) ;
1000
+ } ;
1001
+ }
1002
+
924
1003
/// Matches the given value against the given matcher, panicking if it does not
925
1004
/// match.
926
1005
///
0 commit comments