mirror of
https://github.com/rustdesk/magnum-opus.git
synced 2025-07-01 15:25:27 +00:00
Use compiletest to check Repacketizer lifetimes
This commit is contained in:
parent
09f9d16148
commit
9a0430620f
@ -13,3 +13,6 @@ repository = "https://github.com/SpaceManiac/opus-rs"
|
||||
[dependencies]
|
||||
opus-sys = "0.2.0"
|
||||
libc = "0.2"
|
||||
|
||||
[dev-dependencies]
|
||||
compiletest_rs = "0.2.4"
|
||||
|
10
tests/compile-fail/repacketize.rs
Normal file
10
tests/compile-fail/repacketize.rs
Normal file
@ -0,0 +1,10 @@
|
||||
extern crate opus;
|
||||
|
||||
fn main() {
|
||||
let mut rp = opus::Repacketizer::new().unwrap();
|
||||
let mut wip = rp.begin().cat_move(
|
||||
&[1, 2, 3]
|
||||
//~^ ERROR borrowed value does not live long enough
|
||||
).unwrap();
|
||||
wip.out(&mut []);
|
||||
}
|
21
tests/compiletests.rs
Normal file
21
tests/compiletests.rs
Normal file
@ -0,0 +1,21 @@
|
||||
extern crate compiletest_rs as compiletest;
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
const DEPS: &'static str = "-L target/debug -L target/debug/deps";
|
||||
#[cfg(not(debug_assertions))]
|
||||
const DEPS: &'static str = "-L target/release -L target/release/deps";
|
||||
|
||||
fn run_mode(mode: &'static str) {
|
||||
let mut config = compiletest::default_config();
|
||||
config.mode = mode.parse().ok().expect("Invalid mode");
|
||||
config.src_base = PathBuf::from(format!("tests/{}", mode));
|
||||
config.target_rustcflags = Some(DEPS.to_owned());
|
||||
compiletest::run_tests(&config);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn compile_test() {
|
||||
run_mode("compile-fail");
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user