Merge branch 'positional-segments' into style-variables

This commit is contained in:
heyrict 2020-04-25 22:52:27 +08:00
commit 444334ad20
No known key found for this signature in database
GPG Key ID: 803E2EACED3FF3AA

View File

@ -216,7 +216,7 @@ mod tests {
use super::*;
use ansi_term::Color;
// match_next(result: Iter<Segment>, value, style)
// match_next(result: IterMut<Segment>, value, style)
macro_rules! match_next {
($iter:ident, $value:literal, $($style:tt)+) => {
let _next = $iter.next().unwrap();
@ -397,6 +397,17 @@ mod tests {
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]
fn test_parse_error() {
// brackets without escape