summaryrefslogtreecommitdiffstats
path: root/vendor/always-assert/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /vendor/always-assert/tests
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/always-assert/tests')
-rw-r--r--vendor/always-assert/tests/it.rs79
1 files changed, 79 insertions, 0 deletions
diff --git a/vendor/always-assert/tests/it.rs b/vendor/always-assert/tests/it.rs
new file mode 100644
index 000000000..18855787d
--- /dev/null
+++ b/vendor/always-assert/tests/it.rs
@@ -0,0 +1,79 @@
+#[cfg(any(debug_assertions, feature = "force"))]
+mod armed {
+ use always_assert::{always, never};
+
+ #[test]
+ #[should_panic = "assertion failed: 2 + 2 == 5"]
+ fn syntax1() {
+ let _: bool = always!(2 + 2 == 5);
+ }
+
+ #[test]
+ #[should_panic = "custom"]
+ fn syntax2() {
+ let _: bool = always!(2 + 2 == 5, "custom");
+ }
+
+ #[test]
+ #[should_panic = "custom 92"]
+ fn syntax3() {
+ let _: bool = always!(2 + 2 == 5, "custom {}", 92);
+ }
+
+ #[test]
+ #[should_panic = "assertion failed: !(2 + 2 == 4)"]
+ fn syntax4() {
+ let _: bool = never!(2 + 2 == 4);
+ }
+
+ #[test]
+ #[should_panic = "custom"]
+ fn syntax5() {
+ let _: bool = never!(2 + 2 == 4, "custom");
+ }
+
+ #[test]
+ #[should_panic = "custom 92"]
+ fn syntax6() {
+ let _: bool = never!(2 + 2 == 4, "custom {}", 92);
+ }
+
+ #[test]
+ #[should_panic = "unreachable code"]
+ fn syntax7() {
+ let () = never!();
+ }
+
+ #[test]
+ #[should_panic = "custom"]
+ fn syntax8() {
+ let () = never!("custom");
+ }
+
+ #[test]
+ #[should_panic = "custom"]
+ fn syntax9() {
+ let () = never!("custom");
+ }
+
+ #[test]
+ #[should_panic = "custom 92"]
+ fn syntax10() {
+ let () = never!("custom {}", 92);
+ }
+}
+
+#[cfg(all(not(debug_assertions), not(feature = "force")))]
+mod disarmed {
+ use always_assert::{always, never};
+
+ #[test]
+ fn syntax1() {
+ assert!(!always!(false));
+ }
+
+ #[test]
+ fn syntax2() {
+ assert!(never!(true));
+ }
+}