Add test for StructuralEq for std::cmp::Ordering.

Added test in library/core/tests/cmp.rs that ensures that `const`s of type `Ordering`s can be used in patterns.
This commit is contained in:
Zachary S 2022-03-16 14:01:48 -05:00
parent ba611d55f3
commit b13b495b91

View File

@ -133,6 +133,19 @@ fn ordering_const() {
assert_eq!(THEN, Greater);
}
#[test]
fn ordering_structural_eq() {
// test that consts of type `Ordering` are usable in patterns
const ORDERING: Ordering = Greater;
const REVERSE: Ordering = ORDERING.reverse();
match Ordering::Less {
REVERSE => {}
_ => unreachable!(),
};
}
#[test]
fn cmp_default() {
// Test default methods in PartialOrd and PartialEq