MCPcopy Create free account
hub / github.com/dfinity/orbit / test_observer

Function test_observer

core/station/impl/src/core/observer.rs:48–68  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

46
47 #[test]
48 fn test_observer() {
49 let mut observer = Observer::default();
50 observer.add_listener(Box::new(|t| {
51 assert_eq!(*t, 42);
52 COUNT.with(|count| {
53 *count.borrow_mut() += 1;
54 });
55 }));
56 observer.add_listener(Box::new(|t| {
57 assert_eq!(*t, 42);
58 COUNT.with(|count| {
59 *count.borrow_mut() += 1;
60 });
61 }));
62
63 observer.notify(&42);
64
65 COUNT.with(|count| {
66 assert_eq!(*count.borrow(), 2);
67 });
68 }
69
70 #[test]
71 fn test_observer_debug() {

Callers

nothing calls this directly

Calls 2

add_listenerMethod · 0.80
notifyMethod · 0.45

Tested by

no test coverage detected