compare_properties horizontal rule.

This commit is contained in:
Tom Alexander 2023-10-10 01:29:00 -04:00
parent e40e3ff553
commit fc104680eb
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -2384,23 +2384,39 @@ fn compare_fixed_width_area<'b, 's>(
} }
fn compare_horizontal_rule<'b, 's>( fn compare_horizontal_rule<'b, 's>(
_source: &'s str, source: &'s str,
emacs: &'b Token<'s>, emacs: &'b Token<'s>,
rust: &'b HorizontalRule<'s>, rust: &'b HorizontalRule<'s>,
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> { ) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
let child_status = Vec::new();
let mut this_status = DiffStatus::Good; let mut this_status = DiffStatus::Good;
let mut child_status = Vec::new();
let mut message = None; let mut message = None;
// TODO: Compare :caption assert_no_children(emacs, &mut this_status, &mut message)?;
// Compare name
let name = get_property_quoted_string(emacs, ":name")?; for diff in compare_properties!(
if name.as_ref().map(String::as_str) != rust.name { source,
this_status = DiffStatus::Bad; emacs,
message = Some(format!( rust,
"Name mismatch (emacs != rust) {:?} != {:?}", (
name, rust.name EmacsField::Optional(":name"),
)); |r| r.name,
compare_property_quoted_string
),
(
EmacsField::Optional(":caption"),
compare_identity,
compare_noop
)
) {
match diff {
ComparePropertiesResult::NoChange => {}
ComparePropertiesResult::SelfChange(new_status, new_message) => {
this_status = new_status;
message = new_message
}
ComparePropertiesResult::DiffEntry(diff_entry) => child_status.push(diff_entry),
}
} }
Ok(DiffResult { Ok(DiffResult {