rust/tests/trim_multiline.rs

56 lines
974 B
Rust
Raw Normal View History

/// test the multiline-trim function
2016-08-17 18:35:25 +02:00
extern crate clippy_lints;
2016-08-17 18:35:25 +02:00
use clippy_lints::utils::trim_multiline;
#[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]
2016-12-20 10:20:41 +01:00
#[cfg_attr(rustfmt, rustfmt_skip)]
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 15:48:48 +02:00
#[test]
2016-12-20 10:20:41 +01:00
#[cfg_attr(rustfmt, rustfmt_skip)]
2015-08-13 15:48:48 +02:00
fn test_empty_line() {
assert_eq!("\
if x {
y
} else {
z
}", trim_multiline(" if x {
y
} else {
z
}".into(), false));
}