From 7a7be84e41fced71d1b75c036cb4dbca8b11f2a3 Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Mon, 2 Nov 2026 03:10:14 +0000 Subject: [PATCH] test: pin three linked margin keys boundary and wrap merged doc comment Co-Authored-By: Claude Sonnet 5.5 --- crates/slideshow/src/settings.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/slideshow/src/settings.rs b/crates/slideshow/src/settings.rs index c17c2bba6..488819e77 100644 --- a/crates/slideshow/src/settings.rs +++ b/crates/slideshow/src/settings.rs @@ -218,8 +218,8 @@ impl SlideSettings { /// These settings with the keys `p` names changed (the others kept), validated and clamped. /// A wrong type, an unknown key or a non-finite number is an error, and nothing changes. - /// With `linkMargins` on (already, or set in `p`), a margin given sets all four (unless all four are given); `margins` - /// sets all four in any case. + /// With `linkMargins` on (already, or set in `p`), a margin given sets all four (unless all four are given); + /// `margins` sets all four in any case. pub fn merged(&self, p: &Value) -> Result { let Some(obj) = p.as_object() else { return Err("parameters must be an object".into()) }; let mut s = self.clone(); @@ -341,6 +341,14 @@ mod tests { assert_eq!(d.merged(&st.to_json()).unwrap(), st); } + #[test] + fn merge_copies_last_of_three_linked_margins() { + let d = SlideSettings::default(); + // keys are visited in key order (bottom, left, top): the last one, `marginTop`, wins + let s = d.merged(&json!({"marginLeft": 0.1, "marginTop": 0.3, "marginBottom": 0.2})).unwrap(); + assert_eq!((s.margin_left, s.margin_right, s.margin_top, s.margin_bottom), (0.3, 0.3, 0.3, 0.3)); + } + #[test] fn merge_validates_links_margins_and_round_trips() { let d = SlideSettings::default();