added a few unit tests to trim_multiline

This commit is contained in:
llogiq 2015-08-13 15:46:00 +02:00 committed by Manish Goregaokar
parent fbbb44d93b
commit f4b5d21533
1 changed files with 38 additions and 0 deletions

38
tests/trim_multiline.rs Normal file
View File

@ -0,0 +1,38 @@
/// 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));
}