team-ljyzipelo

공개
25줄846 바이트
1use app_core::Operation;
2
3#[test]
4fn ids_are_nonzero_distinct_and_bound_to_handles() {
5 let (first, first_cancel) = Operation::start().unwrap();
6 let (second, second_cancel) = Operation::start().unwrap();
7 assert_ne!(first.id(), second.id());
8 assert_ne!(first.id().value(), 0);
9 assert_ne!(second.id().value(), 0);
10 assert_eq!(first.id(), first_cancel.operation());
11 assert_eq!(second.id(), second_cancel.operation());
12}
13
14#[test]
15fn cancellation_is_shared_monotonic_and_operation_local() {
16 let (_, first) = Operation::start().unwrap();
17 let clone = first.clone();
18 let (_, second) = Operation::start().unwrap();
19 assert!(!first.is_requested());
20 assert!(clone.request());
21 assert!(first.is_requested());
22 assert!(!first.request());
23 assert!(!clone.request());
24 assert!(!second.is_requested());
25}