rust/tests/trim_multiline.rs
2015-08-13 23:18:34 +05:30

55 lines
920 B
Rust

/// test the multiline-trim function
#[allow(plugin_as_library)]
extern crate clippy;
use clippy::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]
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));
}
#[test]
fn test_empty_line() {
assert_eq!("\
if x {
y
} else {
z
}", trim_multiline(" if x {
y
} else {
z
}".into(), false));
}