From 8ca28ff4a66bb6046c010f30acbfb450f47e43b8 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 821d286a5a0..12da4331e6f 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); + } + } }