From 803eae5d6bcb7065da28167f0617c599702408bd Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Mon, 22 Feb 2016 15:55:15 +0100 Subject: [PATCH] Add some tests for sync primitives --- vulkano/src/sync.rs | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/vulkano/src/sync.rs b/vulkano/src/sync.rs index 116d8193..864b368a 100644 --- a/vulkano/src/sync.rs +++ b/vulkano/src/sync.rs @@ -355,3 +355,48 @@ impl Drop for Event { } } } + +#[cfg(test)] +mod tests { + use sync::Fence; + use sync::Semaphore; + + #[test] + fn fence_create() { + let (device, _) = gfx_dev_and_queue!(); + + let fence = Fence::new(&device).unwrap(); + assert!(!fence.ready().unwrap()); + } + + #[test] + fn fence_create_signaled() { + let (device, _) = gfx_dev_and_queue!(); + + let fence = Fence::signaled(&device).unwrap(); + assert!(fence.ready().unwrap()); + } + + #[test] + fn fence_signaled_wait() { + let (device, _) = gfx_dev_and_queue!(); + + let fence = Fence::signaled(&device).unwrap(); + fence.wait(10).unwrap(); + } + + #[test] + fn fence_reset() { + let (device, _) = gfx_dev_and_queue!(); + + let fence = Fence::signaled(&device).unwrap(); + fence.reset(); + assert!(!fence.ready().unwrap()); + } + + #[test] + fn semaphore_create() { + let (device, _) = gfx_dev_and_queue!(); + let _ = Semaphore::new(&device).unwrap(); + } +}