use super::*; #[test] fn test_u8_take() { let container: Rusturn = Rusturn::new(); let blocking: Access<&Rusturn, _> = container.blocking_access(); let _: () = blocking.publish(64u8); assert_eq!(blocking.take().unwrap(), Some(64u8)); assert!(blocking.take().unwrap().is_none()); } #[test] fn test_u8_try_take() { let container: Rusturn = Rusturn::new(); let directly: Access<&Rusturn, _> = container.instant_access(); let _: () = directly.try_publish(64u8).unwrap(); assert_eq!(directly.try_take().unwrap(), Some(64u8)); assert!(directly.try_take().unwrap().is_none()); } #[test] fn test_u8_fail_try_take() { let container: Rusturn = Rusturn::new(); let directly: Access<&Rusturn, _> = container.instant_access(); let _: () = directly.try_publish(64u8).unwrap(); let editor: Editor = directly.try_edit().unwrap(); prevent_optimization(&editor); assert!(matches!( directly.try_take(), Err(TryAccessError::NotAccessible( InstantAccessError::WouldBlock )) )); editor.done(); assert!(matches!(directly.try_take(), Ok(Some(64u8)))); assert_eq!(directly.try_edit().unwrap().take(), None); }