-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b307ad6
commit fc81756
Showing
3 changed files
with
90 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,4 @@ check: | |
|
||
miri: | ||
cargo +nightly miri run --example opinions -F json | ||
cargo +nightly miri test -p merde_core |
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,35 @@ | ||
use super::FieldSlot; | ||
|
||
#[test] | ||
fn test_fieldslot_no_assign() { | ||
let mut option: Option<i32> = None; | ||
|
||
{ | ||
let slot = FieldSlot::new(&mut option); | ||
// let it drop | ||
let _ = slot; | ||
} | ||
|
||
assert!(option.is_none()); | ||
} | ||
|
||
#[test] | ||
fn test_fieldslot_with_assign() { | ||
let mut option: Option<i32> = None; | ||
|
||
{ | ||
let slot = FieldSlot::new(&mut option); | ||
slot.fill::<i32>(42); | ||
} | ||
|
||
assert_eq!(option, Some(42)); | ||
} | ||
|
||
#[test] | ||
#[should_panic(expected = "tried to assign")] | ||
fn test_fieldslot_with_assign_mismatched_type() { | ||
let mut option: Option<String> = None; | ||
|
||
let slot = FieldSlot::new(&mut option); | ||
slot.fill::<i32>(42); | ||
} |