You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
async-std/tests/verbose_errors.rs

34 lines
1.1 KiB
Rust

#![cfg(not(target_os = "unknown"))]
use async_std::{fs, io, net::ToSocketAddrs, task};
#[test]
fn open_file() {
task::block_on(async {
let non_existing_file = "/ashjudlkahasdasdsikdhajik/asdasdasdasdasdasd/fjuiklashdbflasas";
let res = fs::File::open(non_existing_file).await;
match res {
Ok(_) => panic!("Found file with random name: We live in a simulation"),
Err(e) => assert_eq!(
"could not open `/ashjudlkahasdasdsikdhajik/asdasdasdasdasdasd/fjuiklashdbflasas`",
&format!("{}", e)
),
}
})
}
#[test]
fn resolve_address() {
task::block_on(async {
let non_existing_addr = "ashjudlkahasdasdsikdhajik.asdasdasdasdasdasd.fjuiklashdbflasas:80";
let res: Result<_, io::Error> = non_existing_addr.to_socket_addrs().await;
match res {
Ok(_) => panic!("Found address with random name: We live in a simulation"),
Err(e) => assert_eq!(
"could not resolve address `\"ashjudlkahasdasdsikdhajik.asdasdasdasdasdasd.fjuiklashdbflasas:80\"`",
&format!("{}", e)
),
}
})
}