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(target_os = "windows")]
#![warn(clippy::pedantic)]
use windows_sys::Win32::System::Diagnostics::Debug::Beep;
pub fn beep_with_hz_and_millis(hertz: u32, millis: u32) {
unsafe { Beep(hertz, millis) };
}
#[cfg(test)]
mod tests {
use windows_sys::Win32::UI::WindowsAndMessaging::{MessageBoxA, IDYES, MB_YESNO};
use crate::beep_with_hz_and_millis;
#[test]
fn confirmed_beep() {
beep_with_hz_and_millis(1000, 100);
let answer = unsafe {
MessageBoxA(
0,
"Did you hear a beep?\n\n(System sounds must not be muted.)\0".as_ptr(),
"Test\0".as_ptr(),
MB_YESNO,
)
};
assert_eq!(answer, IDYES);
}
}