|
1 |
| -use super::{plain_text_summary, short_markdown_summary}; |
| 1 | +use super::{find_testable_code, plain_text_summary, short_markdown_summary}; |
2 | 2 | use super::{ErrorCodes, IdMap, Ignore, LangString, Markdown, MarkdownHtml};
|
3 | 3 | use rustc_span::edition::{Edition, DEFAULT_EDITION};
|
4 | 4 |
|
@@ -300,3 +300,25 @@ fn test_markdown_html_escape() {
|
300 | 300 | t("Struct<'a, T>", "<p>Struct<’a, T></p>\n");
|
301 | 301 | t("Struct<br>", "<p>Struct<br></p>\n");
|
302 | 302 | }
|
| 303 | + |
| 304 | +#[test] |
| 305 | +fn test_find_testable_code_line() { |
| 306 | + fn t(input: &str, expect: &[usize]) { |
| 307 | + impl crate::doctest::Tester for Vec<usize> { |
| 308 | + fn add_test(&mut self, _test: String, _config: LangString, line: usize) { |
| 309 | + self.push(line); |
| 310 | + } |
| 311 | + } |
| 312 | + let mut lines = Vec::<usize>::new(); |
| 313 | + find_testable_code(input, &mut lines, ErrorCodes::No, false, None); |
| 314 | + assert_eq!(lines, expect); |
| 315 | + } |
| 316 | + |
| 317 | + t("", &[]); |
| 318 | + t("```rust\n```", &[1]); |
| 319 | + t(" ```rust\n```", &[1]); |
| 320 | + t("\n```rust\n```", &[2]); |
| 321 | + t("\n ```rust\n```", &[2]); |
| 322 | + t("```rust\n```\n```rust\n```", &[1, 3]); |
| 323 | + t("```rust\n```\n ```rust\n```", &[1, 3]); |
| 324 | +} |
0 commit comments