From 67553308b1c72a0e10da9dc3f22c1448f03c70a1 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Wed, 15 Feb 2023 12:31:12 -0600 Subject: [PATCH 1/2] change ~ (windows) add tests for unknown windows versions --- src/platform/windows.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/platform/windows.rs b/src/platform/windows.rs index 6b22893..6568655 100644 --- a/src/platform/windows.rs +++ b/src/platform/windows.rs @@ -724,6 +724,23 @@ fn test_known_winos_names() { winos_name(10, 0, 22621, VER_NT_WORKSTATION, VER_SUITE_PERSONAL), "Windows 11" ); + // test unmatched versions (triggers `_` matches and returns a `default_name`) + assert_eq!( + winos_name(5, 9, 3790, VER_NT_WORKSTATION, VER_SUITE_PERSONAL), + "Windows 5.9" + ); + assert_eq!( + winos_name(5, 9, 3790, VER_NT_SERVER, VER_SUITE_SMALLBUSINESS), + "Windows Server 5.9" + ); + assert_eq!( + winos_name(6, 9, 9600, VER_NT_WORKSTATION, VER_SUITE_PERSONAL), + "Windows 6.9" + ); + assert_eq!( + winos_name(6, 9, 9600, VER_NT_SERVER, VER_SUITE_SMALLBUSINESS), + "Windows Server 6.9" + ); } #[test] From dc5e8a9556c641ef99f293c1cc5cbb04cd18417d Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sat, 27 May 2023 15:24:42 -0500 Subject: [PATCH 2/2] change ~ (windows) minor comparison refactors --- src/platform/windows.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/platform/windows.rs b/src/platform/windows.rs index 6568655..5702c35 100644 --- a/src/platform/windows.rs +++ b/src/platform/windows.rs @@ -390,14 +390,14 @@ where info.wProductType = VER_NT_WORKSTATION; let mask = WinAPI_VerSetConditionMask(0, VER_SUITENAME, VER_EQUAL); - let suite_mask = if WinAPI_VerifyVersionInfoW(&info, VER_SUITENAME, mask) != 0 { + let suite_mask = if WinAPI_VerifyVersionInfoW(&info, VER_SUITENAME, mask) != FALSE { VER_SUITE_WH_SERVER } else { 0 }; let mask = WinAPI_VerSetConditionMask(0, VER_PRODUCT_TYPE, VER_EQUAL); - let product_type = if WinAPI_VerifyVersionInfoW(&info, VER_PRODUCT_TYPE, mask) != 0 { + let product_type = if WinAPI_VerifyVersionInfoW(&info, VER_PRODUCT_TYPE, mask) != FALSE { VER_NT_WORKSTATION } else { 0