summaryrefslogtreecommitdiffstats
path: root/third_party/rust/bitflags/src/tests/all.rs
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust/bitflags/src/tests/all.rs')
-rw-r--r--third_party/rust/bitflags/src/tests/all.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/third_party/rust/bitflags/src/tests/all.rs b/third_party/rust/bitflags/src/tests/all.rs
new file mode 100644
index 0000000000..cceb93a469
--- /dev/null
+++ b/third_party/rust/bitflags/src/tests/all.rs
@@ -0,0 +1,23 @@
+use super::*;
+
+use crate::Flags;
+
+#[test]
+fn cases() {
+ case(1 | 1 << 1 | 1 << 2, TestFlags::all);
+
+ case(0, TestZero::all);
+
+ case(0, TestEmpty::all);
+
+ case(!0, TestExternal::all);
+}
+
+#[track_caller]
+fn case<T: Flags>(expected: T::Bits, inherent: impl FnOnce() -> T)
+where
+ <T as Flags>::Bits: std::fmt::Debug + PartialEq,
+{
+ assert_eq!(expected, inherent().bits(), "T::all()");
+ assert_eq!(expected, T::all().bits(), "Flags::all()");
+}