]> git.proxmox.com Git - rustc.git/blame - vendor/pulldown-cmark/tests/errors.rs
New upstream version 1.64.0+dfsg1
[rustc.git] / vendor / pulldown-cmark / tests / errors.rs
CommitLineData
064997fb 1use pulldown_cmark::{Options, Parser};
a2a8927a
XL
2
3fn parse(md: &str) {
4 let parser = Parser::new(md);
5
6 for _ in parser {}
7}
8
064997fb
FG
9fn parse_all_options(md: &str) {
10 let parser = Parser::new_ext(md, Options::all());
11
12 for _ in parser {}
13}
14
a2a8927a
XL
15#[test]
16fn test_lists_inside_code_spans() {
17 parse(
18 r"- `
19x
20**
21 *
22 `",
23 );
24}
1b1a35ee 25
064997fb
FG
26#[test]
27fn test_fuzzer_input_1() {
28 parse(">\n >>><N\n");
29}
30
31#[test]
32fn test_fuzzer_input_2() {
33 parse(" \u{b}\\\r- ");
34}
35
36#[test]
37fn test_fuzzer_input_3() {
38 parse_all_options("\n # #\r\u{1c} ");
39}
40
41#[test]
42fn test_fuzzer_input_4() {
43 parse_all_options("\u{0}{\tϐ}\n-");
44}
45
46#[test]
47fn test_fuzzer_input_5() {
48 parse_all_options(" \u{c}{}\n-\n");
49}
50
51#[test]
52fn test_fuzzer_input_6() {
53 parse("*\t[][\n\t<p]>\n\t[]");
54}
55
56#[test]
57fn test_fuzzer_input_7() {
58 parse_all_options("[][{]}\n-");
59}
60
61#[test]
62fn test_fuzzer_input_8() {
63 parse_all_options("a\n \u{c}{}\n-");
64}
65
66#[test]
67fn test_fuzzer_input_9() {
68 parse_all_options("a\n \u{c}{}\\\n-");
69}
70
71#[test]
72fn test_fuzzer_input_10() {
73 parse_all_options("[[ \t\n \u{c}\u{c}\u{c}\u{c}\u{c} {}\n-\r\u{e}\u{0}\u{0}{# }\n\u{b}\u{b}\u{b}\u{b}\u{b}\u{b}\u{b}\u{b}\u{b}\u{b}\u{0}\u{0}");
74}
75
76#[test]
77fn test_fuzzer_input_11() {
78 parse_all_options(
79 "[[\u{c}\u{c} \t\n \u{c}\u{c}\u{c}\u{c}\u{c}\u{c}\u{c}\u{c}\u{c} {}\n-\r\u{e}",
80 );
81}
82
83#[test]
84fn test_fuzzer_input_12() {
85 parse_all_options("\u{c}-\n\u{c}\n-");
86}
87
1b1a35ee
XL
88#[test]
89fn test_wrong_code_block() {
a2a8927a
XL
90 parse(
91 r##"```
1b1a35ee 92 * ```
a2a8927a
XL
93 "##,
94 );
1b1a35ee
XL
95}
96
97#[test]
98fn test_unterminated_link() {
a2a8927a 99 parse("[](\\");
1b1a35ee
XL
100}
101
102#[test]
103fn test_unterminated_autolink() {
a2a8927a 104 parse("<a");
1b1a35ee
XL
105}
106
107#[test]
108fn test_infinite_loop() {
a2a8927a 109 parse("[<!W\n\\\n");
1b1a35ee
XL
110}
111
112#[test]
113fn test_html_tag() {
a2a8927a
XL
114 parse("<script\u{feff}");
115}
1b1a35ee 116
a2a8927a
XL
117// all of test_bad_slice_* were found in https://github.com/raphlinus/pulldown-cmark/issues/521
118#[test]
119fn test_bad_slice_a() {
120 parse("><a\n");
121}
122
123#[test]
124fn test_bad_slice_b() {
125 parse("><a a\n");
126}
127
128#[test]
129fn test_bad_slice_unicode() {
130 parse("><a a=\n毿>")
1b1a35ee 131}