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