mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-01 07:13:24 +03:00
Move test into the tests.rs file
This commit is contained in:
@@ -1036,29 +1036,6 @@ fn doctest_run_fn(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[test]
|
||||
fn check_split_args() {
|
||||
fn compare(input: &str, expected: &[&str]) {
|
||||
let output = split_args(input);
|
||||
let expected = expected.iter().map(|s| s.to_string()).collect::<Vec<_>>();
|
||||
assert_eq!(expected, output, "test failed for {input:?}");
|
||||
}
|
||||
|
||||
compare("'a' \"b\"c", &["a", "bc"]);
|
||||
compare("'a' \"b \"c d", &["a", "b c", "d"]);
|
||||
compare("'a' \"b\\\"c\"", &["a", "b\"c"]);
|
||||
compare("'a\"'", &["a\""]);
|
||||
compare("\"a'\"", &["a'"]);
|
||||
compare("\\ a", &[" a"]);
|
||||
compare("\\\\", &["\\"]);
|
||||
compare("a'", &["a"]);
|
||||
compare("a ", &["a"]);
|
||||
compare("a b", &["a", "b"]);
|
||||
compare("a\n\t \rb", &["a", "b"]);
|
||||
compare("a\n\t1 \rb", &["a", "1", "b"]);
|
||||
}
|
||||
|
||||
#[cfg(test)] // used in tests
|
||||
impl DocTestVisitor for Vec<usize> {
|
||||
fn visit_test(&mut self, _test: String, _config: LangString, rel_line: MdRelLine) {
|
||||
|
||||
@@ -379,3 +379,25 @@ fn main() {
|
||||
let (output, len) = make_test(input, None, false, &opts, None);
|
||||
assert_eq!((output, len), (expected, 1));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn check_split_args() {
|
||||
fn compare(input: &str, expected: &[&str]) {
|
||||
let output = super::split_args(input);
|
||||
let expected = expected.iter().map(|s| s.to_string()).collect::<Vec<_>>();
|
||||
assert_eq!(expected, output, "test failed for {input:?}");
|
||||
}
|
||||
|
||||
compare("'a' \"b\"c", &["a", "bc"]);
|
||||
compare("'a' \"b \"c d", &["a", "b c", "d"]);
|
||||
compare("'a' \"b\\\"c\"", &["a", "b\"c"]);
|
||||
compare("'a\"'", &["a\""]);
|
||||
compare("\"a'\"", &["a'"]);
|
||||
compare("\\ a", &[" a"]);
|
||||
compare("\\\\", &["\\"]);
|
||||
compare("a'", &["a"]);
|
||||
compare("a ", &["a"]);
|
||||
compare("a b", &["a", "b"]);
|
||||
compare("a\n\t \rb", &["a", "b"]);
|
||||
compare("a\n\t1 \rb", &["a", "1", "b"]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user