Vendor things
This commit is contained in:
parent
5deceec006
commit
977e3c17e5
19434 changed files with 10682014 additions and 0 deletions
91
third-party/vendor/bitflags/src/tests/intersects.rs
vendored
Normal file
91
third-party/vendor/bitflags/src/tests/intersects.rs
vendored
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
use super::*;
|
||||
|
||||
use crate::Flags;
|
||||
|
||||
#[test]
|
||||
fn cases() {
|
||||
case(
|
||||
TestFlags::empty(),
|
||||
&[
|
||||
(TestFlags::empty(), false),
|
||||
(TestFlags::A, false),
|
||||
(TestFlags::B, false),
|
||||
(TestFlags::C, false),
|
||||
(TestFlags::from_bits_retain(1 << 3), false),
|
||||
],
|
||||
TestFlags::intersects,
|
||||
);
|
||||
|
||||
case(
|
||||
TestFlags::A,
|
||||
&[
|
||||
(TestFlags::empty(), false),
|
||||
(TestFlags::A, true),
|
||||
(TestFlags::B, false),
|
||||
(TestFlags::C, false),
|
||||
(TestFlags::ABC, true),
|
||||
(TestFlags::from_bits_retain(1 << 3), false),
|
||||
(TestFlags::from_bits_retain(1 | (1 << 3)), true),
|
||||
],
|
||||
TestFlags::intersects,
|
||||
);
|
||||
|
||||
case(
|
||||
TestFlags::ABC,
|
||||
&[
|
||||
(TestFlags::empty(), false),
|
||||
(TestFlags::A, true),
|
||||
(TestFlags::B, true),
|
||||
(TestFlags::C, true),
|
||||
(TestFlags::ABC, true),
|
||||
(TestFlags::from_bits_retain(1 << 3), false),
|
||||
],
|
||||
TestFlags::intersects,
|
||||
);
|
||||
|
||||
case(
|
||||
TestFlags::from_bits_retain(1 << 3),
|
||||
&[
|
||||
(TestFlags::empty(), false),
|
||||
(TestFlags::A, false),
|
||||
(TestFlags::B, false),
|
||||
(TestFlags::C, false),
|
||||
(TestFlags::from_bits_retain(1 << 3), true),
|
||||
],
|
||||
TestFlags::intersects,
|
||||
);
|
||||
|
||||
case(
|
||||
TestOverlapping::AB,
|
||||
&[
|
||||
(TestOverlapping::AB, true),
|
||||
(TestOverlapping::BC, true),
|
||||
(TestOverlapping::from_bits_retain(1 << 1), true),
|
||||
],
|
||||
TestOverlapping::intersects,
|
||||
);
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
fn case<T: Flags + std::fmt::Debug + Copy>(
|
||||
value: T,
|
||||
inputs: &[(T, bool)],
|
||||
mut inherent: impl FnMut(&T, T) -> bool,
|
||||
) {
|
||||
for (input, expected) in inputs {
|
||||
assert_eq!(
|
||||
*expected,
|
||||
inherent(&value, *input),
|
||||
"{:?}.intersects({:?})",
|
||||
value,
|
||||
input
|
||||
);
|
||||
assert_eq!(
|
||||
*expected,
|
||||
Flags::intersects(&value, *input),
|
||||
"Flags::intersects({:?}, {:?})",
|
||||
value,
|
||||
input
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue