Skip to content

Commit 18abece

Browse files
satylogincopybara-github
authored andcommitted
Remove the assert_ versions for macros since the preference if for using
`verify_` and `expect_` PiperOrigin-RevId: 651889994
1 parent a524db9 commit 18abece

13 files changed

+4
-561
lines changed

googletest/src/assertions.rs

Lines changed: 0 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -449,31 +449,6 @@ macro_rules! verify_true {
449449
}};
450450
}
451451

452-
/// Assert if the condition evaluates to true and panics if false.
453-
///
454-
/// This is the same as calling `and_log_failure` on [`verify_true`] macro
455-
/// Result.
456-
///
457-
/// This can only be invoked inside tests with the
458-
/// [`googletest::test`][crate::test] attribute. The failure must be generated
459-
/// in the same thread as that running the test itself.
460-
///
461-
/// Example:
462-
/// ```ignore
463-
/// use googletest::prelude::*;
464-
///
465-
/// #[googletest::test]
466-
/// fn should_fail() {
467-
/// assert_true!(2 + 2 == 5);
468-
/// }
469-
/// ```
470-
#[macro_export]
471-
macro_rules! assert_true {
472-
($condition:expr) => {
473-
verify_true!($condition).and_log_failure()
474-
};
475-
}
476-
477452
/// Marks test as failed and continue execution if the expression evaluates to
478453
/// false.
479454
///
@@ -534,31 +509,6 @@ macro_rules! verify_false {
534509
}};
535510
}
536511

537-
/// Assert if the condition evaluates to false and panics if true.
538-
///
539-
/// This is the same as calling `and_log_failure` on [`verify_false`] macro
540-
/// Result.
541-
///
542-
/// This can only be invoked inside tests with the
543-
/// [`googletest::test`][crate::test] attribute. The failure must be generated
544-
/// in the same thread as that running the test itself.
545-
///
546-
/// Example:
547-
/// ```ignore
548-
/// use googletest::prelude::*;
549-
///
550-
/// #[googletest::test]
551-
/// fn should_fail() {
552-
/// assert_false!(2 + 2 == 4);
553-
/// }
554-
/// ```
555-
#[macro_export]
556-
macro_rules! assert_false {
557-
($condition:expr) => {
558-
verify_false!($condition).and_log_failure()
559-
};
560-
}
561-
562512
/// Marks test as failed and continue execution if the expression evaluates to
563513
/// true.
564514
///
@@ -631,68 +581,6 @@ macro_rules! verify_eq {
631581
};
632582
}
633583

634-
/// Panics if the second argument is not equal to first argument.
635-
///
636-
/// This is the same as calling `and_log_failure` on [`verify_eq`] macro Result.
637-
///
638-
/// This can only be invoked inside tests with the
639-
/// [`googletest::test`][crate::test] attribute. The failure must be generated
640-
/// in the same thread as that running the test itself.
641-
///
642-
/// Example:
643-
/// ```ignore
644-
/// use googletest;
645-
///
646-
/// #[googletest::test]
647-
/// fn should_fail() {
648-
/// googletest::assert_eq!(2, 1);
649-
/// }
650-
/// ```
651-
///
652-
/// This macro has special support for matching against container. Namely:
653-
/// * `assert_eq!(actual, [e1, e2, ...])` for checking actual contains "e1, e2,
654-
/// ..." in order.
655-
/// * `assert_eq!(actual, {e1, e2, ...})` for checking actual contains "e1, e2,
656-
/// ..." in any order.
657-
///
658-
/// One may include formatted arguments in the failure message:
659-
///```ignore
660-
/// use googletest;
661-
///
662-
/// #[googletest::test]
663-
/// fn should_fail() {
664-
/// let argument = "argument"
665-
/// googletest::assert_eq!(2, 1, "custom failure message: {argument}");
666-
/// }
667-
/// ```
668-
#[macro_export]
669-
macro_rules! assert_eq {
670-
($actual:expr, [$($expected:expr),+ $(,)?] $(,)?) => {
671-
verify_eq!($actual, [$($expected),*]).and_log_failure();
672-
};
673-
($actual:expr, [$($expected:expr),+ $(,)?], $($format_args:expr),* $(,)?) => {
674-
verify_eq!($actual, [$($expected),*])
675-
.with_failure_message(|| format!($($format_args),*))
676-
.and_log_failure();
677-
};
678-
($actual:expr, {$($expected:expr),+ $(,)?} $(,)?) => {
679-
verify_eq!($actual, {$($expected),*}).and_log_failure();
680-
};
681-
($actual:expr, {$($expected:expr),+ $(,)?}, $($format_args:expr),* $(,)?) => {
682-
verify_eq!($actual, {$($expected),*})
683-
.with_failure_message(|| format!($($format_args),*))
684-
.and_log_failure();
685-
};
686-
($actual:expr, $expected:expr $(,)?) => {
687-
verify_eq!($actual, $expected).and_log_failure();
688-
};
689-
($actual:expr, $expected:expr, $($format_args:expr),* $(,)?) => {
690-
verify_eq!($actual, $expected)
691-
.with_failure_message(|| format!($($format_args),*))
692-
.and_log_failure();
693-
};
694-
}
695-
696584
/// Marks test as failed and continues execution if the second argument is not
697585
/// equal to first argument.
698586
///

googletest/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ pub mod prelude {
5050
pub use super::Result;
5151
// Assert macros
5252
pub use super::{
53-
add_failure, add_failure_at, assert_false, assert_that, assert_true, expect_eq,
54-
expect_false, expect_ge, expect_gt, expect_le, expect_lt, expect_ne, expect_pred,
55-
expect_that, expect_true, fail, succeed, verify_eq, verify_false, verify_ge, verify_gt,
56-
verify_le, verify_lt, verify_ne, verify_pred, verify_that, verify_true,
53+
add_failure, add_failure_at, assert_that, expect_eq, expect_false, expect_ge, expect_gt,
54+
expect_le, expect_lt, expect_ne, expect_pred, expect_that, expect_true, fail, succeed,
55+
verify_eq, verify_false, verify_ge, verify_gt, verify_le, verify_lt, verify_ne,
56+
verify_pred, verify_that, verify_true,
5757
};
5858
}
5959

integration_tests/Cargo.toml

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,6 @@ name = "verify_true_macro_on_false_condition"
150150
path = "src/verify_true_macro_on_false_condition.rs"
151151
test = false
152152

153-
[[bin]]
154-
name = "assert_true_macro_on_false_condition_panics"
155-
path = "src/assert_true_macro_on_false_condition_panics.rs"
156-
test = false
157-
158153
[[bin]]
159154
name = "expect_true_macro_on_false_condition_fails_test_and_continues"
160155
path = "src/expect_true_macro_on_false_condition_fails_test_and_continues.rs"
@@ -165,11 +160,6 @@ name = "verify_false_macro_on_true_condition"
165160
path = "src/verify_false_macro_on_true_condition.rs"
166161
test = false
167162

168-
[[bin]]
169-
name = "assert_false_macro_on_true_condition_panics"
170-
path = "src/assert_false_macro_on_true_condition_panics.rs"
171-
test = false
172-
173163
[[bin]]
174164
name = "expect_false_macro_on_true_condition_fails_test_and_continues"
175165
path = "src/expect_false_macro_on_true_condition_fails_test_and_continues.rs"
@@ -190,36 +180,6 @@ name = "verify_eq_with_unordered_elements_when_not_equal_returns_error"
190180
path = "src/verify_eq_with_unordered_elements_when_not_equal_returns_error.rs"
191181
test = false
192182

193-
[[bin]]
194-
name = "assert_eq_when_not_equal_returns_error"
195-
path = "src/assert_eq_when_not_equal_returns_error.rs"
196-
test = false
197-
198-
[[bin]]
199-
name = "assert_eq_supports_custom_message"
200-
path = "src/assert_eq_supports_custom_message.rs"
201-
test = false
202-
203-
[[bin]]
204-
name = "assert_eq_with_ordered_elements_when_not_equal_returns_error"
205-
path = "src/assert_eq_with_ordered_elements_when_not_equal_returns_error.rs"
206-
test = false
207-
208-
[[bin]]
209-
name = "assert_eq_with_ordered_elements_supports_custom_message"
210-
path = "src/assert_eq_with_ordered_elements_supports_custom_message.rs"
211-
test = false
212-
213-
[[bin]]
214-
name = "assert_eq_with_unordered_elements_when_not_equal_returns_error"
215-
path = "src/assert_eq_with_unordered_elements_when_not_equal_returns_error.rs"
216-
test = false
217-
218-
[[bin]]
219-
name = "assert_eq_with_unordered_elements_supports_custom_message"
220-
path = "src/assert_eq_with_unordered_elements_supports_custom_message.rs"
221-
test = false
222-
223183
[[bin]]
224184
name = "expect_eq_when_not_equal_returns_error"
225185
path = "src/expect_eq_when_not_equal_returns_error.rs"

integration_tests/src/assert_eq_supports_custom_message.rs

Lines changed: 0 additions & 26 deletions
This file was deleted.

integration_tests/src/assert_eq_when_not_equal_returns_error.rs

Lines changed: 0 additions & 25 deletions
This file was deleted.

integration_tests/src/assert_eq_with_ordered_elements_supports_custom_message.rs

Lines changed: 0 additions & 26 deletions
This file was deleted.

integration_tests/src/assert_eq_with_ordered_elements_when_not_equal_returns_error.rs

Lines changed: 0 additions & 25 deletions
This file was deleted.

integration_tests/src/assert_eq_with_unordered_elements_supports_custom_message.rs

Lines changed: 0 additions & 26 deletions
This file was deleted.

integration_tests/src/assert_eq_with_unordered_elements_when_not_equal_returns_error.rs

Lines changed: 0 additions & 25 deletions
This file was deleted.

integration_tests/src/assert_false_macro_on_true_condition_panics.rs

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)