Add vCard X-label tests

This commit is contained in:
Maurus Decimus
2026-07-08 11:34:59 +02:00
parent 24dadff463
commit 7f9e77ae58
4 changed files with 123 additions and 0 deletions
+25
View File
@@ -324,6 +324,22 @@ fn component_top_level_properties(text: &str, name: &str) -> Vec<String> {
out
}
pub fn grouped_property_values(text: &str, name: &str) -> Vec<String> {
let unfolded = unfold_text(text);
let mut out = Vec::new();
for line in unfolded.lines() {
let l = line.trim_end_matches('\r');
let Some(colon) = l.find(':') else { continue };
let head = &l[..colon];
let name_part = head.split(';').next().unwrap_or(head);
let bare = name_part.rsplit('.').next().unwrap_or(name_part);
if bare.eq_ignore_ascii_case(name) {
out.push(l[colon + 1..].to_owned());
}
}
out
}
pub fn has_line_prefix(text: &str, prefix: &str) -> bool {
let unfolded = unfold_text(text);
unfolded.lines().any(|l| l.starts_with(prefix))
@@ -540,6 +556,15 @@ pub fn assert_contact_round_trip(conn: &Connection, source: &[u8], uid: &str, la
);
}
for label_name in ["X-ABLABEL", "X-ABDATE"] {
for value in grouped_property_values(text, label_name) {
assert!(
json_contains_string(&data, &value),
"{label}: contact {uid} {label_name} {value:?} not preserved in stored JSContact vCard roundtrip block"
);
}
}
if let Some(bday) = extract_property(text, "BDAY") {
let iso = format_vcard_date_as_iso(&bday);
let present_raw = json_contains_string(&data, &bday);