26 lines
537 B
Rust
26 lines
537 B
Rust
use subject_source::errors::option as opt;
|
|
|
|
#[test]
|
|
pub fn is_some() {
|
|
assert!(!opt::is_some(&None));
|
|
assert!(opt::is_some(&Some(0)));
|
|
}
|
|
|
|
#[test]
|
|
pub fn get_or_default() {
|
|
assert_eq!(opt::get_or_default(None, 1), 1);
|
|
assert_eq!(opt::get_or_default(Some(1), 1), 1);
|
|
assert_eq!(opt::get_or_default(Some(2), 1), 2);
|
|
}
|
|
|
|
#[test]
|
|
#[should_panic]
|
|
pub fn get_or_panic_none() {
|
|
let _ = std::hint::black_box(opt::get_or_panic(None));
|
|
}
|
|
|
|
#[test]
|
|
pub fn get_or_panic_some() {
|
|
assert_eq!(opt::get_or_panic(Some(1)), 1);
|
|
}
|