Skip to content

Commit

Permalink
Test for Send and Sync
Browse files Browse the repository at this point in the history
Should fail to compile if not
  • Loading branch information
lifers committed Aug 16, 2024
1 parent dff4499 commit 208e52f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions crates/tests/event/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,20 @@ fn multiple() -> Result<()> {

Ok(())
}

#[test]
fn is_send_sync() -> Result<()> {
// test that the event can be sent and synced between threads
let event = Arc::new(Event::<EventHandler<i32>>::new());
let event_sender = event.clone();

let thread = std::thread::spawn(move || {
// Nothing will happen because the event is empty.
event_sender.call(|delegate| delegate.Invoke(None, 123));
event_sender
});

let returned_event = thread.join().unwrap();
assert!(Arc::ptr_eq(&event, &returned_event));
Ok(())
}

0 comments on commit 208e52f

Please sign in to comment.