1 #![warn(rust_2018_idioms)] 2 #![cfg(feature = "full")] 3 4 use tokio::io::{AsyncWrite, AsyncWriteExt}; 5 6 use std::io; 7 use std::pin::Pin; 8 use std::task::{Context, Poll}; 9 10 #[tokio::test] write_int_should_err_if_write_count_0()11async fn write_int_should_err_if_write_count_0() { 12 struct Wr {} 13 14 impl AsyncWrite for Wr { 15 fn poll_write( 16 self: Pin<&mut Self>, 17 _cx: &mut Context<'_>, 18 _buf: &[u8], 19 ) -> Poll<io::Result<usize>> { 20 Ok(0).into() 21 } 22 23 fn poll_flush(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<io::Result<()>> { 24 Ok(()).into() 25 } 26 27 fn poll_shutdown(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<io::Result<()>> { 28 Ok(()).into() 29 } 30 } 31 32 let mut wr = Wr {}; 33 34 // should be ok just to test these 2, other cases actually expanded by same macro. 35 assert!(wr.write_i8(0).await.is_err()); 36 assert!(wr.write_i32(12).await.is_err()); 37 } 38