File: verbose_errors.rs

package info (click to toggle)
rust-async-std 1.13.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,992 kB
  • sloc: sh: 13; makefile: 8
file content (33 lines) | stat: -rw-r--r-- 1,176 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#![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)
            ),
        }
    })
}