parent
bd46065c27
commit
9882b85a41
|
|
@ -341,3 +341,14 @@ fn hostile_annotation_params_never_panic() {
|
|||
let _ = cadcraft_render::build(s.doc().unwrap(), &cadcraft_doc::Space::Model, &cadcraft_render::Options::default());
|
||||
assert!(matches!(dim(&s, d).kind, DimKind::Linear { .. }));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mtext_rejects_nonpositive_height() {
|
||||
let mut s = Session::new();
|
||||
for height in [0.0, -2.0] {
|
||||
assert!(s.execute("mtext", &json!({ "at": [0, 0], "text": "hi", "height": height })).is_err(), "height {height}");
|
||||
}
|
||||
assert!(s.doc().unwrap().model.is_empty());
|
||||
s.execute("mtext", &json!({ "at": [0, 0], "text": "hi", "height": 2 })).unwrap();
|
||||
assert_eq!(s.doc().unwrap().model.len(), 1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -320,6 +320,9 @@ fn run_mtext(s: &mut Session, p: &Value) -> Result<Value> {
|
|||
let at = point_req("mtext", p, "at")?;
|
||||
let text = str_param(p, "text").ok_or_else(|| bad("mtext", "`text` is required"))?;
|
||||
let height = f64_or(p, "height", s.doc()?.header.f64("TEXTSIZE", 0.2));
|
||||
if height <= 0.0 {
|
||||
return Err(bad("mtext", "height must be positive"));
|
||||
}
|
||||
let style = s.doc()?.header.str("TEXTSTYLE", "Standard");
|
||||
let k = EntityKind::MText(MText {
|
||||
insert: v3(at),
|
||||
|
|
|
|||
Loading…
Reference in New Issue