fn assert_send<T: Send>() {}
fn assert_future<T: std::future::Future>() {}
#[test]
fn test_read_async_future_type_parameters_satisfy_send() {
assert_send::<futures::channel::oneshot::Receiver<Result<(), wgpu::BufferAsyncError>>>();
assert_send::<futures::channel::oneshot::Sender<Result<(), wgpu::BufferAsyncError>>>();
}
#[allow(dead_code)]
async fn _check_compute_pipeline_api_compat(
pipeline: oxigdal_gpu::ComputePipeline<f32>,
) -> oxigdal_gpu::GpuResult<Vec<f32>> {
let _blocking_fn: fn(oxigdal_gpu::ComputePipeline<f32>) -> oxigdal_gpu::GpuResult<Vec<f32>> =
oxigdal_gpu::ComputePipeline::<f32>::read_blocking;
pipeline.read_async().await
}
#[test]
fn test_read_async_and_blocking_api_signatures_compatible() {
let _: fn(oxigdal_gpu::ComputePipeline<f32>) -> oxigdal_gpu::GpuResult<Vec<f32>> =
oxigdal_gpu::ComputePipeline::<f32>::read_blocking;
assert_future::<
std::pin::Pin<Box<dyn std::future::Future<Output = oxigdal_gpu::GpuResult<Vec<f32>>>>>,
>();
}
#[test]
fn test_oneshot_channel_resolves_on_send() {
let (tx, rx) = futures::channel::oneshot::channel::<u32>();
let send_result = tx.send(42_u32);
assert!(
send_result.is_ok(),
"send should succeed on an open channel"
);
let received = pollster::block_on(rx);
assert!(
received.is_ok(),
"receiver should not be cancelled when sender sent a value"
);
assert_eq!(
received.expect("receiver value"),
42_u32,
"received value must match sent value"
);
}
#[test]
fn test_poll_type_enum_accessible() {
let _poll_type = wgpu::PollType::Poll;
let _wait_type = wgpu::PollType::wait_indefinitely();
}
#[test]
fn test_read_async_error_type_matches_blocking() {
let err = oxigdal_gpu::GpuError::buffer_mapping("Channel closed");
let formatted = err.to_string();
assert!(
formatted.contains("Channel closed"),
"error message must include the reason string, got: {formatted}"
);
assert!(
formatted.contains("map"),
"error message must mention 'map' (buffer mapping failure), got: {formatted}"
);
let err2 = oxigdal_gpu::GpuError::buffer_mapping("wgpu: buffer destroyed");
assert!(
err2.to_string().contains("buffer destroyed"),
"reason must propagate through the error message"
);
assert!(
err.is_recoverable(),
"BufferMapping errors must be recoverable"
);
}