From 0f6b37a33dfe9c9ef3fb86d74924112b73af14df Mon Sep 17 00:00:00 2001 From: Geordie Roscoe Date: Sat, 24 Feb 2024 22:47:59 -0800 Subject: [PATCH] Fix crossplatform mapping for Windows --- src/windows.rs | 8 ++++---- tests/windows.rs | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/windows.rs b/src/windows.rs index b131a66..5e1a6d6 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -77,10 +77,10 @@ impl std::convert::TryFrom for WinAPIThreadPriority { ThreadPriority::Crossplatform(crate::ThreadPriorityValue(p)) => match p { 0 => WinAPIThreadPriority::Idle, 1..=19 => WinAPIThreadPriority::Lowest, - 21..=39 => WinAPIThreadPriority::BelowNormal, - 41..=59 => WinAPIThreadPriority::Normal, - 61..=79 => WinAPIThreadPriority::AboveNormal, - 81..=98 => WinAPIThreadPriority::Highest, + 20..=39 => WinAPIThreadPriority::BelowNormal, + 40..=59 => WinAPIThreadPriority::Normal, + 60..=79 => WinAPIThreadPriority::AboveNormal, + 80..=98 => WinAPIThreadPriority::Highest, 99 => WinAPIThreadPriority::TimeCritical, _ => return Err(Error::Priority("The value is out of range [0; 99].")), }, diff --git a/tests/windows.rs b/tests/windows.rs index 62abb2f..cff6d0d 100644 --- a/tests/windows.rs +++ b/tests/windows.rs @@ -6,6 +6,7 @@ use thread_priority::*; #[rstest] #[case(ThreadPriority::Min, ThreadPriority::Os(WinAPIThreadPriority::Lowest.try_into().unwrap()))] #[case(ThreadPriority::Crossplatform(23u8.try_into().unwrap()), ThreadPriority::Os(WinAPIThreadPriority::BelowNormal.try_into().unwrap()))] +#[case(ThreadPriority::Crossplatform(80u8.try_into().unwrap()), ThreadPriority::Os(WinAPIThreadPriority::Highest.try_into().unwrap()))] #[case(ThreadPriority::Max, ThreadPriority::Os(WinAPIThreadPriority::Highest.try_into().unwrap()))] fn get_and_set_priority_requires_capabilities( #[case] input_priority: ThreadPriority,