mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-10-28 12:08:46 -06:00
M6: treat imported MaxLen zero as unlimited
This commit is contained in:
@@ -2239,6 +2239,22 @@ fn page_shapes_closes_only_last_stroked_subpath_but_all_filled_subpaths() {
|
||||
assert!(filled.rules.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn zero_max_len_is_unlimited_and_overrides_inherited_limit() {
|
||||
let mut doc = fixture();
|
||||
let city = fields(&doc).into_iter().find(|f| f.name == "address.city").unwrap();
|
||||
let parent = doc.get(city.obj).as_dict().unwrap().get(b"Parent").unwrap().as_ref().unwrap();
|
||||
doc.update_dict(parent, |d| d.set(b"MaxLen".to_vec(), Object::Int(3))).unwrap();
|
||||
assert_eq!(fields(&doc).into_iter().find(|f| f.name == "address.city").unwrap().max_len, Some(3));
|
||||
doc.update_dict(city.obj, |d| d.set(b"MaxLen".to_vec(), Object::Int(0))).unwrap();
|
||||
assert_eq!(fields(&doc).into_iter().find(|f| f.name == "address.city").unwrap().max_len, None);
|
||||
set_value(&mut doc, "address.city", &FieldValue::Text("Absalom".into())).unwrap();
|
||||
let again = reopen(&doc);
|
||||
assert_eq!(field(&fields(&again), "address.city").value, ["Absalom"]);
|
||||
assert_eq!(again.get(city.obj).as_dict().unwrap().int(b"MaxLen"), Some(0), "preserve the original entry");
|
||||
assert!(set_value(&mut doc, "zip", &FieldValue::Text("123456".into())).is_err(), "positive limits still apply");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn auto_text_size_fits_single_and_multiline_text() {
|
||||
use crate::appearance::auto_text_size;
|
||||
|
||||
Reference in New Issue
Block a user