mirror of
https://github.com/storytold/photocraft.git
synced 2026-11-21 09:26:43 +00:00
Every tests/*.rs file is its own executable that links the whole crate graph. Move each crate's test files into tests/it/ as modules of one tests/it/main.rs; helper modules under tests/common move with them. These keep their own binary (own process): - engine panic_hunt: a process-wide panic hook counts every panic. - engine text_gamma: changes the process-wide text gamma. - engine smart_filter_stages, mask_cache_purge: assert on global caches. - codecs pnm_peak_memory: reads the process's peak RSS. - photocraft mac_menu_appkit: harness = false.
25 lines
1.1 KiB
Rust
25 lines
1.1 KiB
Rust
use photocraft_engine::file_cmds::read_file_info;
|
|
|
|
#[test]
|
|
fn numeric_character_references_are_decoded() {
|
|
let xmp = "<x:xmpmeta xmlns:x=\"adobe:ns:meta/\"><rdf:RDF><rdf:Description>\
|
|
<dc:description><rdf:Alt><rdf:li xml:lang=\"x-default\">Line one
Line two © & co A &#38;</rdf:li></rdf:Alt></dc:description>\
|
|
</rdf:Description></rdf:RDF></x:xmpmeta>";
|
|
let info = read_file_info(Some(xmp));
|
|
assert_eq!(info["description"], "Line one\nLine two © & co A &");
|
|
}
|
|
|
|
/// Many `&` with no `;` near them stay literal, and are scanned a bounded distance each (a
|
|
/// multi-megabyte XMP once made this quadratic).
|
|
#[test]
|
|
fn a_long_run_of_ampersands_without_semicolons_is_left_unchanged() {
|
|
let run = "&".repeat(200_000);
|
|
let xmp = format!(
|
|
"<x:xmpmeta xmlns:x=\"adobe:ns:meta/\"><rdf:RDF><rdf:Description>\
|
|
<dc:description><rdf:Alt><rdf:li xml:lang=\"x-default\">{run}</rdf:li></rdf:Alt></dc:description>\
|
|
</rdf:Description></rdf:RDF></x:xmpmeta>"
|
|
);
|
|
let info = read_file_info(Some(&xmp));
|
|
assert_eq!(info["description"], run.as_str());
|
|
}
|