]> git.lizzy.rs Git - rust.git/blob - tests/needless_continue_helpers.rs
Make cast_ptr_alignment ignore c_void
[rust.git] / tests / needless_continue_helpers.rs
1 // Tests for the various helper functions used by the needless_continue
2 // lint that don't belong in utils.
3
4 extern crate clippy_lints;
5 use clippy_lints::needless_continue::{erode_block, erode_from_back, erode_from_front};
6
7 #[test]
8 #[cfg_attr(rustfmt, rustfmt_skip)]
9 fn test_erode_from_back() {
10     let input = "\
11 {
12     let x = 5;
13     let y = format!(\"{}\", 42);
14 }";
15
16     let expected = "\
17 {
18     let x = 5;
19     let y = format!(\"{}\", 42);";
20
21     let got = erode_from_back(input);
22     assert_eq!(expected, got);
23 }
24
25 #[test]
26 #[cfg_attr(rustfmt, rustfmt_skip)]
27 fn test_erode_from_back_no_brace() {
28     let input = "\
29 let x = 5;
30 let y = something();
31 ";
32     let expected = "";
33     let got = erode_from_back(input);
34     assert_eq!(expected, got);
35 }
36
37 #[test]
38 #[cfg_attr(rustfmt, rustfmt_skip)]
39 fn test_erode_from_front() {
40     let input = "
41         {
42             something();
43             inside_a_block();
44         }
45     ";
46     let expected =
47 "            something();
48             inside_a_block();
49         }
50     ";
51     let got = erode_from_front(input);
52     println!("input: {}\nexpected:\n{}\ngot:\n{}", input, expected, got);
53     assert_eq!(expected, got);
54 }
55
56 #[test]
57 #[cfg_attr(rustfmt, rustfmt_skip)]
58 fn test_erode_from_front_no_brace() {
59     let input = "
60             something();
61             inside_a_block();
62     ";
63     let expected =
64 "something();
65             inside_a_block();
66     ";
67     let got = erode_from_front(input);
68     println!("input: {}\nexpected:\n{}\ngot:\n{}", input, expected, got);
69     assert_eq!(expected, got);
70 }
71
72 #[test]
73 #[cfg_attr(rustfmt, rustfmt_skip)]
74 fn test_erode_block() {
75
76     let input = "
77         {
78             something();
79             inside_a_block();
80         }
81     ";
82     let expected =
83 "            something();
84             inside_a_block();";
85     let got = erode_block(input);
86     println!("input: {}\nexpected:\n{}\ngot:\n{}", input, expected, got);
87     assert_eq!(expected, got);
88 }