From 17ee783d3efb6ff4361da2050f492494ef23f059 Mon Sep 17 00:00:00 2001 From: Theodore Cipicchio Date: Sat, 16 Jun 2018 14:08:23 -0700 Subject: [PATCH] Add `static_new_in_place()` marker limit tests --- src/tests.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/tests.rs b/src/tests.rs index 5364406..e1f842d 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -544,6 +544,38 @@ fn validate_back_marker_limits() { ); } +/// Verifies that the available space for tracking markers at the front of a +/// scratchpad is correctly adjusted as markers set at the back increase when +/// using a `Scratchpad` created with `static_new_in_place()`. +#[test] +fn validate_front_marker_limits_in_place() { + unsafe { + let mut scratchpad = uninitialized(); + SimpleScratchpad::static_new_in_place(&mut scratchpad); + validate_marker_limits( + &scratchpad, + |scratchpad| scratchpad.mark_front(), + |scratchpad| scratchpad.mark_back(), + ); + } +} + +/// Verifies that the available space for tracking markers at the back of a +/// scratchpad is correctly adjusted as markers set at the front increase when +/// using a `Scratchpad` created with `static_new_in_place()`. +#[test] +fn validate_back_marker_limits_in_place() { + unsafe { + let mut scratchpad = uninitialized(); + SimpleScratchpad::static_new_in_place(&mut scratchpad); + validate_marker_limits( + &scratchpad, + |scratchpad| scratchpad.mark_back(), + |scratchpad| scratchpad.mark_front(), + ); + } +} + /// Verifies `Allocation::unwrap()` doesn't accidentally drop or leak data. #[test] fn allocation_unwrap_test() {