MINSERT: test that JSON null counts and distances are taken as missing

A null rows or columns is 1 and a null rowSpacing or columnSpacing is 0,
as when the key is missing. Each count is tested null on its own; the
distances on a 2 x 2 grid, since one row or column drops its distance
anyway.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2ez4gcx
2026-11-04 23:39:33 +07:00
co-authored by Claude Opus 5.5
parent 20a9ac7433
commit 8b1adcd8d5
+8
View File
@@ -222,6 +222,14 @@ fn the_json_form_makes_the_same_grid() {
let r = s.execute("minsert", &json!({"name": "B", "at": [0, 200], "rows": 2, "rowSpacing": 15, "explode": true})).unwrap();
assert!(r["handle"].is_string(), "{r}");
assert_eq!(inserts(&s).last().map(grid), Some((1, 2, 0.0, 15.0)));
// A null count is 1 and a null distance 0, as missing ones are: each count on its own, then
// both distances with two rows and two columns (one row or column keeps no distance anyway).
s.execute("minsert", &json!({"name": "B", "at": [0, 250], "rows": null, "columns": 2, "columnSpacing": 20})).unwrap();
assert_eq!(inserts(&s).last().map(grid), Some((2, 1, 20.0, 0.0)));
s.execute("minsert", &json!({"name": "B", "at": [0, 270], "rows": 2, "columns": null, "rowSpacing": 15})).unwrap();
assert_eq!(inserts(&s).last().map(grid), Some((1, 2, 0.0, 15.0)));
s.execute("minsert", &json!({"name": "B", "at": [0, 290], "rows": 2, "columns": 2, "rowSpacing": null, "columnSpacing": null})).unwrap();
assert_eq!(inserts(&s).last().map(grid), Some((2, 2, 0.0, 0.0)));
s.execute("minsert", &json!({"name": "B", "at": [0, 300], "columns": 32767, "columnSpacing": 1})).unwrap();
assert_eq!(inserts(&s).last().map(grid), Some((32767, 1, 1.0, 0.0)));
}