-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
Trying to mock an unsafe function results in an error. Is there any particular reason my unsafe function cannot be mocked?
Minimal test:
unsafe fn count() -> i32 {
1
}
#[test]
fn unsafe_test() {
unsafe {
count.mock_raw(|| MockResult::Return(0));
assert_eq!(0, count());
}
}
Output:
error[E0599]: no method named `mock_raw` found for type `unsafe fn() -> i32 {test::count}` in the current scope
--> src\example.rs:10:23
|
| count.mock_raw(|| MockResult::Return(0));
| ^^^^^^^^
|
= note: count is a function, perhaps you wish to call it
= note: the method `mock_raw` exists but the following trait bounds were not satisfied:
`unsafe fn() -> i32 {test::count} : mocktopus::mocking::Mockable<_, _>`
Metadata
Metadata
Assignees
Labels
No labels