mirror of
https://github.com/storytold/photocraft.git
synced 2026-11-02 06:17:22 -06: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.
20 lines
865 B
Rust
20 lines
865 B
Rust
use photocraft_color::{ColorMode, SampleType};
|
|
use photocraft_doc::{Document, LabelColor, Layer, Size};
|
|
|
|
#[test]
|
|
fn layer_labels_pcraft_roundtrip_all_colors_and_depths() {
|
|
for depth in SampleType::ALL {
|
|
let mut doc = Document::new("Labels", Size::new(2, 2), ColorMode::Rgb, depth);
|
|
for color in LabelColor::ALL {
|
|
let mut child = Layer::raster("Child", doc.pixel_format());
|
|
child.label = color;
|
|
let mut group = Layer::group(color.label(), vec![child]);
|
|
group.label = color;
|
|
doc.layers.push(group);
|
|
}
|
|
let bytes = photocraft_format::save_to_bytes(&doc, &Default::default()).unwrap();
|
|
assert_eq!(photocraft_format::load_from_bytes(&bytes).unwrap(), doc, "{depth:?}");
|
|
assert!(photocraft_format::load_from_bytes(&bytes[..bytes.len() / 2]).is_err());
|
|
}
|
|
}
|