|
1 | 1 | use super::{make_test, TestOptions};
|
| 2 | +use expect_test::expect_file; |
2 | 3 | use rustc_span::edition::DEFAULT_EDITION;
|
3 | 4 |
|
4 | 5 | #[test]
|
@@ -277,3 +278,26 @@ test_wrapper! {
|
277 | 278 | let output = make_test(input, Some("my_crate"), false, &opts, DEFAULT_EDITION);
|
278 | 279 | assert_eq!(output, (expected, 1));
|
279 | 280 | }
|
| 281 | + |
| 282 | +#[test] |
| 283 | +fn test_html_highlighting() { |
| 284 | + let src = include_str!("fixtures/sample.rs"); |
| 285 | + let html = { |
| 286 | + let mut out = String::new(); |
| 287 | + crate::html::highlight::write_code(&mut out, src); |
| 288 | + format!("{}<pre><code>{}</code></pre>\n", STYLE, out) |
| 289 | + }; |
| 290 | + expect_file!["src/librustdoc/test/fixtures/sample.html"].assert_eq(&html); |
| 291 | + |
| 292 | + const STYLE: &str = r#" |
| 293 | +<style> |
| 294 | +.kw { color: #8959A8; } |
| 295 | +.kw-2, .prelude-ty { color: #4271AE; } |
| 296 | +.number, .string { color: #718C00; } |
| 297 | +.self, .bool-val, .prelude-val, .attribute, .attribute .ident { color: #C82829; } |
| 298 | +.macro, .macro-nonterminal { color: #3E999F; } |
| 299 | +.lifetime { color: #B76514; } |
| 300 | +.question-mark { color: #ff9011; } |
| 301 | +</style> |
| 302 | +"#; |
| 303 | +} |
0 commit comments