mirror of
https://github.com/storytold/deckcraft.git
synced 2026-10-26 03:27:03 -06:00
Fix up merged PRs: no debug_assert in blank_presentation; more exhaustion coverage
blank_presentation's debug_assert would panic in debug builds (never-crash rule): a fresh deck that cannot fit its title slide now simply arrives without it. The exhaustion test also covers insert.smartArt and insert.textBox. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
67e1ab6373
commit
c79416be4c
@@ -3469,6 +3469,8 @@ fn an_exhausted_id_space_refuses_growth() {
|
||||
assert!(s.execute("shape.insert", &json!({"preset": "rect", "rect": [10, 10, 100, 50]})).is_err());
|
||||
assert!(s.execute("slide.duplicate", &json!({})).is_err());
|
||||
assert!(s.execute("edit.duplicate", &json!({})).is_err());
|
||||
assert!(s.execute("insert.smartArt", &json!({"kind": "blockList", "items": ["Plan", "Build"]})).is_err());
|
||||
assert!(s.execute("insert.textBox", &json!({"text": "Hi"})).is_err());
|
||||
// What the deck holds is untouched: same slides, same ids, no duplicates.
|
||||
let after = s.doc().unwrap().doc.clone();
|
||||
assert_eq!(after.slides.len(), before.slides.len());
|
||||
|
||||
@@ -522,9 +522,9 @@ pub fn blank_presentation(size: Size, theme: Theme, title_slide: bool) -> Presen
|
||||
// A fresh deck starts at id 256 and this builds a handful of ids, so the slide always
|
||||
// fits; should that ever stop holding, the deck arrives without its title slide rather
|
||||
// than with a duplicated id.
|
||||
let s = new_slide(&mut p, first_layout);
|
||||
debug_assert!(s.is_some(), "a fresh deck cannot run out of ids");
|
||||
p.slides.extend(s.map(|s| vec![Arc::new(s)]).unwrap_or_default());
|
||||
if let Some(s) = new_slide(&mut p, first_layout) {
|
||||
p.slides.push(Arc::new(s));
|
||||
}
|
||||
}
|
||||
p
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user