feat: added support for lists

This commit is contained in:
darwincereska
2026-06-08 05:39:49 -04:00
parent 849eb9d62a
commit 5743c0b490
6 changed files with 60 additions and 14 deletions
+15
View File
@@ -2,6 +2,7 @@
mod test_parser {
use envkit::parser::parse_bool;
use envkit::parser::parse_number;
use envkit::parser::parse_list;
#[test]
/// Tests for the `parse_bool` function.
@@ -34,4 +35,18 @@ mod test_parser {
assert_eq!(parse_number::<f32>("42"), Ok(42_f32));
assert_eq!(parse_number::<f64>("42"), Ok(42_f64));
}
#[test]
/// Tests for the `parse_list` function.
fn test_parse_list() {
let numbers = "1,2,3,4";
let names = "Alice, Bob, Charlie";
let bools = "true, false, yes, no";
let floats = "3.14, 2.718, 1.618";
assert_eq!(parse_list::<u8>(numbers), Ok(Vec::from([1,2,3,4])));
assert_eq!(parse_list::<String>(names), Ok(Vec::from(["Alice".to_string(), "Bob".to_string(), "Charlie".to_string()])));
assert_eq!(parse_list::<bool>(bools), Ok(Vec::from([true, false, true, false])));
assert_eq!(parse_list::<f64>(floats), Ok(Vec::from([3.14, 2.718, 1.618])));
}
}