summaryrefslogtreecommitdiffstats
path: root/third_party/rust/tokio/tests/fs_open_options_windows.rs
blob: 398e6a12b36acd7128e691193170513167916fb5 (plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(tokio_wasi)))] // WASI does not support all fs operations
#![cfg(windows)]

use tokio::fs::OpenOptions;
use windows_sys::Win32::Storage::FileSystem;

#[tokio::test]
#[cfg(windows)]
async fn open_options_windows_access_mode() {
    // TESTING HACK: use Debug output to check the stored data
    assert!(format!("{:?}", OpenOptions::new().access_mode(0)).contains("access_mode: Some(0)"));
}

#[tokio::test]
#[cfg(windows)]
async fn open_options_windows_share_mode() {
    // TESTING HACK: use Debug output to check the stored data
    assert!(format!("{:?}", OpenOptions::new().share_mode(0)).contains("share_mode: 0,"));
}

#[tokio::test]
#[cfg(windows)]
async fn open_options_windows_custom_flags() {
    // TESTING HACK: use Debug output to check the stored data
    assert!(format!(
        "{:?}",
        OpenOptions::new().custom_flags(FileSystem::FILE_FLAG_DELETE_ON_CLOSE)
    )
    .contains("custom_flags: 67108864,"));
}

#[tokio::test]
#[cfg(windows)]
async fn open_options_windows_attributes() {
    assert!(format!(
        "{:?}",
        OpenOptions::new().attributes(FileSystem::FILE_ATTRIBUTE_HIDDEN)
    )
    .contains("attributes: 2,"));
}

#[tokio::test]
#[cfg(windows)]
async fn open_options_windows_security_qos_flags() {
    assert!(format!(
        "{:?}",
        OpenOptions::new().security_qos_flags(FileSystem::SECURITY_IDENTIFICATION)
    )
    .contains("security_qos_flags: 1114112,"));
}