forked from 1b-agent/opencadstudio-upstream
style: apply cargo fmt across workspace
This commit is contained in:
1 parent
85710e5454
commit
9cf9ff2c5c
531 files changed
+57740
-33906
No files matched your search
@@ -64,10 +64,14 @@ fn empty_annotation_scales_is_not_annotative() {
|
||||
/// Walk an entity's xdict → "AcDbContextDataManager" → "ACDB_ANNOTATIONSCALES"
|
||||
/// and return its leaf handles.
|
||||
fn context_leaves(doc: &CadDocument, entity: Handle) -> Vec<Handle> {
|
||||
let Some(xd) = doc.get_entity(entity).and_then(|e| e.common().xdictionary_handle) else {
|
||||
let Some(xd) = doc
|
||||
.get_entity(entity)
|
||||
.and_then(|e| e.common().xdictionary_handle)
|
||||
else {
|
||||
return vec![];
|
||||
};
|
||||
let Some(mgr) = annotative::as_dict(doc, xd).and_then(|d| d.get("AcDbContextDataManager")) else {
|
||||
let Some(mgr) = annotative::as_dict(doc, xd).and_then(|d| d.get("AcDbContextDataManager"))
|
||||
else {
|
||||
return vec![];
|
||||
};
|
||||
let Some(coll) = annotative::as_dict(doc, mgr).and_then(|d| d.get("ACDB_ANNOTATIONSCALES"))
|
||||
@@ -156,7 +160,10 @@ fn ocs_synthesized_block_context_survives_dwg_roundtrip() {
|
||||
assert_eq!(leaves.len(), 1, "block context leaf lost");
|
||||
match doc2.objects.get(&leaves[0]) {
|
||||
Some(ObjectType::ObjectContextData(c)) => {
|
||||
assert!(matches!(c.kind, ObjectContextKind::BlkRef { .. }), "not a BLKREF context");
|
||||
assert!(
|
||||
matches!(c.kind, ObjectContextKind::BlkRef { .. }),
|
||||
"not a BLKREF context"
|
||||
);
|
||||
}
|
||||
other => panic!("leaf is not an ObjectContextData: {other:?}"),
|
||||
}
|
||||
@@ -190,14 +197,20 @@ fn object_scale_membership_add_remove_roundtrips() {
|
||||
assert_eq!(names, vec!["1:100", "1:50"], "both memberships expected");
|
||||
|
||||
// Remove one, keep the other; survives a round-trip.
|
||||
assert!(annotative::remove_annotation_context_for_scale(&mut doc, ent, s50));
|
||||
assert!(annotative::remove_annotation_context_for_scale(
|
||||
&mut doc, ent, s50
|
||||
));
|
||||
let bytes = io::save_to_bytes(&doc, "dwg", DxfVersion::AC1032).unwrap();
|
||||
let doc2 = io::load_bytes("rt.dwg", bytes).unwrap();
|
||||
let remaining: Vec<String> = annotative::object_scale_memberships(&doc2, ent)
|
||||
.into_iter()
|
||||
.map(|(n, _)| n)
|
||||
.collect();
|
||||
assert_eq!(remaining, vec!["1:100"], "exactly the un-removed scale remains");
|
||||
assert_eq!(
|
||||
remaining,
|
||||
vec!["1:100"],
|
||||
"exactly the un-removed scale remains"
|
||||
);
|
||||
|
||||
// Removing the last representation tears the chain down → non-annotative.
|
||||
let mut doc3 = doc2.clone();
|
||||
@@ -207,7 +220,9 @@ fn object_scale_membership_add_remove_roundtrips() {
|
||||
.iter()
|
||||
.find_map(|(h, o)| matches!(o, ObjectType::Scale(s) if s.name == "1:100").then_some(*h))
|
||||
.unwrap();
|
||||
assert!(annotative::remove_annotation_context_for_scale(&mut doc3, ent, s100b));
|
||||
assert!(annotative::remove_annotation_context_for_scale(
|
||||
&mut doc3, ent, s100b
|
||||
));
|
||||
assert!(
|
||||
annotative::object_scale_memberships(&doc3, ent).is_empty(),
|
||||
"no memberships after removing the last"
|
||||
|
||||
Reference in new issue
Block a user