diff --git a/library/coretests/tests/cmp.rs b/library/coretests/tests/cmp.rs index 55e35a4a7250e..3a980db3e2988 100644 --- a/library/coretests/tests/cmp.rs +++ b/library/coretests/tests/cmp.rs @@ -118,6 +118,13 @@ fn test_user_defined_eq() { assert!(SketchyNum { num: 25 } != SketchyNum { num: 57 }); } +#[test] +fn test_clamp() { + assert_eq!((-3).clamp(-2, 1), -2); + assert_eq!(0.clamp(-2, 1), 0); + assert_eq!(2.clamp(-2, 1), 1); +} + #[test] fn ordering_const() { // test that the methods of `Ordering` are usable in a const context diff --git a/library/coretests/tests/option.rs b/library/coretests/tests/option.rs index fc0f82ad6bb38..0d497482868a4 100644 --- a/library/coretests/tests/option.rs +++ b/library/coretests/tests/option.rs @@ -248,6 +248,12 @@ fn test_unwrap_or_else() { */ } +#[test] +fn test_unwrap_or_default() { + assert_eq!(Some(666u32).unwrap_or_default(), 666); + assert_eq!(None::.unwrap_or_default(), 0); +} + #[test] fn test_unwrap_unchecked() { assert_eq!(unsafe { Some(1).unwrap_unchecked() }, 1); diff --git a/library/coretests/tests/result.rs b/library/coretests/tests/result.rs index 39898d5dbb76e..1f7bfecd59ba4 100644 --- a/library/coretests/tests/result.rs +++ b/library/coretests/tests/result.rs @@ -44,6 +44,18 @@ fn test_or_else() { assert_eq!(op2().or_else(|e| Err::(e)).unwrap_err(), "sadface"); } +#[test] +fn test_map_or() { + assert_eq!(op1().map_or(667, |x| x), 666); + assert_eq!(op2().map_or(666, |_| panic!()), 666); +} + +#[test] +fn test_copied() { + assert!(Ok::<&isize, isize>(&1).copied() == Ok(1)); + assert!(Err::<&isize, isize>(1).copied() == Err(1)); +} + #[test] fn test_impl_map() { assert!(Ok::(1).map(|x| x + 1) == Ok(2));