Skip to content

Commit f214a59

Browse files
Move test into the tests.rs file
1 parent f5dfb34 commit f214a59

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

src/librustdoc/doctest.rs

-23
Original file line numberDiff line numberDiff line change
@@ -1036,29 +1036,6 @@ fn doctest_run_fn(
10361036
Ok(())
10371037
}
10381038

1039-
#[cfg(test)]
1040-
#[test]
1041-
fn check_split_args() {
1042-
fn compare(input: &str, expected: &[&str]) {
1043-
let output = split_args(input);
1044-
let expected = expected.iter().map(|s| s.to_string()).collect::<Vec<_>>();
1045-
assert_eq!(expected, output, "test failed for {input:?}");
1046-
}
1047-
1048-
compare("'a' \"b\"c", &["a", "bc"]);
1049-
compare("'a' \"b \"c d", &["a", "b c", "d"]);
1050-
compare("'a' \"b\\\"c\"", &["a", "b\"c"]);
1051-
compare("'a\"'", &["a\""]);
1052-
compare("\"a'\"", &["a'"]);
1053-
compare("\\ a", &[" a"]);
1054-
compare("\\\\", &["\\"]);
1055-
compare("a'", &["a"]);
1056-
compare("a ", &["a"]);
1057-
compare("a b", &["a", "b"]);
1058-
compare("a\n\t \rb", &["a", "b"]);
1059-
compare("a\n\t1 \rb", &["a", "1", "b"]);
1060-
}
1061-
10621039
#[cfg(test)] // used in tests
10631040
impl DocTestVisitor for Vec<usize> {
10641041
fn visit_test(&mut self, _test: String, _config: LangString, rel_line: MdRelLine) {

src/librustdoc/doctest/tests.rs

+22
Original file line numberDiff line numberDiff line change
@@ -379,3 +379,25 @@ fn main() {
379379
let (output, len) = make_test(input, None, false, &opts, None);
380380
assert_eq!((output, len), (expected, 1));
381381
}
382+
383+
#[test]
384+
fn check_split_args() {
385+
fn compare(input: &str, expected: &[&str]) {
386+
let output = super::split_args(input);
387+
let expected = expected.iter().map(|s| s.to_string()).collect::<Vec<_>>();
388+
assert_eq!(expected, output, "test failed for {input:?}");
389+
}
390+
391+
compare("'a' \"b\"c", &["a", "bc"]);
392+
compare("'a' \"b \"c d", &["a", "b c", "d"]);
393+
compare("'a' \"b\\\"c\"", &["a", "b\"c"]);
394+
compare("'a\"'", &["a\""]);
395+
compare("\"a'\"", &["a'"]);
396+
compare("\\ a", &[" a"]);
397+
compare("\\\\", &["\\"]);
398+
compare("a'", &["a"]);
399+
compare("a ", &["a"]);
400+
compare("a b", &["a", "b"]);
401+
compare("a\n\t \rb", &["a", "b"]);
402+
compare("a\n\t1 \rb", &["a", "1", "b"]);
403+
}

0 commit comments

Comments
 (0)