diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
commit | 698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch) | |
tree | 173a775858bd501c378080a10dca74132f05bc50 /src/librustdoc/theme | |
parent | Initial commit. (diff) | |
download | rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip |
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/librustdoc/theme')
-rw-r--r-- | src/librustdoc/theme/tests.rs | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/src/librustdoc/theme/tests.rs b/src/librustdoc/theme/tests.rs new file mode 100644 index 000000000..ae8f43c6d --- /dev/null +++ b/src/librustdoc/theme/tests.rs @@ -0,0 +1,117 @@ +use super::*; + +#[test] +fn test_comments_in_rules() { + let text = r#" +rule a {} + +rule b, c +// a line comment +{} + +rule d +// another line comment +e {} + +rule f/* a multine + +comment*/{} + +rule g/* another multine + +comment*/h + +i {} + +rule j/*commeeeeent + +you like things like "{}" in there? :) +*/ +end {}"#; + + let against = r#" +rule a {} + +rule b, c {} + +rule d e {} + +rule f {} + +rule gh i {} + +rule j end {} +"#; + + let mut ret = Vec::new(); + get_differences( + &load_css_paths(against.as_bytes()), + &load_css_paths(text.as_bytes()), + &mut ret, + ); + assert!(ret.is_empty()); +} + +#[test] +fn test_text() { + let text = r#" +a +/* sdfs +*/ b +c // sdf +d {} +"#; + let paths = load_css_paths(text.as_bytes()); + assert!(paths.children.contains(&CssPath::new("a b c d".to_owned()))); +} + +#[test] +fn test_comparison() { + let x = r#" +a { + b { + c {} + } +} +"#; + + let y = r#" +a { + b {} +} +"#; + + let against = load_css_paths(y.as_bytes()); + let other = load_css_paths(x.as_bytes()); + + let mut ret = Vec::new(); + get_differences(&against, &other, &mut ret); + assert!(ret.is_empty()); + get_differences(&other, &against, &mut ret); + assert_eq!(ret, vec![" Missing \"c\" rule".to_owned()]); +} + +#[test] +fn check_empty_css() { + let events = load_css_events(&[]); + assert_eq!(events.len(), 0); +} + +#[test] +fn check_invalid_css() { + let events = load_css_events(b"*"); + assert_eq!(events.len(), 0); +} + +#[test] +fn test_with_minification() { + let text = include_str!("../html/static/css/themes/dark.css"); + let minified = minifier::css::minify(&text).expect("CSS minification failed").to_string(); + + let against = load_css_paths(text.as_bytes()); + let other = load_css_paths(minified.as_bytes()); + + let mut ret = Vec::new(); + get_differences(&against, &other, &mut ret); + assert!(ret.is_empty()); +} |