mirror of
https://github.com/bspeice/qadapt
synced 2025-07-02 06:16:30 -04:00
Handle actual functions
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
extern crate qadapt;
|
||||
use std::io;
|
||||
|
||||
use qadapt::allocate_panic;
|
||||
use qadapt::QADAPT;
|
||||
@ -20,13 +21,65 @@ fn no_allocate() {
|
||||
let _v: Vec<()> = Vec::with_capacity(0);
|
||||
}
|
||||
|
||||
#[allocate_panic]
|
||||
fn no_allocate_ret() -> bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
#[allocate_panic]
|
||||
fn no_allocate_implicit_ret() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
#[allocate_panic]
|
||||
fn no_allocate_arg(b: bool) -> bool {
|
||||
b
|
||||
}
|
||||
|
||||
#[allocate_panic]
|
||||
fn no_allocate_args(_b: bool, _u: usize, i: i64) -> i64 {
|
||||
i
|
||||
}
|
||||
|
||||
#[allocate_panic]
|
||||
fn return_result(r: Result<usize, io::Error>) -> Result<Result<usize, io::Error>, ()> {
|
||||
Ok(r)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_no_allocate() {
|
||||
fn macro_no_allocate() {
|
||||
no_allocate();
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn test_allocates() {
|
||||
fn macro_allocates() {
|
||||
allocates();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn macro_return() {
|
||||
assert!(no_allocate_ret());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn macro_implicit_return() {
|
||||
assert!(no_allocate_ret());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn macro_allocate_arg() {
|
||||
no_allocate_arg(true);
|
||||
no_allocate_arg(false);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn macro_allocate_args() {
|
||||
no_allocate_args(true, 0, -1);
|
||||
no_allocate_args(false, 4, -90);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn macro_return_result() {
|
||||
return_result(Ok(16)).unwrap().unwrap();
|
||||
}
|
Reference in New Issue
Block a user