Fix the arc-length DWG round-trip test build; cargo fmt

The squash for #159 picked up an earlier revision of the #140 test, which
called as_bytes() on a Vec<u8>. Also apply rustfmt to code from #120 and #155.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Brandon ThomasandClaude Opus 5.5 committed 2026-10-10 13:04:59 -04:00
1 parent bd2412f495
commit 8fceaaff3a
3 files changed
+5 -10

No files matched your search

-1
View File
@@ -705,7 +705,6 @@ mod tests {
let _ = std::fs::remove_dir_all(&dir);
}
fn args(values: &[&str]) -> Vec<String> {
values.iter().map(|value| (*value).into()).collect()
}
+2 -3
View File
@@ -199,9 +199,8 @@ fn run_area(s: &mut Session, p: &Value) -> Result<Value> {
let mut total = (0.0, 0.0);
for (i, g) in geoms.iter().enumerate() {
let probe = polys.get(i).and_then(|p| p.first().copied());
let depth = probe.map_or(0, |pt| {
polys.iter().enumerate().filter(|(j, q)| *j != i && cadcraft_geom::point_in_polygon(q, pt)).count()
});
let depth =
probe.map_or(0, |pt| polys.iter().enumerate().filter(|(j, q)| *j != i && cadcraft_geom::point_in_polygon(q, pt)).count());
total.0 += if depth % 2 == 0 { g.area().abs() } else { -g.area().abs() };
total.1 += g.len();
}
+3 -6
View File
@@ -1265,11 +1265,8 @@ fn attdef_prompt_survives_dxf_roundtrip() {
d.add(&Space::Model, Default::default(), attdef("Enter value")).unwrap();
d.add(&Space::Model, Default::default(), attdef("")).unwrap();
let back = roundtrip(&d);
let prompts: Vec<&str> = back
.model
.iter()
.filter_map(|e| if let EntityKind::AttDef(a) = &e.kind { Some(a.prompt.as_str()) } else { None })
.collect();
let prompts: Vec<&str> =
back.model.iter().filter_map(|e| if let EntityKind::AttDef(a) = &e.kind { Some(a.prompt.as_str()) } else { None }).collect();
assert_eq!(prompts, vec!["Enter value", ""]);
}
@@ -1309,7 +1306,7 @@ fn arc_length_dimension_keeps_its_kind_and_centre_on_roundtrip() {
}
// And through DWG.
let dwg = cadcraft_dwg::dxf_to_dwg(text.as_bytes()).unwrap();
let back = read_dxf(cadcraft_dwg::dwg_to_dxf(&dwg).unwrap().as_bytes()).unwrap();
let back = read_dxf(&cadcraft_dwg::dwg_to_dxf(&dwg).unwrap()).unwrap();
let dims: Vec<_> = back.model.iter().filter_map(|e| if let EntityKind::Dimension(x) = &e.kind { Some(x.clone()) } else { None }).collect();
assert_eq!(dims.len(), 1);
assert!(matches!(dims[0].kind, DimKind::ArcLength), "{:?}", dims[0].kind);