mirror of
https://github.com/starship/starship.git
synced 2025-06-30 06:40:55 +02:00
fix: Add test for StyleVariableHolder
This commit is contained in:
@ -81,6 +81,10 @@ impl<'a> StyleVariableHolder<Cow<'a, str>> for Vec<FormatElement<'a>> {
|
||||
acc.extend(textgroup.style.get_style_variables());
|
||||
acc
|
||||
}
|
||||
FormatElement::Positional(format) => {
|
||||
acc.extend(format.get_style_variables());
|
||||
acc
|
||||
}
|
||||
_ => acc,
|
||||
})
|
||||
}
|
||||
|
@ -408,6 +408,16 @@ mod tests {
|
||||
assert_eq!(variables, expected_variables);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_style_variable_holder() {
|
||||
const FORMAT_STR: &str = "($a [($b) $c](none $s)) $d [t]($t)";
|
||||
let expected_variables = BTreeSet::from_iter(vec!["s", "t"].into_iter().map(String::from));
|
||||
|
||||
let formatter = StringFormatter::new(FORMAT_STR).unwrap().map(empty_mapper);
|
||||
let variables = formatter.get_style_variables();
|
||||
assert_eq!(variables, expected_variables);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_error() {
|
||||
// brackets without escape
|
||||
|
Reference in New Issue
Block a user