Skip to content

Commit f8c7e35

Browse files
committed
add fuzz tests
1 parent c077f1d commit f8c7e35

File tree

9 files changed

+316
-5
lines changed

9 files changed

+316
-5
lines changed

Cargo.lock

Lines changed: 215 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,9 @@ html2rdf = { path = "html2rdf" }
1717
oxiri = "0.2.11"
1818
oxrdf = "0.3.3"
1919
oxttl = "0.2.3"
20+
21+
[profile.fuzz]
22+
inherits = "dev"
23+
opt-level = 3
24+
incremental = false
25+
codegen-units = 1

html2rdf/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,12 @@ scraper = "0.25.0"
3636
tracing = "0.1.44"
3737

3838
[dev-dependencies]
39+
bolero = "0.13.4"
3940
insta = { version = "1.46.3", features = ["glob"] }
4041
oxrdf = { workspace = true, features = ["rdfc-10"] }
4142
oxttl = { workspace = true }
4243
pretty_assertions = "1.4.1"
44+
pyo3 = "0.28.2"
4345
rstest = { version = "0.26.1", default-features = false, features = [
4446
"crate-name",
4547
] }

html2rdf/tests/edge-cases.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,44 @@ fn blank_node_datatype_treated_as_missing() {
3535
<> <val> "42" .
3636
"#);
3737
}
38+
39+
#[test]
40+
fn typeof_on_root_empty_about() {
41+
let html = r#"
42+
<html about="" typeof="foaf:Person" rel="foaf:knows">
43+
<head><title>test</title></head>
44+
<body>
45+
<span property="http://example.test/val">42</span>
46+
</body>
47+
</html>"#;
48+
49+
let (output, _processor) = parse_html(html);
50+
insta::assert_snapshot!(utils::serialize_graph(output, base().as_str()), @r#"
51+
@base <http://example.test/> .
52+
@prefix rdf: <//www.w3.org/1999/02/22-rdf-syntax-ns#> .
53+
@prefix foaf: <//xmlns.com/foaf/0.1/> .
54+
<> a foaf:Person ;
55+
foaf:knows _:c14n0 .
56+
_:c14n0 <val> "42" .
57+
"#);
58+
}
59+
60+
#[test]
61+
fn typeof_on_root_no_about() {
62+
let html = r#"
63+
<html typeof="foaf:Person" rel="foaf:knows">
64+
<body>
65+
<span property="http://example.test/val">42</span>
66+
</body>
67+
</html>"#;
68+
69+
let (output, _processor) = parse_html(html);
70+
insta::assert_snapshot!(utils::serialize_graph(output, base().as_str()), @r#"
71+
@base <http://example.test/> .
72+
@prefix rdf: <//www.w3.org/1999/02/22-rdf-syntax-ns#> .
73+
@prefix foaf: <//xmlns.com/foaf/0.1/> .
74+
<> foaf:knows _:c14n0 .
75+
_:c14n0 a foaf:Person ;
76+
<val> "42" .
77+
"#);
78+
}

0 commit comments

Comments
 (0)