Add additional tests to val_or_vec
This commit is contained in:
parent
b5f436d511
commit
964aae00ff
@ -234,3 +234,31 @@ where
|
|||||||
deserialize_map,
|
deserialize_map,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
|
use matches::assert_matches;
|
||||||
|
|
||||||
|
use super::ValOrVec;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn cow_borrowed() {
|
||||||
|
let mut x = ValOrVec::Val(Cow::Borrowed("a"));
|
||||||
|
x.push(Cow::Borrowed("b"));
|
||||||
|
x.push(Cow::Borrowed("c"));
|
||||||
|
assert_matches!(x, ValOrVec::Vec(v) if v == vec!["a", "b", "c"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn cow_owned() {
|
||||||
|
let mut x = ValOrVec::Val(Cow::from("a".to_owned()));
|
||||||
|
x.push(Cow::from("b".to_owned()));
|
||||||
|
x.push(Cow::from("c".to_owned()));
|
||||||
|
assert_matches!(
|
||||||
|
x,
|
||||||
|
ValOrVec::Vec(v) if v == vec!["a".to_owned(), "b".to_owned(), "c".to_owned()]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user