Add test for more generic function

Also add test whether duplicated keys get ignored
This commit is contained in:
Matthias Beyer 2017-05-03 21:39:25 +02:00
parent 83ca7c8cfb
commit 18e13c999b

View file

@ -661,5 +661,36 @@ mod tests {
assert_eq!("example", names.iter().next().unwrap());
}
#[test]
fn test_get_aspect_names_for_aspect_position_arbitrary_empty() {
let config = toml_from_str(r#"
test-key = [ ]
"#).unwrap();
let names = get_aspect_names_for_aspect_position("test-key", &Some(config));
assert!(names.is_empty());
}
#[test]
fn test_get_aspect_names_for_aspect_position_arbitrary_one() {
let config = toml_from_str(r#"
test-key = [ "test-value" ]
"#).unwrap();
let names = get_aspect_names_for_aspect_position("test-key", &Some(config));
assert_eq!(1, names.len());
assert_eq!("test-value", names.iter().next().unwrap());
}
#[test]
fn test_get_aspect_names_for_aspect_position_arbitrary_duplicated() {
let config = toml_from_str(r#"
test-key = [ "test-value", "test-value" ]
"#).unwrap();
let names = get_aspect_names_for_aspect_position("test-key", &Some(config));
assert_eq!(1, names.len());
let mut iter = names.iter();
assert_eq!("test-value", iter.next().unwrap());
assert!(iter.next().is_none());
}
}