mirror of
https://github.com/fanzeyi/cargo-play
synced 2024-11-10 05:04:13 +00:00
add external_crate test
This commit is contained in:
parent
f345f7589d
commit
7e424d95b3
3 changed files with 32 additions and 0 deletions
22
fixtures/bitflags.rs
Normal file
22
fixtures/bitflags.rs
Normal file
|
@ -0,0 +1,22 @@
|
|||
#!/bin/true
|
||||
//# bitflags = "1.1.0"
|
||||
|
||||
use bitflags::bitflags;
|
||||
|
||||
bitflags! {
|
||||
struct Flags: u32 {
|
||||
const A = 0b00000001;
|
||||
const B = 0b00000010;
|
||||
const C = 0b00000100;
|
||||
const ABC = Self::A.bits | Self::B.bits | Self::C.bits;
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let e1 = Flags::A | Flags::C;
|
||||
let e2 = Flags::B | Flags::C;
|
||||
assert_eq!((e1 | e2), Flags::ABC); // union
|
||||
assert_eq!((e1 & e2), Flags::C); // intersection
|
||||
assert_eq!((e1 - e2), Flags::A); // set difference
|
||||
assert_eq!(!e2, Flags::A); // set complement
|
||||
}
|
|
@ -199,3 +199,13 @@ fn program_args() -> Result<()> {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn external_crate() -> Result<()> {
|
||||
let rt = TestRuntime::new()?;
|
||||
|
||||
let output = rt.run(&["fixtures/bitflags.rs"])?;
|
||||
assert_eq!(output.status.code().unwrap(), 0);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue