Skip to content

Commit

Permalink
Add test for StructuralEq for std::cmp::Ordering.
Browse files Browse the repository at this point in the history
Added test in library/core/tests/cmp.rs that ensures that `const`s of type `Ordering`s can be used in patterns.
  • Loading branch information
zachs18 committed Mar 16, 2022
1 parent ba611d5 commit b13b495
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions library/core/tests/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b13b495

Please sign in to comment.