1
0
mirror of https://github.com/bspeice/qadapt synced 2025-07-01 22:06:49 -04:00

Get version 0.4 ready

This commit is contained in:
2018-11-15 20:16:49 -05:00
parent 398b1395a0
commit 8b4ebe8c88
7 changed files with 53 additions and 26 deletions

View File

@ -1,4 +1,3 @@
#![feature(asm)]
extern crate qadapt;
use qadapt::enter_protected;
@ -9,16 +8,11 @@ use qadapt::QADAPT;
#[global_allocator]
static Q: QADAPT = QADAPT;
pub fn black_box<T>(dummy: T) -> T {
// Taken from test lib, need to mark the arg as non-introspectable
unsafe { asm!("" : : "r"(&dummy)) }
dummy
}
#[test]
fn test_copy() {
enter_protected();
black_box(0u8);
let v = 0u8;
let v2 = v;
exit_protected();
}
@ -41,16 +35,8 @@ fn unit_result(b: bool) -> Result<(), ()> {
#[test]
fn test_unit_result() {
enter_protected();
#[allow(unused)]
{
black_box(unit_result(true));
}
black_box(unit_result(true)).unwrap();
#[allow(unused)]
{
black_box(unit_result(false));
}
black_box(unit_result(false)).unwrap_err();
unit_result(true).unwrap();
unit_result(false).unwrap_err();
exit_protected();
}
@ -80,14 +66,14 @@ fn test_vec_push_capacity() {
#[test]
fn test_vec_with_zero() {
enter_protected();
let _v: Vec<u8> = black_box(Vec::with_capacity(0));
let _v: Vec<u8> = Vec::with_capacity(0);
exit_protected();
}
#[test]
fn test_vec_new() {
enter_protected();
let _v: Vec<u8> = black_box(Vec::new());
let _v: Vec<u8> = Vec::new();
exit_protected();
}
@ -110,3 +96,12 @@ fn exit_too_often() {
exit_protected();
exit_protected();
}
#[test]
#[should_panic]
fn intentional_drop() {
let v: Vec<()> = Vec::new();
let v = Box::new(v);
enter_protected();
drop(v);
}