Files
craft-libs/crates/psd/tests/it/layer_block_order.rs
Dylan M. Taylor ee78a9bd46 craft-psd: Photoshop PSD/PSB reader and writer, moved from PhotoCraft (#875)
PhotoCraft's `photocraft-psd` crate (crates/psd at storytold/photocraft
63b641b55e54bf8f5c83efd977fdb16a2c255431) as `craft-psd`: the lossless
PSD/PSB model, reader, writer and builder, descriptors, the Photoshop
resource files that share its primitives (.abr, .asl, .aco, .act, .ase,
.grd, .pat, .atn, .csh, .shc) and the Photoshop blocks of a layered TIFF.
The crate had no dependency on any other PhotoCraft crate.

Code is unchanged apart from the crate name, craft-libs' rustfmt width,
comments that named other PhotoCraft crates, issue references (now
`photocraft#N`), and the corpus tests' directory (`CRAFT_PSD_CORPUS` or
`corpus/` at the workspace root). Tests, proptests, fuzz targets and
fixtures move with it.

Part of #778, #786.
2026-11-11 17:00:33 -05:00

27 lines
1.2 KiB
Rust

//! The global layer block retains its insertion position and neighboring opaque blocks.
use craft_psd::*;
#[test]
fn global_layer_block_roundtrips_with_opaque_neighbors() {
for version in [Version::Psd, Version::Psb] {
for depth in [16, 32] {
for index in 0..=2 {
for signature in [*b"8BIM", *b"8B64"] {
let mut file = testgen::layered(version, ColorMode::Rgb, depth, Compression::Raw);
file.global_blocks = vec![TaggedBlock::new(*b"zz01", vec![7, 8, 9]), TaggedBlock::new(*b"zz02", vec![10, 11])];
file.layer_info_placement = LayerInfoPlacement::GlobalBlock {
index,
signature,
key: if depth == 16 { *b"Lr16" } else { *b"Lr32" },
padding: Some(vec![31, 32, 33]),
};
let bytes = file.to_bytes().unwrap();
let parsed = PsdFile::from_bytes(&bytes).unwrap();
assert_eq!(parsed, file, "{version:?} {depth} {index} {signature:?}");
assert_eq!(parsed.to_bytes().unwrap(), bytes);
}
}
}
}
}