Skip to content

Commit

Permalink
Fix skipping every other XData field (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
MickHarrigan authored Nov 8, 2024
1 parent b9613ed commit ee71db7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3071,6 +3071,37 @@ mod tests {
}
}

#[test]
fn read_multiple_x_data() {
let ent = read_entity(
"POLYLINE",
vec![
CodePair::new_str(1001, "Alpha"),
CodePair::new_str(1000, "a"),
CodePair::new_str(1001, "Beta"),
CodePair::new_str(1000, "b"),
CodePair::new_str(1001, "Gamma"),
CodePair::new_str(1000, "c"),
],
);
// dbg!(&ent);
assert_eq!(ent.common.x_data.len(), 3);
for (i, x) in ent.common.x_data.iter().enumerate() {
let (name, val) = match i {
0 => ("Alpha", "a"),
1 => ("Beta", "b"),
2 => ("Gamma", "c"),
_ => panic!("should only have 3 items"),
};

assert_eq!(x.application_name, name);
match x.items[0] {
XDataItem::Str(ref a) => assert_eq!(a, val),
_ => panic!("Expected a string"),
}
}
}

#[test]
fn write_x_data() {
let mut drawing = Drawing::new();
Expand Down
1 change: 1 addition & 0 deletions src/x_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ impl XData {
};
if pair.code == XDATA_APPLICATIONNAME || pair.code < XDATA_STRING {
// new xdata or non xdata
iter.put_back(Ok(pair));
break;
}
xdata.items.push(XDataItem::read_item(&pair, iter)?);
Expand Down

0 comments on commit ee71db7

Please sign in to comment.