forked from microsoft/windows-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow
windows-result
to work on non-Windows platforms (microsoft#3082)
- Loading branch information
1 parent
421a793
commit 5bf79ff
Showing
4 changed files
with
168 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// This tests code paths in `windows-result` that are different on non-Windows platforms. | ||
#![cfg(not(windows))] | ||
|
||
use windows::core::Error; | ||
use windows::Win32::Foundation::{E_FAIL, S_OK}; | ||
|
||
#[test] | ||
fn basic_hresult() { | ||
assert!(E_FAIL.is_err()); | ||
assert!(S_OK.is_ok()); | ||
|
||
let ok_message = S_OK.message(); | ||
assert_eq!(ok_message, "0x00000000"); | ||
} | ||
|
||
#[test] | ||
fn error_message_is_not_supported() { | ||
let e = Error::new(S_OK, "this gets ignored"); | ||
let message = e.message(); | ||
assert_eq!(message, "0x00000000"); | ||
} | ||
|
||
#[test] | ||
#[should_panic] | ||
fn from_win32_panics() { | ||
// from_win32() is not implemented on non-Windows platforms. | ||
let _e = Error::from_win32(); | ||
} | ||
|
||
#[test] | ||
fn error_from_hresult() { | ||
let e = Error::from(E_FAIL); | ||
assert_eq!(e.code(), E_FAIL); | ||
} |