1#![cfg(target_os = "windows")]
2#![warn(clippy::pedantic)]
3
4use windows_sys::Win32::System::Diagnostics::Debug::Beep;
5
6pub fn beep_with_hz_and_millis(hertz: u32, millis: u32) {
7 unsafe { Beep(hertz, millis) };
10}
11
12#[cfg(test)]
13mod tests {
14 use windows_sys::Win32::UI::WindowsAndMessaging::{MessageBoxA, IDYES, MB_YESNO};
15
16 use crate::beep_with_hz_and_millis;
17
18 #[test]
19 fn confirmed_beep() {
20 beep_with_hz_and_millis(1000, 100);
21
22 let answer = unsafe {
24 MessageBoxA(
25 0,
26 "Did you hear a beep?\n\n(System sounds must not be muted.)\0".as_ptr(),
27 "Test\0".as_ptr(),
28 MB_YESNO,
29 )
30 };
31 assert_eq!(answer, IDYES);
32 }
33}