diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2024-12-20 15:14:08 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2024-12-20 22:35:00 +0100 |
| commit | bc03e40a29574c18ebfc04bd179065815ebe83f8 (patch) | |
| tree | 865ddeccb0a2b29fcf217ac2c167a16b79f14757 | |
| parent | 55653a5178c07a0a854066e79062de4c585561a5 (diff) | |
| download | rust-bc03e40a29574c18ebfc04bd179065815ebe83f8.tar.gz rust-bc03e40a29574c18ebfc04bd179065815ebe83f8.zip | |
Move test into the `tests.rs` file
| -rw-r--r-- | src/librustdoc/doctest.rs | 23 | ||||
| -rw-r--r-- | src/librustdoc/doctest/tests.rs | 22 |
2 files changed, 22 insertions, 23 deletions
diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index a93e2f92718..e6e5123d0bb 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -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) { diff --git a/src/librustdoc/doctest/tests.rs b/src/librustdoc/doctest/tests.rs index 160d0f222b4..fa6cca3681b 100644 --- a/src/librustdoc/doctest/tests.rs +++ b/src/librustdoc/doctest/tests.rs @@ -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"]); +} |
