mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-25 18:27:02 -06:00
Found while testing crates/svg/src/export.rs:138 and :143 Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
27 lines
1.1 KiB
Rust
27 lines
1.1 KiB
Rust
// Integration tests: unwrapping and panicking on failure is fine here, unlike in shipped code (AGENTS.md › Robustness).
|
||
#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
|
||
use vectorcraft_doc::Document;
|
||
use vectorcraft_svg::{ExportOptions, export, import};
|
||
|
||
#[test]
|
||
fn title_and_description_control_chars_are_filtered() {
|
||
let mut d = Document::new(200.0, 200.0);
|
||
d.title = "Poster\u{b}v2".into();
|
||
d.metadata.description = "a\u{1}b".into();
|
||
let svg = export(&d, &ExportOptions::default());
|
||
assert!(import(&svg).is_ok(), "export wrote invalid XML: {svg}");
|
||
assert!(svg.contains("<title>Poster v2</title>"));
|
||
assert!(svg.contains("<desc>ab</desc>"));
|
||
}
|
||
|
||
#[test]
|
||
fn title_and_description_markup_is_escaped() {
|
||
let mut d = Document::new(200.0, 200.0);
|
||
d.title = "A & <B>".into();
|
||
d.metadata.description = "x & y".into();
|
||
let svg = export(&d, &ExportOptions::default());
|
||
assert!(import(&svg).is_ok(), "export wrote invalid XML: {svg}");
|
||
assert!(svg.contains("<title>A & <B></title>"));
|
||
assert!(svg.contains("<desc>x & y</desc>"));
|
||
}
|