Skip to content

Commit

Permalink
Add unit tests for tokio::File::AsRaw{Fd,Handle} for Unix and Windows. (
Browse files Browse the repository at this point in the history
#1890)

Supersedes #1640.
  • Loading branch information
Xinkai authored and carllerche committed Dec 3, 2019
1 parent 38c3617 commit 8a2160a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tokio/tests/fs_file.rs
Expand Up @@ -39,3 +39,23 @@ async fn basic_write() {
fn tempfile() -> NamedTempFile {
NamedTempFile::new().unwrap()
}

#[tokio::test]
#[cfg(unix)]
async fn unix_fd() {
use std::os::unix::io::AsRawFd;
let tempfile = tempfile();

let file = File::create(tempfile.path()).await.unwrap();
assert!(file.as_raw_fd() as u64 > 0);
}

#[tokio::test]
#[cfg(windows)]
async fn windows_handle() {
use std::os::windows::io::AsRawHandle;
let tempfile = tempfile();

let file = File::create(tempfile.path()).await.unwrap();
assert!(file.as_raw_handle() as u64 > 0);
}

0 comments on commit 8a2160a

Please sign in to comment.