Skip to content

Commit c9fbce9

Browse files
committed
test(erd): cover escape_record_field DOT metacharacter arm
Adds a direct test exercising every DOT-record metacharacter escape arm plus the plain passthrough arm in escape_record_field. Real branch coverage of a previously test-less escaping path.
1 parent 6e99d62 commit c9fbce9

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

  • crates/vespertide-cli/src/commands/erd

crates/vespertide-cli/src/commands/erd/dot.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,18 @@ mod tests {
109109
"M:N: user_id, tag_id -> id, tenant_id"
110110
);
111111
}
112+
113+
// Covers the escape match arm of `escape_record_field`: every DOT-record
114+
// metacharacter (`\ { } | < > "`) must be backslash-escaped, while plain
115+
// chars pass through unchanged. Without a value containing these chars the
116+
// escaping arm is never exercised.
117+
#[test]
118+
fn escape_record_field_escapes_all_dot_metacharacters() {
119+
assert_eq!(
120+
escape_record_field(r#"a\b{c}d|e<f>g"h"#),
121+
r#"a\\b\{c\}d\|e\<f\>g\"h"#
122+
);
123+
// Plain text is returned unchanged (the `_ =>` arm).
124+
assert_eq!(escape_record_field("plain_name"), "plain_name");
125+
}
112126
}

0 commit comments

Comments
 (0)