From 6c3ebfa433db9ee480f2ec853199cf6911ab8757 Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Sat, 22 Sep 2018 19:57:58 -0400 Subject: [PATCH] More tests --- tests/basic.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/basic.rs b/tests/basic.rs index bbf2395..e688ed8 100644 --- a/tests/basic.rs +++ b/tests/basic.rs @@ -41,4 +41,30 @@ fn allocation_flag() { let _x = Box::new(42); assert!(A.has_allocated()); +} + +#[inline(never)] +fn no_op() {} + +#[test] +fn no_alloc_during_noop() { + A.clear_allocations(); + assert!(!A.has_allocated()); + + no_op(); + assert!(!A.has_allocated()); +} + +#[inline(never)] +fn allocates() { + let _x = Box::new(42); +} + +#[test] +fn alloc_during_func_call() { + A.clear_allocations(); + assert!(!A.has_allocated()); + + allocates(); + assert!(A.has_allocated()); } \ No newline at end of file