From 8c0e580363125143d5d0456a63231e93889f44b2 Mon Sep 17 00:00:00 2001 From: Denis Lisov Date: Sat, 28 Mar 2020 21:29:21 +0300 Subject: [PATCH] reorder: add test for compare_opt_ident_as_versions --- rustfmt-core/rustfmt-lib/src/reorder.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rustfmt-core/rustfmt-lib/src/reorder.rs b/rustfmt-core/rustfmt-lib/src/reorder.rs index f1ddc721c53..39094864e46 100644 --- a/rustfmt-core/rustfmt-lib/src/reorder.rs +++ b/rustfmt-core/rustfmt-lib/src/reorder.rs @@ -403,4 +403,13 @@ mod tests { strings = tail; } } + #[test] + fn test_compare_opt_ident_as_versions() { + use super::compare_opt_ident_as_versions; + use std::cmp::Ordering; + let items: &[Option<&'static str>] = &[None, Some("a"), Some("r#a"), Some("a")]; + for (p, n) in items[..items.len() - 1].iter().zip(items[1..].iter()) { + assert!(compare_opt_ident_as_versions(p, n) != Ordering::Greater); + } + } }