2018-08-23 13:36:07 +00:00
|
|
|
|
2018-05-30 16:24:44 +00:00
|
|
|
|
2015-08-13 13:46:00 +00:00
|
|
|
/// test the multiline-trim function
|
2016-08-17 16:35:25 +00:00
|
|
|
extern crate clippy_lints;
|
2015-08-13 13:46:00 +00:00
|
|
|
|
2016-08-17 16:35:25 +00:00
|
|
|
use clippy_lints::utils::trim_multiline;
|
2015-08-13 13:46:00 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_single_line() {
|
|
|
|
assert_eq!("", trim_multiline("".into(), false));
|
|
|
|
assert_eq!("...", trim_multiline("...".into(), false));
|
|
|
|
assert_eq!("...", trim_multiline(" ...".into(), false));
|
|
|
|
assert_eq!("...", trim_multiline("\t...".into(), false));
|
|
|
|
assert_eq!("...", trim_multiline("\t\t...".into(), false));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2018-05-30 16:24:44 +00:00
|
|
|
#[rustfmt::skip]
|
2015-08-13 13:46:00 +00:00
|
|
|
fn test_block() {
|
|
|
|
assert_eq!("\
|
|
|
|
if x {
|
|
|
|
y
|
|
|
|
} else {
|
|
|
|
z
|
|
|
|
}", trim_multiline(" if x {
|
|
|
|
y
|
|
|
|
} else {
|
|
|
|
z
|
|
|
|
}".into(), false));
|
|
|
|
assert_eq!("\
|
|
|
|
if x {
|
|
|
|
\ty
|
|
|
|
} else {
|
|
|
|
\tz
|
|
|
|
}", trim_multiline(" if x {
|
|
|
|
\ty
|
|
|
|
} else {
|
|
|
|
\tz
|
|
|
|
}".into(), false));
|
|
|
|
}
|
2015-08-13 13:48:48 +00:00
|
|
|
|
|
|
|
#[test]
|
2018-05-30 16:24:44 +00:00
|
|
|
#[rustfmt::skip]
|
2015-08-13 13:48:48 +00:00
|
|
|
fn test_empty_line() {
|
|
|
|
assert_eq!("\
|
|
|
|
if x {
|
|
|
|
y
|
|
|
|
|
|
|
|
} else {
|
|
|
|
z
|
|
|
|
}", trim_multiline(" if x {
|
|
|
|
y
|
|
|
|
|
|
|
|
} else {
|
|
|
|
z
|
|
|
|
}".into(), false));
|
|
|
|
}
|