1#![warn(rust_2018_idioms)]
2#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations
3#![cfg(windows)]
4
5use tokio::fs::OpenOptions;
6use windows_sys::Win32::Storage::FileSystem;
7
8#[tokio::test]
9#[cfg(windows)]
10async fn open_options_windows_access_mode() {
11 // TESTING HACK: use Debug output to check the stored data
12 assert!(format!("{:?}", OpenOptions::new().access_mode(0)).contains("access_mode: Some(0)"));
13}
14
15#[tokio::test]
16#[cfg(windows)]
17async fn open_options_windows_share_mode() {
18 // TESTING HACK: use Debug output to check the stored data
19 assert!(format!("{:?}", OpenOptions::new().share_mode(0)).contains("share_mode: 0,"));
20}
21
22#[tokio::test]
23#[cfg(windows)]
24async fn open_options_windows_custom_flags() {
25 // TESTING HACK: use Debug output to check the stored data
26 assert!(format!(
27 "{:?}",
28 OpenOptions::new().custom_flags(FileSystem::FILE_FLAG_DELETE_ON_CLOSE)
29 )
30 .contains("custom_flags: 67108864,"));
31}
32
33#[tokio::test]
34#[cfg(windows)]
35async fn open_options_windows_attributes() {
36 assert!(format!(
37 "{:?}",
38 OpenOptions::new().attributes(FileSystem::FILE_ATTRIBUTE_HIDDEN)
39 )
40 .contains("attributes: 2,"));
41}
42
43#[tokio::test]
44#[cfg(windows)]
45async fn open_options_windows_security_qos_flags() {
46 assert!(format!(
47 "{:?}",
48 OpenOptions::new().security_qos_flags(FileSystem::SECURITY_IDENTIFICATION)
49 )
50 .contains("security_qos_flags: 1114112,"));
51}
52