4 fn test_compare_names() {
13 ("hello123", "hello123"),
14 ("hello123", "hello12"),
15 ("hello12", "hello123"),
16 ("hello01abc", "hello01xyz"),
17 ("hello0abc", "hello0"),
18 ("hello0", "hello0abc"),
21 assert_eq!(compare_names(a, b), a.cmp(b), "{:?} - {:?}", a, b);
23 assert_eq!(compare_names("u8", "u16"), Ordering::Less);
24 assert_eq!(compare_names("u32", "u16"), Ordering::Greater);
25 assert_eq!(compare_names("u8_to_f64", "u16_to_f64"), Ordering::Less);
26 assert_eq!(compare_names("u32_to_f64", "u16_to_f64"), Ordering::Greater);
27 assert_eq!(compare_names("u16_to_f64", "u16_to_f64"), Ordering::Equal);
28 assert_eq!(compare_names("u16_to_f32", "u16_to_f64"), Ordering::Less);
32 fn test_name_sorting() {
34 "Apple", "Banana", "Fruit", "Fruit0", "Fruit00", "Fruit01", "Fruit1", "Fruit02", "Fruit2",
35 "Fruit20", "Fruit30x", "Fruit100", "Pear",
37 let mut sorted = names.to_owned();
38 sorted.sort_by(|&l, r| compare_names(l, r));
39 assert_eq!(names, sorted);
43 fn test_all_types_prints_header_once() {
44 // Regression test for #82477
45 let all_types = AllTypes::new();
47 let mut buffer = Buffer::new();
48 all_types.print(&mut buffer);
50 assert_eq!(1, buffer.into_inner().matches("List of all items").count());