Vendor things
This commit is contained in:
parent
5deceec006
commit
977e3c17e5
19434 changed files with 10682014 additions and 0 deletions
47
third-party/vendor/num_enum-0.5.11/tests/into_primitive.rs
vendored
Normal file
47
third-party/vendor/num_enum-0.5.11/tests/into_primitive.rs
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
use ::num_enum::IntoPrimitive;
|
||||
|
||||
// Guard against https://github.com/illicitonion/num_enum/issues/27
|
||||
mod alloc {}
|
||||
mod core {}
|
||||
mod num_enum {}
|
||||
mod std {}
|
||||
|
||||
#[derive(IntoPrimitive)]
|
||||
#[repr(u8)]
|
||||
enum Enum {
|
||||
Zero,
|
||||
One,
|
||||
Two,
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn simple() {
|
||||
let zero: u8 = Enum::Zero.into();
|
||||
assert_eq!(zero, 0u8);
|
||||
|
||||
let one: u8 = Enum::One.into();
|
||||
assert_eq!(one, 1u8);
|
||||
|
||||
let two: u8 = Enum::Two.into();
|
||||
assert_eq!(two, 2u8);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn catch_all() {
|
||||
#[derive(Debug, Eq, PartialEq, IntoPrimitive)]
|
||||
#[repr(u8)]
|
||||
enum Enum {
|
||||
Zero = 0,
|
||||
#[num_enum(catch_all)]
|
||||
NonZero(u8),
|
||||
}
|
||||
|
||||
let zero: u8 = Enum::Zero.into();
|
||||
assert_eq!(zero, 0u8);
|
||||
|
||||
let one: u8 = Enum::NonZero(1u8).into();
|
||||
assert_eq!(one, 1u8);
|
||||
|
||||
let two: u8 = Enum::NonZero(2u8).into();
|
||||
assert_eq!(two, 2u8);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue