Add a test for sort_by_key

This commit is contained in:
varkor 2018-03-01 13:39:52 +00:00
parent b8452cc326
commit 9fbee359d7

View File

@ -425,6 +425,11 @@ fn test_sort() {
v.sort_by(|a, b| b.cmp(a));
assert!(v.windows(2).all(|w| w[0] >= w[1]));
// Sort in lexicographic order.
let mut v = orig.clone();
v.sort_by_key(|x| x.to_string());
assert!(v.windows(2).all(|w| w[0].to_string() <= w[1].to_string()));
// Sort with many pre-sorted runs.
let mut v = orig.clone();
v.sort();