aboutsummaryrefslogtreecommitdiff
path: root/mingling_core/src/program/string_vec.rs
diff options
context:
space:
mode:
Diffstat (limited to 'mingling_core/src/program/string_vec.rs')
-rw-r--r--mingling_core/src/program/string_vec.rs59
1 files changed, 59 insertions, 0 deletions
diff --git a/mingling_core/src/program/string_vec.rs b/mingling_core/src/program/string_vec.rs
index fd0e2cb..1ccedf4 100644
--- a/mingling_core/src/program/string_vec.rs
+++ b/mingling_core/src/program/string_vec.rs
@@ -55,3 +55,62 @@ impl From<Vec<&str>> for StringVec {
}
}
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn test_string_vec_from_array() {
+ let sv = StringVec::from(["a", "b", "c"]);
+ assert_eq!(sv.vec, vec!["a", "b", "c"]);
+ }
+
+ #[test]
+ fn test_string_vec_from_slice_ref() {
+ let arr = ["x", "y"];
+ let sv = StringVec::from(&arr[..]);
+ assert_eq!(sv.vec, vec!["x", "y"]);
+ }
+
+ #[test]
+ fn test_string_vec_from_vec_string() {
+ let original = vec!["one".to_string(), "two".to_string()];
+ let sv = StringVec::from(original.clone());
+ assert_eq!(sv.vec, original);
+ }
+
+ #[test]
+ fn test_string_vec_from_slice_string() {
+ let original = vec!["a".to_string(), "b".to_string()];
+ let sv = StringVec::from(&original[..]);
+ assert_eq!(sv.vec, original);
+ }
+
+ #[test]
+ fn test_string_vec_from_vec_str() {
+ let sv = StringVec::from(vec!["hello", "world"]);
+ assert_eq!(sv.vec, vec!["hello", "world"]);
+ }
+
+ #[test]
+ fn test_string_vec_deref() {
+ let sv = StringVec::from(["alpha", "beta"]);
+ let inner: &Vec<String> = &*sv;
+ assert_eq!(inner.len(), 2);
+ assert_eq!(inner[0], "alpha");
+ }
+
+ #[test]
+ fn test_string_vec_into_vec() {
+ let sv = StringVec::from(["foo", "bar"]);
+ let v: Vec<String> = sv.into();
+ assert_eq!(v, vec!["foo", "bar"]);
+ }
+
+ #[test]
+ fn test_string_vec_empty_from_empty_array() {
+ let sv = StringVec::from([] as [&str; 0]);
+ assert!(sv.vec.is_empty());
+ }
+}