use super::*; #[test] fn test_u8_reset() { 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!(directly.try_edit().unwrap().has()); let _: () = blocking.reset(); assert!(directly.try_take().unwrap().is_none()); } #[test] fn test_u8_try_reset() { 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!(directly.try_edit().unwrap().has()); let _: () = directly.try_reset().unwrap(); assert!(blocking.take().unwrap().is_none()); } #[test] fn test_u8_fail_try_reset() { 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_reset(), Err(InstantAccessError::WouldBlock) )); editor.done(); assert!(directly.try_edit().unwrap().has()); assert!(matches!(directly.try_reset(), Ok(()))); assert_eq!(directly.try_edit().unwrap().take(), None); }