//! TDD tests for device fallback handling //! These tests define expected behavior for device creation without cpu feature use rtx_tensor::Device; #[test] fn test_device_default_creation() { // Test creating default device (should work without cpu feature) let device = Device::default(); // Device should be valid match device { Device::Cuda(_) => { // CUDA device is valid } _ => { // Other devices are valid too } } } #[test] fn test_device_cuda_with_fallback() { // Test CUDA creation with fallback to default let device = Device::cuda(0).unwrap_or(Device::default()); // Should have a valid device match device { Device::Cuda(_) => { // CUDA device worked } _ => { // Fallback worked } } } #[test] fn test_device_fallback_pattern() { // Test the pattern we'll use to replace Device::cpu() let device = get_fallback_device(); // Should return a valid device match device { Device::Cuda(_) => { // CUDA device } _ => { // Default device } } } // Helper function that replaces Device::cpu() calls fn get_fallback_device() -> Device { Device::cuda(0).unwrap_or(Device::default()) }