1
1
//! Tests for crashes in the loading stage.
2
//!
3
//! Ensures that loading and parsing (but not rendering) a particular
4
//! SVG doesn't crash.
5

            
6
use rsvg::Loader;
7

            
8
use std::path::PathBuf;
9

            
10
24
fn loading_crash(filename: &str) {
11
24
    let mut full_filename = PathBuf::new();
12
24
    full_filename.push("tests/fixtures/crash");
13
24
    full_filename.push(filename);
14

            
15
    // We just test for crashes during loading, and don't care about success/error.
16
24
    let _ = Loader::new().read_path(&full_filename);
17
24
}
18

            
19
macro_rules! t {
20
    ($test_name:ident, $filename:expr) => {
21
        #[test]
22
48
        fn $test_name() {
23
24
            loading_crash($filename);
24
48
        }
25
    };
26
}
27

            
28
#[rustfmt::skip]
29
mod tests {
30
    use super::*;
31

            
32
    t!(bug335_non_svg_toplevel_svg,                  "bug335-non-svg-toplevel.svg");
33
    t!(bug336_invalid_css_svg,                       "bug336-invalid-css.svg");
34
    t!(bug349_empty_data_uri_svg,                    "bug349-empty-data-uri.svg");
35
    t!(bug349_too_big_image_in_href_data_svg,        "bug349-too-big-image-in-href-data.svg");
36
    t!(bug352_feconvolvematrix_large_allocation_svg, "bug352-feConvolveMatrix-large-allocation.svg");
37
    t!(bug377_xinclude_invalid_xml_svg,              "bug377-xinclude-invalid-xml.svg");
38
    t!(bug463_characters_outside_first_element_svg,  "bug463-characters-outside-first-element.svg");
39
    t!(bug467_xinclude_without_parent_element_svg,   "bug467-xinclude-without-parent-element.svg");
40
    t!(bug524_invalid_stylesheet_href_svg,           "bug524-invalid-stylesheet-href.svg");
41
    t!(bug942_xinclude_recursion_svg,                "bug942-xinclude-recursion.svg");
42
    t!(bug942_xinclude_mutual_recursion_svg,         "bug942-xinclude-mutual-recursion.svg");
43
    t!(bug620238_svg,                                "bug620238.svg");
44
    t!(bug759084_svg,                                "bug759084.svg");
45
    t!(bug785276_empty_svg,                          "bug785276-empty.svg");
46
    t!(bug785276_short_file_svg,                     "bug785276-short-file.svg");
47
    t!(bug800_font_inherit_svg,                      "bug800-font-inherit.svg");
48
    t!(bug800_marker_svg,                            "bug800-marker.svg");
49
    t!(bug1064_private_lang_tag_in_lang_selector,    "bug1064-private-lang-tag-in-lang-selector.svg");
50
    t!(feconvolvematrix_empty_kernel_svg,            "feConvolveMatrix-empty-kernel.svg");
51
    t!(marker_cycles_svg,                            "marker-cycles.svg");
52
    t!(mask_cycles_svg,                              "mask-cycles.svg");
53
    t!(pattern_fallback_cycles_svg,                  "pattern-fallback-cycles.svg");
54
    t!(xinclude_text_xml_svg,                        "xinclude-text-xml.svg");
55
    t!(xml_pi_without_data_svg,                      "xml-pi-without-data.svg");
56
}