id stringlengths 22 133 | text stringlengths 40 40.2k | arch stringclasses 1
value | syntax stringclasses 1
value | kind stringclasses 4
values | repo stringclasses 27
values | path stringlengths 5 116 | license stringclasses 6
values | commit stringlengths 40 40 | source_host stringclasses 1
value | category stringclasses 16
values | source_url stringlengths 85 196 | line_start int64 1 4.28k | line_end int64 4 4.31k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tokio-rs/tokio:tokio/tests/io_read.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::{AsyncRead, AsyncReadExt};
use tokio_test::assert_ok;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
#[tokio::test]
async fn read() {
#[derive(Default)]
struct Rd {
poll_cnt: usize,
}
impl AsyncRead for Rd {... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read.rs | MIT | fbe143b142875977f49772d2905029b57b92e429 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fbe143b142875977f49772d2905029b57b92e429/tokio/tests/io_read.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_read.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::{AsyncRead, AsyncReadExt};
use tokio_test::assert_ok;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
#[tokio::test]
async fn read() {
#[derive(Default)]
struct Rd {
poll_cnt: usize,
}
impl AsyncRead for Rd {... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read.rs | MIT | 7b4c999341809588a427a9a80d310ee4aa1c1a21 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7b4c999341809588a427a9a80d310ee4aa1c1a21/tokio/tests/io_read.rs | 1 | 38 |
tokio-rs/tokio:tokio/tests/io_read.rs:1 | #![deny(warnings, rust_2018_idioms)]
#![feature(async_await)]
use tokio::io::{AsyncRead, AsyncReadExt};
use tokio_test::assert_ok;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
#[tokio::test]
async fn read() {
#[derive(Default)]
struct Rd {
poll_cnt: usize,
}
impl AsyncRead... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read.rs | MIT | ed4d4a5353d07d2428072965ea23c9a6eba5d87d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ed4d4a5353d07d2428072965ea23c9a6eba5d87d/tokio/tests/io_read.rs | 1 | 38 |
tokio-rs/tokio:tokio/tests/io_read.rs:1 | #![deny(warnings, rust_2018_idioms)]
#![feature(async_await)]
use tokio::io::{AsyncRead, AsyncReadExt};
use tokio_test::assert_ok;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
#[tokio::test]
async fn read() {
#[derive(Default)]
struct Rd {
poll_cnt: usize,
}
impl AsyncRead... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read.rs | MIT | 1f47ed3dcc4b582315cdbfb195495d7d4c76d3f3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1f47ed3dcc4b582315cdbfb195495d7d4c76d3f3/tokio/tests/io_read.rs | 1 | 38 |
tokio-rs/tokio:tokio/tests/io_read.rs:1 | #![deny(warnings, rust_2018_idioms)]
use tokio::io::{AsyncRead, AsyncReadExt};
use tokio_test::assert_ready_ok;
use tokio_test::task::MockTask;
use pin_utils::pin_mut;
use std::future::Future;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
#[test]
fn read() {
struct Rd;
impl AsyncRead for R... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read.rs | MIT | 11f6b2862fc458204aabbed9a6f919c65215aeb5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f6b2862fc458204aabbed9a6f919c65215aeb5/tokio/tests/io_read.rs | 1 | 41 |
tokio-rs/tokio:tokio/tests/io_read_buf.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::{AsyncRead, AsyncReadExt, ReadBuf};
use tokio_test::assert_ok;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
#[tokio::test]
async fn read_buf() {
struct Rd {
cnt: usize,
}
impl AsyncRead for Rd {
fn pol... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_buf.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_read_buf.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_read_buf.rs:2 | use bytes::BufMut;
// steps to zero
let mut buf = [0; 8];
let mut read_buf = ReadBuf::new(&mut buf);
assert_eq!(read_buf.remaining_mut(), 8);
assert_eq!(read_buf.chunk_mut().len(), 8);
unsafe {
read_buf.advance_mut(1);
}
assert_eq!(read_buf.remaining_mut(), 7);
assert_eq!(re... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_buf.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_read_buf.rs | 41 | 94 |
tokio-rs/tokio:tokio/tests/io_read_buf.rs:3 | let mut buf = [std::mem::MaybeUninit::uninit(); 8];
let mut uninit = ReadBuf::uninit(&mut buf);
unsafe {
uninit.advance_mut(4);
}
assert_eq!(uninit.remaining_mut(), 4);
assert_eq!(uninit.chunk_mut().len(), 4);
uninit.put_u8(1);
assert_eq!(uninit.remaining_mut(), 3);
assert_eq!(un... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_buf.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_read_buf.rs | 81 | 94 |
tokio-rs/tokio:tokio/tests/io_read_buf.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::{AsyncRead, AsyncReadExt, ReadBuf};
use tokio_test::assert_ok;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
#[tokio::test]
async fn read_buf() {
struct Rd {
cnt: usize,
}
impl AsyncRead for Rd {
fn pol... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_buf.rs | MIT | d78655337a68bded305782a8a8b4ac7be42aa6a7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d78655337a68bded305782a8a8b4ac7be42aa6a7/tokio/tests/io_read_buf.rs | 1 | 36 |
tokio-rs/tokio:tokio/tests/io_read_buf.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::{AsyncRead, AsyncReadExt, ReadBuf};
use tokio_test::assert_ok;
use futures::future::poll_fn;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
#[tokio::test]
async fn read_buf() {
struct Rd {
cnt: usize,
}
impl Asy... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_buf.rs | MIT | fe2b9976755407b85c82b5cdee9d8c5e16e3d6c6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fe2b9976755407b85c82b5cdee9d8c5e16e3d6c6/tokio/tests/io_read_buf.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_read_buf.rs:2 | struct Rd {
cnt: usize,
}
impl AsyncRead for Rd {
fn poll_read(
mut self: Pin<&mut Self>,
_cx: &mut Context<'_>,
buf: &mut ReadBuf<'_>,
) -> Poll<io::Result<()>> {
self.cnt += 1;
buf.put_slice(b"hello world");
Poll:... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_buf.rs | MIT | fe2b9976755407b85c82b5cdee9d8c5e16e3d6c6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fe2b9976755407b85c82b5cdee9d8c5e16e3d6c6/tokio/tests/io_read_buf.rs | 41 | 72 |
tokio-rs/tokio:tokio/tests/io_read_exact.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::AsyncReadExt;
use tokio_test::assert_ok;
#[tokio::test]
async fn read_exact() {
let mut buf = Box::new([0; 8]);
let mut rd: &[u8] = b"hello world";
let n = assert_ok!(rd.read_exact(&mut buf[..]).await);
assert_eq!(n, 8);
assert_e... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_exact.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_read_exact.rs | 1 | 15 |
tokio-rs/tokio:tokio/tests/io_read_exact.rs:1 | #![deny(warnings, rust_2018_idioms)]
#![feature(async_await)]
use tokio::io::{AsyncRead, AsyncReadExt};
use tokio_test::assert_ok;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
#[tokio::test]
async fn read_exact() {
struct Rd {
val: &'static [u8; 11],
}
impl AsyncRead for Rd {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_exact.rs | MIT | ed4d4a5353d07d2428072965ea23c9a6eba5d87d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ed4d4a5353d07d2428072965ea23c9a6eba5d87d/tokio/tests/io_read_exact.rs | 1 | 39 |
tokio-rs/tokio:tokio/tests/io_read_exact.rs:1 | #![deny(warnings, rust_2018_idioms)]
#![feature(async_await)]
use tokio::io::{AsyncRead, AsyncReadExt};
use tokio_test::assert_ok;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
#[tokio::test]
async fn read_exact() {
struct Rd {
val: &'static [u8; 11],
}
impl AsyncRead for Rd {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_exact.rs | MIT | 1f47ed3dcc4b582315cdbfb195495d7d4c76d3f3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1f47ed3dcc4b582315cdbfb195495d7d4c76d3f3/tokio/tests/io_read_exact.rs | 1 | 37 |
tokio-rs/tokio:tokio/tests/io_read_exact.rs:1 | #![deny(warnings, rust_2018_idioms)]
use tokio::io::{AsyncRead, AsyncReadExt};
use tokio_test::assert_ready_ok;
use tokio_test::task::MockTask;
use pin_utils::pin_mut;
use std::future::Future;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
#[test]
fn read_exact() {
struct Rd {
val: &'sta... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_exact.rs | MIT | 11f6b2862fc458204aabbed9a6f919c65215aeb5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f6b2862fc458204aabbed9a6f919c65215aeb5/tokio/tests/io_read_exact.rs | 1 | 46 |
tokio-rs/tokio:tokio/tests/io_read_line.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use std::io::ErrorKind;
use tokio::io::{AsyncBufReadExt, BufReader, Error};
use tokio_test::{assert_ok, io::Builder};
use std::io::Cursor;
#[tokio::test]
async fn read_line() {
let mut buf = String::new();
let mut rd = Cursor::new(b"hello\nworld\n\n");
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_line.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_read_line.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_read_line.rs:2 | let mut line = "We say ".to_string();
let bytes = read.read_line(&mut line).await.unwrap();
assert_eq!(bytes, "Hello World\n".len());
assert_eq!(line.as_str(), "We say Hello World\n");
line = "I solve ".to_string();
let bytes = read.read_line(&mut line).await.unwrap();
assert_eq!(bytes, "FizzBu... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_line.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_read_line.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/io_read_line.rs:3 | .build();
let mut read = BufReader::new(mock);
let mut line = "Foo".to_string();
let err = read.read_line(&mut line).await.expect_err("Should fail");
assert_eq!(err.kind(), ErrorKind::Other);
assert_eq!(err.to_string(), "The world has no end");
assert_eq!(line.as_str(), "FooHello Wor");
}
#[t... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_line.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_read_line.rs | 81 | 107 |
tokio-rs/tokio:tokio/tests/io_read_line.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::AsyncBufReadExt;
use tokio_test::assert_ok;
use std::io::Cursor;
#[tokio::test]
async fn read_line() {
let mut buf = String::new();
let mut rd = Cursor::new(b"hello\nworld\n\n");
let n = assert_ok!(rd.read_line(&mut buf).await);
ass... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_line.rs | MIT | 7b4c999341809588a427a9a80d310ee4aa1c1a21 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7b4c999341809588a427a9a80d310ee4aa1c1a21/tokio/tests/io_read_line.rs | 1 | 29 |
tokio-rs/tokio:tokio/tests/io_read_line.rs:1 | #![deny(warnings, rust_2018_idioms)]
#![feature(async_await)]
use tokio::io::{AsyncBufRead, AsyncBufReadExt, AsyncRead};
use tokio_test::assert_ok;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
#[tokio::test]
async fn read_line() {
struct Rd {
val: &'static [u8],
}
impl AsyncRe... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_line.rs | MIT | ab040bb498c96623f413efdc9fc16c46f72f9c63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ab040bb498c96623f413efdc9fc16c46f72f9c63/tokio/tests/io_read_line.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_read_to_end.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use std::pin::Pin;
use std::task::{Context, Poll};
use tokio::io::{AsyncRead, AsyncReadExt, ReadBuf};
use tokio_test::assert_ok;
use tokio_test::io::Builder;
#[tokio::test]
async fn read_to_end() {
let mut buf = vec![];
let mut rd: &[u8] = b"hello world";
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_to_end.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_read_to_end.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_read_to_end.rs:2 | match me.state {
State::Initializing => {
buf.initialize_unfilled_to(me.num_init + 2);
buf.advance(1);
me.num_init += 1;
if me.num_init == 24 {
me.state = State::JustFilling;
}
}
Stat... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_to_end.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_read_to_end.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/io_read_to_end.rs:3 | #[tokio::test]
#[cfg_attr(miri, ignore)] // too slow with miri
async fn read_to_end_doesnt_grow_with_capacity() {
let arr: Vec<u8> = (0..100).collect();
// We only test from 32 since we allocate at least 32 bytes each time
for len in 32..100 {
let bytes = &arr[..len];
for split in 0..len {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_to_end.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_read_to_end.rs | 81 | 125 |
tokio-rs/tokio:tokio/tests/io_read_to_end.rs:2 | match me.state {
State::Initializing => {
buf.initialize_unfilled_to(me.num_init + 2);
buf.advance(1);
me.num_init += 1;
if me.num_init == 24 {
me.state = State::JustFilling;
}
}
Stat... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_to_end.rs | MIT | 7aea597a8f5af8756bdac35095f49ded8ec1a4e2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7aea597a8f5af8756bdac35095f49ded8ec1a4e2/tokio/tests/io_read_to_end.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/io_read_to_end.rs:3 | #[tokio::test]
async fn read_to_end_doesnt_grow_with_capacity() {
let arr: Vec<u8> = (0..100).collect();
// We only test from 32 since we allocate at least 32 bytes each time
for len in 32..100 {
let bytes = &arr[..len];
for split in 0..len {
for cap in 0..101 {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_to_end.rs | MIT | 7aea597a8f5af8756bdac35095f49ded8ec1a4e2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7aea597a8f5af8756bdac35095f49ded8ec1a4e2/tokio/tests/io_read_to_end.rs | 81 | 124 |
tokio-rs/tokio:tokio/tests/io_read_to_end.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use std::pin::Pin;
use std::task::{Context, Poll};
use tokio::io::{AsyncRead, AsyncReadExt, ReadBuf};
use tokio_test::assert_ok;
#[tokio::test]
async fn read_to_end() {
let mut buf = vec![];
let mut rd: &[u8] = b"hello world";
let n = assert_ok!(rd.rea... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_to_end.rs | MIT | c1cf6b7504bdb08b7702568b7669751ee2d76649 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c1cf6b7504bdb08b7702568b7669751ee2d76649/tokio/tests/io_read_to_end.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_read_to_end.rs:2 | match me.state {
State::Initializing => {
buf.initialize_unfilled_to(me.num_init + 2);
buf.advance(1);
me.num_init += 1;
if me.num_init == 24 {
me.state = State::JustFilling;
}
}
Stat... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_to_end.rs | MIT | c1cf6b7504bdb08b7702568b7669751ee2d76649 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c1cf6b7504bdb08b7702568b7669751ee2d76649/tokio/tests/io_read_to_end.rs | 41 | 78 |
tokio-rs/tokio:tokio/tests/io_read_to_end.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::AsyncReadExt;
use tokio_test::assert_ok;
#[tokio::test]
async fn read_to_end() {
let mut buf = vec![];
let mut rd: &[u8] = b"hello world";
let n = assert_ok!(rd.read_to_end(&mut buf).await);
assert_eq!(n, 11);
assert_eq!(buf[..],... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_to_end.rs | MIT | 7b4c999341809588a427a9a80d310ee4aa1c1a21 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7b4c999341809588a427a9a80d310ee4aa1c1a21/tokio/tests/io_read_to_end.rs | 1 | 15 |
tokio-rs/tokio:tokio/tests/io_read_to_end.rs:1 | #![deny(warnings, rust_2018_idioms)]
#![feature(async_await)]
use tokio::io::{AsyncRead, AsyncReadExt};
use tokio_test::assert_ok;
use std::pin::Pin;
use std::task::{Context, Poll};
use std::{cmp, io};
#[tokio::test]
async fn read_to_end() {
struct Rd {
val: &'static [u8],
}
impl AsyncRead for R... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_to_end.rs | MIT | f1b8a318d9d65c8e1ca2b4ee3f23f2c57c53bd04 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f1b8a318d9d65c8e1ca2b4ee3f23f2c57c53bd04/tokio/tests/io_read_to_end.rs | 1 | 40 |
tokio-rs/tokio:tokio/tests/io_read_to_string.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use std::io;
use tokio::io::AsyncReadExt;
use tokio_test::assert_ok;
use tokio_test::io::Builder;
#[tokio::test]
async fn read_to_string() {
let mut buf = String::new();
let mut rd: &[u8] = b"hello world";
let n = assert_ok!(rd.read_to_string(&mut buf)... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_to_string.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_read_to_string.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_read_to_string.rs:2 | match AsyncReadExt::read_to_string(&mut mock, &mut s).await {
Ok(len) => panic!("Should fail: {len} bytes."),
Err(err) if err.to_string() == "whoops" => {}
Err(err) => panic!("Fail: {err}."),
}
assert_eq!(s, "abc");
}
#[tokio::test]
async fn to_string_appends() {
let data = b"def".... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_to_string.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_read_to_string.rs | 41 | 63 |
tokio-rs/tokio:tokio/tests/io_read_to_string.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use std::io;
use tokio::io::AsyncReadExt;
use tokio_test::assert_ok;
use tokio_test::io::Builder;
#[tokio::test]
async fn read_to_string() {
let mut buf = String::new();
let mut rd: &[u8] = b"hello world";
let n = assert_ok!(rd.read_to_string(&mut buf)... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_to_string.rs | MIT | 03b68f4e7564a3a78fa29bacfe5e306c59145aaa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03b68f4e7564a3a78fa29bacfe5e306c59145aaa/tokio/tests/io_read_to_string.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_read_to_string.rs:2 | match AsyncReadExt::read_to_string(&mut mock, &mut s).await {
Ok(len) => panic!("Should fail: {} bytes.", len),
Err(err) if err.to_string() == "whoops" => {}
Err(err) => panic!("Fail: {}.", err),
}
assert_eq!(s, "abc");
}
#[tokio::test]
async fn to_string_appends() {
let data = b"d... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_to_string.rs | MIT | 03b68f4e7564a3a78fa29bacfe5e306c59145aaa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03b68f4e7564a3a78fa29bacfe5e306c59145aaa/tokio/tests/io_read_to_string.rs | 41 | 63 |
tokio-rs/tokio:tokio/tests/io_read_to_string.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::AsyncReadExt;
use tokio_test::assert_ok;
#[tokio::test]
async fn read_to_string() {
let mut buf = String::new();
let mut rd: &[u8] = b"hello world";
let n = assert_ok!(rd.read_to_string(&mut buf).await);
assert_eq!(n, 11);
assert... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_to_string.rs | MIT | 7b4c999341809588a427a9a80d310ee4aa1c1a21 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7b4c999341809588a427a9a80d310ee4aa1c1a21/tokio/tests/io_read_to_string.rs | 1 | 15 |
tokio-rs/tokio:tokio/tests/io_read_to_string.rs:1 | #![deny(warnings, rust_2018_idioms)]
#![feature(async_await)]
use tokio::io::{AsyncRead, AsyncReadExt};
use tokio_test::assert_ok;
use std::pin::Pin;
use std::task::{Context, Poll};
use std::{cmp, io};
#[tokio::test]
async fn read_to_string() {
struct Rd {
val: &'static [u8],
}
impl AsyncRead fo... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_to_string.rs | MIT | a88308ed9f608e7225e9803f2dd69ac250c926bf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a88308ed9f608e7225e9803f2dd69ac250c926bf/tokio/tests/io_read_to_string.rs | 1 | 40 |
tokio-rs/tokio:tokio/tests/io_read_until.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use std::io::ErrorKind;
use tokio::io::{AsyncBufReadExt, BufReader, Error};
use tokio_test::{assert_ok, io::Builder};
#[tokio::test]
async fn read_until() {
let mut buf = vec![];
let mut rd: &[u8] = b"hello world";
let n = assert_ok!(rd.read_until(b' '... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_until.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_read_until.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_read_until.rs:2 | chunk = b"I solve ".to_vec();
let bytes = read.read_until(b'#', &mut chunk).await.unwrap();
assert_eq!(bytes, b"Fizz\xffBuzz\n".len());
assert_eq!(chunk, b"I solve Fizz\xffBuzz#");
chunk.clear();
let bytes = read.read_until(b'#', &mut chunk).await.unwrap();
assert_eq!(bytes, 2);
assert_eq!(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_until.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_read_until.rs | 41 | 74 |
tokio-rs/tokio:tokio/tests/io_read_until.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::AsyncBufReadExt;
use tokio_test::assert_ok;
#[tokio::test]
async fn read_until() {
let mut buf = vec![];
let mut rd: &[u8] = b"hello world";
let n = assert_ok!(rd.read_until(b' ', &mut buf).await);
assert_eq!(n, 6);
assert_eq!(bu... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_until.rs | MIT | 7b4c999341809588a427a9a80d310ee4aa1c1a21 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7b4c999341809588a427a9a80d310ee4aa1c1a21/tokio/tests/io_read_until.rs | 1 | 23 |
tokio-rs/tokio:tokio/tests/io_read_until.rs:1 | #![deny(warnings, rust_2018_idioms)]
#![feature(async_await)]
use tokio::io::{AsyncBufRead, AsyncBufReadExt, AsyncRead};
use tokio_test::assert_ok;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
#[tokio::test]
async fn read_until() {
struct Rd {
val: &'static [u8],
}
impl AsyncR... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_read_until.rs | MIT | 0cfa120ba8c93822d6a84f2e7392008d84622010 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0cfa120ba8c93822d6a84f2e7392008d84622010/tokio/tests/io_read_until.rs | 1 | 56 |
tokio-rs/tokio:tokio/tests/io_repeat.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(miri)))]
use tokio::io::AsyncReadExt;
#[tokio::test]
async fn repeat_poll_read_is_cooperative() {
tokio::select! {
biased;
_ = async {
loop {
let mut buf = [0u8; 4096];
tokio::io::repeat(0b101).... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_repeat.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_repeat.rs | 1 | 18 |
tokio-rs/tokio:tokio/tests/io_repeat.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::AsyncReadExt;
#[tokio::test]
async fn repeat_poll_read_is_cooperative() {
tokio::select! {
biased;
_ = async {
loop {
let mut buf = [0u8; 4096];
tokio::io::repeat(0b101).read_exact(&mut ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_repeat.rs | MIT | 84c5674c601dfc36ab417ff0ec01763c2dd30a5c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/84c5674c601dfc36ab417ff0ec01763c2dd30a5c/tokio/tests/io_repeat.rs | 1 | 18 |
tokio-rs/tokio:tokio/tests/io_repeat.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full"))]
use tokio::io::AsyncReadExt;
#[tokio::test]
async fn repeat_poll_read_is_cooperative() {
tokio::select! {
biased;
_ = async {
loop {
let mut buf = [0u8; 4096];
tokio::io::repeat(0b101).read_exact(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_repeat.rs | MIT | 581cd41d79e3c3253490663ea854b904bf39eff0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/581cd41d79e3c3253490663ea854b904bf39eff0/tokio/tests/io_repeat.rs | 1 | 18 |
tokio-rs/tokio:tokio/tests/io_sink.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::AsyncWriteExt;
#[tokio::test]
async fn sink_poll_write_is_cooperative() {
tokio::select! {
biased;
_ = async {
loop {
let buf = vec![1, 2, 3];
tokio::io::sink().write_all(&buf).await.unw... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_sink.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_sink.rs | 1 | 44 |
tokio-rs/tokio:tokio/tests/io_sink.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full"))]
use tokio::io::AsyncWriteExt;
#[tokio::test]
async fn sink_poll_write_is_cooperative() {
tokio::select! {
biased;
_ = async {
loop {
let buf = vec![1, 2, 3];
tokio::io::sink().write_all(&buf).awai... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_sink.rs | MIT | 581cd41d79e3c3253490663ea854b904bf39eff0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/581cd41d79e3c3253490663ea854b904bf39eff0/tokio/tests/io_sink.rs | 1 | 44 |
tokio-rs/tokio:tokio/tests/io_split.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support panic recovery
use tokio::io::{
split, AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, ReadBuf, ReadHalf, WriteHalf,
};
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
struct RW;
impl ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_split.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_split.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_split.rs:2 | fn poll_write_vectored(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
_bufs: &[io::IoSlice<'_>],
) -> Poll<Result<usize, io::Error>> {
Poll::Ready(Ok(2))
}
fn is_write_vectored(&self) -> bool {
true
}
}
#[test]
fn is_send_and_sync() {
fn assert_bound<T: Send ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_split.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_split.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/io_split.rs:3 | fn unsplit_err1() {
let (r, _) = split(RW);
let (_, w) = split(RW);
r.unsplit(w);
}
#[test]
#[should_panic]
fn unsplit_err2() {
let (_, w) = split(RW);
let (r, _) = split(RW);
r.unsplit(w);
}
#[test]
fn method_delegation() {
let (mut r, mut w) = split(RW);
let mut buf = [0; 1];
to... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_split.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_split.rs | 81 | 114 |
tokio-rs/tokio:tokio/tests/io_split.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support panic recovery
use tokio::io::{
split, AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, ReadBuf, ReadHalf, WriteHalf,
};
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
struct RW;
impl ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_split.rs | MIT | 5d29bdfb0cb9e2562c662c76a362bb823f88ffd5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5d29bdfb0cb9e2562c662c76a362bb823f88ffd5/tokio/tests/io_split.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_split.rs:3 | fn unsplit_err1() {
let (r, _) = split(RW);
let (_, w) = split(RW);
r.unsplit(w);
}
#[test]
#[should_panic]
fn unsplit_err2() {
let (_, w) = split(RW);
let (r, _) = split(RW);
r.unsplit(w);
}
#[test]
fn method_delegation() {
let (mut r, mut w) = split(RW);
let mut buf = [0; 1];
to... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_split.rs | MIT | 5d29bdfb0cb9e2562c662c76a362bb823f88ffd5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5d29bdfb0cb9e2562c662c76a362bb823f88ffd5/tokio/tests/io_split.rs | 81 | 116 |
tokio-rs/tokio:tokio/tests/io_split.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support panic recovery
use tokio::io::{split, AsyncRead, AsyncWrite, ReadBuf, ReadHalf, WriteHalf};
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
struct RW;
impl AsyncRead for RW {
fn poll_read(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_split.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/io_split.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_split.rs:2 | #[test]
fn is_send_and_sync() {
fn assert_bound<T: Send + Sync>() {}
assert_bound::<ReadHalf<RW>>();
assert_bound::<WriteHalf<RW>>();
}
#[test]
fn split_stream_id() {
let (r1, w1) = split(RW);
let (r2, w2) = split(RW);
assert!(r1.is_pair_of(&w1));
assert!(!r1.is_pair_of(&w2));
assert!(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_split.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/io_split.rs | 41 | 79 |
tokio-rs/tokio:tokio/tests/io_split.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi does not support panic recovery
use tokio::io::{split, AsyncRead, AsyncWrite, ReadBuf, ReadHalf, WriteHalf};
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
struct RW;
impl AsyncRead for RW {
fn poll_read(
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_split.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/io_split.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_split.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::{split, AsyncRead, AsyncWrite, ReadBuf, ReadHalf, WriteHalf};
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
struct RW;
impl AsyncRead for RW {
fn poll_read(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_split.rs | MIT | 8198ef38814c45f9dc02fcbf826225b5cf32a6bb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8198ef38814c45f9dc02fcbf826225b5cf32a6bb/tokio/tests/io_split.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_split.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::{split, AsyncRead, AsyncWrite, ReadBuf, ReadHalf, WriteHalf};
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
struct RW;
impl AsyncRead for RW {
fn poll_read(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_split.rs | MIT | f8c91f2ead24ed6e268a820405c329032dd30da6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f8c91f2ead24ed6e268a820405c329032dd30da6/tokio/tests/io_split.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_split.rs:2 | #[test]
fn is_send_and_sync() {
fn assert_bound<T: Send + Sync>() {}
assert_bound::<ReadHalf<RW>>();
assert_bound::<WriteHalf<RW>>();
}
#[test]
fn split_stream_id() {
let (r1, w1) = split(RW);
let (r2, w2) = split(RW);
assert_eq!(r1.is_pair_of(&w1), true);
assert_eq!(r1.is_pair_of(&w2), fa... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_split.rs | MIT | f8c91f2ead24ed6e268a820405c329032dd30da6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f8c91f2ead24ed6e268a820405c329032dd30da6/tokio/tests/io_split.rs | 41 | 79 |
tokio-rs/tokio:tokio/tests/io_split.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::{split, AsyncRead, AsyncWrite, ReadBuf, ReadHalf, WriteHalf};
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
struct RW;
impl AsyncRead for RW {
fn poll_read(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_split.rs | MIT | c393236dfd12c13e82badd631d3a3a90481c6f95 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c393236dfd12c13e82badd631d3a3a90481c6f95/tokio/tests/io_split.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_split.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::{split, AsyncRead, AsyncWrite, ReadHalf, WriteHalf};
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
struct RW;
impl AsyncRead for RW {
fn poll_read(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
_buf: &mu... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_split.rs | MIT | c7719a2d2962f83854193b4c9131ee275a5a4475 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c7719a2d2962f83854193b4c9131ee275a5a4475/tokio/tests/io_split.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_split.rs:2 | fn is_send_and_sync() {
fn assert_bound<T: Send + Sync>() {}
assert_bound::<ReadHalf<RW>>();
assert_bound::<WriteHalf<RW>>();
}
#[test]
fn split_stream_id() {
let (r1, w1) = split(RW);
let (r2, w2) = split(RW);
assert_eq!(r1.is_pair_of(&w1), true);
assert_eq!(r1.is_pair_of(&w2), false);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_split.rs | MIT | c7719a2d2962f83854193b4c9131ee275a5a4475 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c7719a2d2962f83854193b4c9131ee275a5a4475/tokio/tests/io_split.rs | 41 | 78 |
tokio-rs/tokio:tokio/tests/io_split.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::{split, AsyncRead, AsyncWrite, ReadHalf, WriteHalf};
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
struct RW;
impl AsyncRead for RW {
fn poll_read(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
_buf: &mu... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_split.rs | MIT | 5bf78d77ada685826b33fd62e69df179f3de8a1c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5bf78d77ada685826b33fd62e69df179f3de8a1c/tokio/tests/io_split.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_split.rs:2 | fn is_send_and_sync() {
fn assert_bound<T: Send + Sync>() {}
assert_bound::<ReadHalf<RW>>();
assert_bound::<WriteHalf<RW>>();
}
#[test]
fn split_stream_id() {
let (r1, w1) = split(RW);
let (r2, w2) = split(RW);
assert_eq!(r1.stream_id(), w1.stream_id());
assert_eq!(r1.stream_id(), w1.strea... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_split.rs | MIT | 5bf78d77ada685826b33fd62e69df179f3de8a1c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5bf78d77ada685826b33fd62e69df179f3de8a1c/tokio/tests/io_split.rs | 41 | 78 |
tokio-rs/tokio:tokio/tests/io_split.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::{split, AsyncRead, AsyncWrite, ReadHalf, WriteHalf};
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
struct RW;
impl AsyncRead for RW {
fn poll_read(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
_buf: &mu... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_split.rs | MIT | 7b4c999341809588a427a9a80d310ee4aa1c1a21 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7b4c999341809588a427a9a80d310ee4aa1c1a21/tokio/tests/io_split.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_split.rs:2 | fn is_send_and_sync() {
fn assert_bound<T: Send + Sync>() {}
assert_bound::<ReadHalf<RW>>();
assert_bound::<WriteHalf<RW>>();
}
#[test]
fn unsplit_ok() {
let (r, w) = split(RW);
r.unsplit(w);
}
#[test]
#[should_panic]
fn unsplit_err1() {
let (r, _) = split(RW);
let (_, w) = split(RW);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_split.rs | MIT | 7b4c999341809588a427a9a80d310ee4aa1c1a21 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7b4c999341809588a427a9a80d310ee4aa1c1a21/tokio/tests/io_split.rs | 41 | 68 |
tokio-rs/tokio:tokio/tests/io_split.rs:1 | use tokio::io::{split, AsyncRead, AsyncWrite, ReadHalf, WriteHalf};
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
struct RW;
impl AsyncRead for RW {
fn poll_read(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
_buf: &mut [u8],
) -> Poll<io::Result<usize>> {
Pol... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_split.rs | MIT | 502cf5d95ca5f8559a4df35d52dc210637d613c5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/502cf5d95ca5f8559a4df35d52dc210637d613c5/tokio/tests/io_split.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_split.rs:2 | assert_bound::<ReadHalf<RW>>();
assert_bound::<WriteHalf<RW>>();
}
#[test]
fn unsplit_ok() {
let (r, w) = split(RW);
r.unsplit(w);
}
#[test]
#[should_panic]
fn unsplit_err1() {
let (r, _) = split(RW);
let (_, w) = split(RW);
r.unsplit(w);
}
#[test]
#[should_panic]
fn unsplit_err2() {
let ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_split.rs | MIT | 502cf5d95ca5f8559a4df35d52dc210637d613c5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/502cf5d95ca5f8559a4df35d52dc210637d613c5/tokio/tests/io_split.rs | 41 | 65 |
tokio-rs/tokio:tokio/tests/io_take.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support panic recovery
use std::pin::Pin;
use std::task::{Context, Poll};
use tokio::io::{self, AsyncRead, AsyncReadExt, ReadBuf};
use tokio_test::assert_ok;
mod support {
pub(crate) mod leaked_buffers;
}
use suppo... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_take.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_take.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_take.rs:2 | struct BadReader {
leaked_buffers: LeakedBuffers,
}
impl BadReader {
fn new() -> Self {
Self {
leaked_buffers: LeakedBuffers::new(),
}
}
}
impl AsyncRead for BadReader {
fn poll_read(
mut self: Pin<&mut Self>,
_cx: &mut Context<'_>,
read_buf: &mut Re... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_take.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_take.rs | 41 | 74 |
tokio-rs/tokio:tokio/tests/io_take.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support panic recovery
use std::pin::Pin;
use std::task::{Context, Poll};
use tokio::io::{self, AsyncRead, AsyncReadExt, ReadBuf};
use tokio_test::assert_ok;
mod support {
pub(crate) mod leaked_buffers;
}
use suppo... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_take.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/io_take.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_take.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi does not support panic recovery
use std::pin::Pin;
use std::task::{Context, Poll};
use tokio::io::{self, AsyncRead, AsyncReadExt, ReadBuf};
use tokio_test::assert_ok;
mod support {
pub(crate) mod leaked_buffers;
}
use support::leak... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_take.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/io_take.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_take.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use std::pin::Pin;
use std::task::{Context, Poll};
use tokio::io::{self, AsyncRead, AsyncReadExt, ReadBuf};
use tokio_test::assert_ok;
mod support {
pub(crate) mod leaked_buffers;
}
use support::leaked_buffers::LeakedBuffers;
#[tokio::test]
async fn take() {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_take.rs | MIT | 454ac1c54fa992004787c109e61bf232697d3652 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/454ac1c54fa992004787c109e61bf232697d3652/tokio/tests/io_take.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_take.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use std::pin::Pin;
use std::task::{Context, Poll};
use tokio::io::{self, AsyncRead, AsyncReadExt, ReadBuf};
use tokio_test::assert_ok;
#[tokio::test]
async fn take() {
let mut buf = [0; 6];
let rd: &[u8] = b"hello world";
let mut rd = rd.take(4);
l... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_take.rs | MIT | 59579465bee804b65a66f95c810c3ea01bb923a1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/59579465bee804b65a66f95c810c3ea01bb923a1/tokio/tests/io_take.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_take.rs:2 | self: Pin<&mut Self>,
_cx: &mut Context<'_>,
read_buf: &mut ReadBuf<'_>,
) -> Poll<io::Result<()>> {
let vec = vec![0; 10];
let mut buf = ReadBuf::new(vec.leak());
buf.put_slice(&[123; 10]);
*read_buf = buf;
Poll::Ready(Ok(()))
}
}
#[tokio::test]
#[shou... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_take.rs | MIT | 59579465bee804b65a66f95c810c3ea01bb923a1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/59579465bee804b65a66f95c810c3ea01bb923a1/tokio/tests/io_take.rs | 41 | 61 |
tokio-rs/tokio:tokio/tests/io_take.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use std::pin::Pin;
use std::task::{Context, Poll};
use tokio::io::{self, AsyncRead, AsyncReadExt, ReadBuf};
use tokio_test::assert_ok;
#[tokio::test]
async fn take() {
let mut buf = [0; 6];
let rd: &[u8] = b"hello world";
let mut rd = rd.take(4);
l... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_take.rs | MIT | 621790e1656d15cd46c971e046cbcf3a7d0d8351 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/621790e1656d15cd46c971e046cbcf3a7d0d8351/tokio/tests/io_take.rs | 1 | 44 |
tokio-rs/tokio:tokio/tests/io_take.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::AsyncReadExt;
use tokio_test::assert_ok;
#[tokio::test]
async fn take() {
let mut buf = [0; 6];
let rd: &[u8] = b"hello world";
let mut rd = rd.take(4);
let n = assert_ok!(rd.read(&mut buf).await);
assert_eq!(n, 4);
assert_eq... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_take.rs | MIT | 7b4c999341809588a427a9a80d310ee4aa1c1a21 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7b4c999341809588a427a9a80d310ee4aa1c1a21/tokio/tests/io_take.rs | 1 | 16 |
tokio-rs/tokio:tokio/tests/io_util_empty.rs:1 | #![cfg(feature = "full")]
use tokio::io::{AsyncBufReadExt, AsyncReadExt, AsyncSeekExt};
#[tokio::test]
async fn empty_read_is_cooperative() {
tokio::select! {
biased;
_ = async {
loop {
let mut buf = [0u8; 4096];
let _ = tokio::io::empty().read(&mut buf)... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_util_empty.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_util_empty.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_util_empty.rs:2 | assert!(matches!(empty.seek(SeekFrom::Start(1)).await, Ok(0)));
assert!(matches!(empty.seek(SeekFrom::Start(u64::MAX)).await, Ok(0)));
assert!(matches!(empty.seek(SeekFrom::End(i64::MIN)).await, Ok(0)));
assert!(matches!(empty.seek(SeekFrom::End(-1)).await, Ok(0)));
assert!(matches!(empty.seek(SeekFrom... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_util_empty.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_util_empty.rs | 41 | 61 |
tokio-rs/tokio:tokio/tests/io_util_empty.rs:1 | #![cfg(feature = "full")]
use tokio::io::{AsyncBufReadExt, AsyncReadExt};
#[tokio::test]
async fn empty_read_is_cooperative() {
tokio::select! {
biased;
_ = async {
loop {
let mut buf = [0u8; 4096];
let _ = tokio::io::empty().read(&mut buf).await;
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_util_empty.rs | MIT | eb1af7f29caaa1cd9e84b9fcbd87b9d62b546de3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/eb1af7f29caaa1cd9e84b9fcbd87b9d62b546de3/tokio/tests/io_util_empty.rs | 1 | 32 |
tokio-rs/tokio:tokio/tests/io_write.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::{AsyncWrite, AsyncWriteExt};
use tokio_test::assert_ok;
use bytes::BytesMut;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
#[tokio::test]
async fn write() {
struct Wr {
buf: BytesMut,
cnt: usize,
}
impl... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_write.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_write.rs | 1 | 58 |
tokio-rs/tokio:tokio/tests/io_write.rs:1 | #![warn(rust_2018_idioms)]
use tokio::io::{AsyncWrite, AsyncWriteExt};
use tokio_test::assert_ok;
use bytes::BytesMut;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
#[tokio::test]
async fn write() {
struct Wr {
buf: BytesMut,
cnt: usize,
}
impl AsyncWrite for Wr {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_write.rs | MIT | 6b35a1e8b0d53524af8d07f99cf85ae81a73ef18 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6b35a1e8b0d53524af8d07f99cf85ae81a73ef18/tokio/tests/io_write.rs | 1 | 57 |
tokio-rs/tokio:tokio/tests/io_write.rs:1 | #![deny(warnings, rust_2018_idioms)]
#![feature(async_await)]
use tokio::io::{AsyncWrite, AsyncWriteExt};
use tokio_test::assert_ok;
use bytes::BytesMut;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
#[tokio::test]
async fn write() {
struct Wr {
buf: BytesMut,
cnt: usize,
}
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_write.rs | MIT | 64343f1b786b386bb4fbd6169fc4850cce9e245a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/64343f1b786b386bb4fbd6169fc4850cce9e245a/tokio/tests/io_write.rs | 1 | 47 |
tokio-rs/tokio:tokio/tests/io_write.rs:1 | #![deny(warnings, rust_2018_idioms)]
#![feature(async_await)]
use tokio::io::{AsyncWrite, AsyncWriteExt};
use tokio_test::assert_ok;
use bytes::BytesMut;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
#[tokio::test]
async fn write() {
struct Wr(BytesMut);
impl AsyncWrite for Wr {
fn... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_write.rs | MIT | 1f47ed3dcc4b582315cdbfb195495d7d4c76d3f3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1f47ed3dcc4b582315cdbfb195495d7d4c76d3f3/tokio/tests/io_write.rs | 1 | 39 |
tokio-rs/tokio:tokio/tests/io_write.rs:1 | #![deny(warnings, rust_2018_idioms)]
use tokio::io::{AsyncWrite, AsyncWriteExt};
use tokio_test::assert_ready_ok;
use tokio_test::task::MockTask;
use bytes::BytesMut;
use pin_utils::pin_mut;
use std::future::Future;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
#[test]
fn write() {
struct Wr(By... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_write.rs | MIT | 11f6b2862fc458204aabbed9a6f919c65215aeb5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f6b2862fc458204aabbed9a6f919c65215aeb5/tokio/tests/io_write.rs | 1 | 48 |
tokio-rs/tokio:tokio/tests/io_write_all.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::{AsyncWrite, AsyncWriteExt};
use tokio_test::assert_ok;
use bytes::BytesMut;
use std::cmp;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
#[tokio::test]
async fn write_all() {
struct Wr {
buf: BytesMut,
cnt: usiz... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_write_all.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_write_all.rs | 1 | 51 |
tokio-rs/tokio:tokio/tests/io_write_all.rs:1 | #![deny(warnings, rust_2018_idioms)]
#![feature(async_await)]
use tokio::io::{AsyncWrite, AsyncWriteExt};
use tokio_test::assert_ok;
use bytes::BytesMut;
use std::cmp;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
#[tokio::test]
async fn write_all() {
struct Wr {
buf: BytesMut,
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_write_all.rs | MIT | 64343f1b786b386bb4fbd6169fc4850cce9e245a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/64343f1b786b386bb4fbd6169fc4850cce9e245a/tokio/tests/io_write_all.rs | 1 | 51 |
tokio-rs/tokio:tokio/tests/io_write_all_buf.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::{AsyncWrite, AsyncWriteExt};
use tokio_test::{assert_err, assert_ok};
use bytes::{Buf, Bytes, BytesMut};
use std::cmp;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
#[tokio::test]
async fn write_all_buf() {
struct Wr {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_write_all_buf.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_write_all_buf.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_write_all_buf.rs:2 | }
}
let mut wr = Wr {
buf: BytesMut::with_capacity(64),
cnt: 0,
};
let mut buf = Bytes::from_static(b"hello").chain(Bytes::from_static(b"world"));
assert_ok!(wr.write_all_buf(&mut buf).await);
assert_eq!(wr.buf, b"helloworld"[..]);
// expect 4 writes, [hell],[o],[worl],[d]... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_write_all_buf.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_write_all_buf.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/io_write_all_buf.rs:3 | fn poll_shutdown(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<io::Result<()>> {
Ok(()).into()
}
}
let mut wr = Wr { cnt: 0 };
let mut buf = Bytes::from_static(b"hello").chain(Bytes::from_static(b"world"));
assert_err!(wr.write_all_buf(&mut buf).await);
assert_eq!(
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_write_all_buf.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_write_all_buf.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/io_write_all_buf.rs:4 | _cx: &mut Context<'_>,
bufs: &[io::IoSlice<'_>],
) -> Poll<Result<usize, io::Error>> {
for buf in bufs {
self.buf.extend_from_slice(buf);
}
let n = self.buf.len();
Ok(n).into()
}
fn is_write_vectored(&self) -> bool {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_write_all_buf.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_write_all_buf.rs | 121 | 145 |
tokio-rs/tokio:tokio/tests/io_write_all_buf.rs:2 | }
}
let mut wr = Wr {
buf: BytesMut::with_capacity(64),
cnt: 0,
};
let mut buf = Bytes::from_static(b"hello").chain(Bytes::from_static(b"world"));
assert_ok!(wr.write_all_buf(&mut buf).await);
assert_eq!(wr.buf, b"helloworld"[..]);
// expect 4 writes, [hell],[o],[worl],[d]... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_write_all_buf.rs | MIT | 8198ef38814c45f9dc02fcbf826225b5cf32a6bb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8198ef38814c45f9dc02fcbf826225b5cf32a6bb/tokio/tests/io_write_all_buf.rs | 41 | 96 |
tokio-rs/tokio:tokio/tests/io_write_all_buf.rs:3 | fn poll_shutdown(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<io::Result<()>> {
Ok(()).into()
}
}
let mut wr = Wr { cnt: 0 };
let mut buf = Bytes::from_static(b"hello").chain(Bytes::from_static(b"world"));
assert_err!(wr.write_all_buf(&mut buf).await);
assert_eq!(
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_write_all_buf.rs | MIT | 8198ef38814c45f9dc02fcbf826225b5cf32a6bb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8198ef38814c45f9dc02fcbf826225b5cf32a6bb/tokio/tests/io_write_all_buf.rs | 81 | 96 |
tokio-rs/tokio:tokio/tests/io_write_all_buf.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::{AsyncWrite, AsyncWriteExt};
use tokio_test::{assert_err, assert_ok};
use bytes::{Buf, Bytes, BytesMut};
use std::cmp;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
#[tokio::test]
async fn write_all_buf() {
struct Wr {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_write_all_buf.rs | MIT | 14bb2f624f1ac3d440dd302219a48e9e8e926b50 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/14bb2f624f1ac3d440dd302219a48e9e8e926b50/tokio/tests/io_write_all_buf.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_write_all_buf.rs:2 | }
}
let mut wr = Wr {
buf: BytesMut::with_capacity(64),
cnt: 0,
};
let mut buf = Bytes::from_static(b"hello").chain(Bytes::from_static(b"world"));
assert_ok!(wr.write_all_buf(&mut buf).await);
assert_eq!(wr.buf, b"helloworld"[..]);
// expect 4 writes, [hell],[o],[worl],[d]... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_write_all_buf.rs | MIT | 14bb2f624f1ac3d440dd302219a48e9e8e926b50 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/14bb2f624f1ac3d440dd302219a48e9e8e926b50/tokio/tests/io_write_all_buf.rs | 41 | 96 |
tokio-rs/tokio:tokio/tests/io_write_buf.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::{AsyncWrite, AsyncWriteExt};
use tokio_test::assert_ok;
use bytes::BytesMut;
use std::cmp;
use std::io::{self, Cursor};
use std::pin::Pin;
use std::task::{Context, Poll};
#[tokio::test]
async fn write_all() {
struct Wr {
buf: BytesMut,
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_write_buf.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_write_buf.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/io_write_buf.rs:2 | Ok(()).into()
}
}
let mut wr = Wr {
buf: BytesMut::with_capacity(64),
cnt: 0,
};
let mut buf = Cursor::new(&b"hello world"[..]);
assert_ok!(wr.write_buf(&mut buf).await);
assert_eq!(wr.buf, b"hell"[..]);
assert_eq!(wr.cnt, 1);
assert_eq!(buf.position(), 4);
}
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_write_buf.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_write_buf.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/io_write_buf.rs:3 | fn poll_write_vectored(
mut self: Pin<&mut Self>,
_cx: &mut Context<'_>,
bufs: &[io::IoSlice<'_>],
) -> Poll<Result<usize, io::Error>> {
let mut n = 0;
for buf in bufs {
self.buf.extend_from_slice(buf);
n += buf.len();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_write_buf.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_write_buf.rs | 81 | 112 |
tokio-rs/tokio:tokio/tests/io_write_buf.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::{AsyncWrite, AsyncWriteExt};
use tokio_test::assert_ok;
use bytes::BytesMut;
use std::cmp;
use std::io::{self, Cursor};
use std::pin::Pin;
use std::task::{Context, Poll};
#[tokio::test]
async fn write_all() {
struct Wr {
buf: BytesMut,
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_write_buf.rs | MIT | 8dbc3c79379f2243fc04d444239d009c1c610016 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8dbc3c79379f2243fc04d444239d009c1c610016/tokio/tests/io_write_buf.rs | 1 | 56 |
tokio-rs/tokio:tokio/tests/io_write_int.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::{AsyncWrite, AsyncWriteExt};
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
#[tokio::test]
async fn write_int_should_err_if_write_count_0() {
struct Wr {}
impl AsyncWrite for Wr {
fn poll_write(
self: Pi... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/io_write_int.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/io_write_int.rs | 1 | 37 |
tokio-rs/tokio:tokio/tests/join_handle_panic.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support panic recovery
#![cfg(panic = "unwind")]
struct PanicsOnDrop;
impl Drop for PanicsOnDrop {
fn drop(&mut self) {
panic!("I told you so");
}
}
#[tokio::test]
async fn test_panics_do_not_propagate_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/join_handle_panic.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/join_handle_panic.rs | 1 | 21 |
tokio-rs/tokio:tokio/tests/join_handle_panic.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support panic recovery
struct PanicsOnDrop;
impl Drop for PanicsOnDrop {
fn drop(&mut self) {
panic!("I told you so");
}
}
#[cfg(panic = "unwind")]
#[tokio::test]
async fn test_panics_do_not_propagate_w... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/join_handle_panic.rs | MIT | d8a4a5f24bfc5012071eec4e501bb4a58a1181d6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d8a4a5f24bfc5012071eec4e501bb4a58a1181d6/tokio/tests/join_handle_panic.rs | 1 | 21 |
tokio-rs/tokio:tokio/tests/join_handle_panic.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support panic recovery
struct PanicsOnDrop;
impl Drop for PanicsOnDrop {
fn drop(&mut self) {
panic!("I told you so");
}
}
#[tokio::test]
async fn test_panics_do_not_propagate_when_dropping_join_handle(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/join_handle_panic.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/join_handle_panic.rs | 1 | 20 |
tokio-rs/tokio:tokio/tests/join_handle_panic.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi does not support panic recovery
struct PanicsOnDrop;
impl Drop for PanicsOnDrop {
fn drop(&mut self) {
panic!("I told you so");
}
}
#[tokio::test]
async fn test_panics_do_not_propagate_when_dropping_join_handle() {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/join_handle_panic.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/join_handle_panic.rs | 1 | 20 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.