mirror of
https://github.com/starship/starship.git
synced 2025-01-12 09:28:15 +01:00
test: Add tests for VariableHolder
This commit is contained in:
parent
e7dd987fd7
commit
9796a66a96
@ -177,7 +177,7 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use ansi_term::Color;
|
use ansi_term::Color;
|
||||||
|
|
||||||
// match_next(result: Iter<Segment>, value, style)
|
// match_next(result: IterMut<Segment>, value, style)
|
||||||
macro_rules! match_next {
|
macro_rules! match_next {
|
||||||
($iter:ident, $value:literal, $($style:tt)+) => {
|
($iter:ident, $value:literal, $($style:tt)+) => {
|
||||||
let _next = $iter.next().unwrap();
|
let _next = $iter.next().unwrap();
|
||||||
@ -342,6 +342,17 @@ mod tests {
|
|||||||
match_next!(result_iter, "$some", None);
|
match_next!(result_iter, "$some", None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_variable_holder() {
|
||||||
|
const FORMAT_STR: &str = "($a [($b) $c](none $s)) $d [t]($t)";
|
||||||
|
let expected_variables =
|
||||||
|
BTreeSet::from_iter(vec!["a", "b", "c", "d"].into_iter().map(String::from));
|
||||||
|
|
||||||
|
let formatter = StringFormatter::new(FORMAT_STR).unwrap().map(empty_mapper);
|
||||||
|
let variables = formatter.get_variables();
|
||||||
|
assert_eq!(variables, expected_variables);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_error() {
|
fn test_parse_error() {
|
||||||
// brackets without escape
|
// brackets without escape
|
||||||
|
Loading…
Reference in New Issue
Block a user