Add a test for partition_source
This commit is contained in:
parent
1daa650d61
commit
09f05e8a86
1 changed files with 39 additions and 0 deletions
|
|
@ -1312,4 +1312,43 @@ mod tests {
|
||||||
assert_eq!(json!(TextDirection::RightToLeft), json!("rtl"));
|
assert_eq!(json!(TextDirection::RightToLeft), json!("rtl"));
|
||||||
assert_eq!(json!(TextDirection::LeftToRight), json!("ltr"));
|
assert_eq!(json!(TextDirection::LeftToRight), json!("ltr"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn partition_rust_source() {
|
||||||
|
assert_eq!(partition_source(""), ("".to_string(), "".to_string()));
|
||||||
|
assert_eq!(
|
||||||
|
partition_source("let x = 1;"),
|
||||||
|
("".to_string(), "let x = 1;\n".to_string())
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
partition_source("fn main()\n{ let x = 1; }\n"),
|
||||||
|
("".to_string(), "fn main()\n{ let x = 1; }\n".to_string())
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
partition_source("#![allow(foo)]"),
|
||||||
|
("#![allow(foo)]\n".to_string(), "".to_string())
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
partition_source("#![allow(foo)]\n"),
|
||||||
|
("#![allow(foo)]\n".to_string(), "".to_string())
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
partition_source("#![allow(foo)]\nlet x = 1;"),
|
||||||
|
("#![allow(foo)]\n".to_string(), "let x = 1;\n".to_string())
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
partition_source(
|
||||||
|
"\n\
|
||||||
|
#![allow(foo)]\n\
|
||||||
|
\n\
|
||||||
|
#![allow(bar)]\n\
|
||||||
|
\n\
|
||||||
|
let x = 1;"
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"\n#![allow(foo)]\n\n#![allow(bar)]\n\n".to_string(),
|
||||||
|
"let x = 1;\n".to_string()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue