mirror of
https://github.com/darwincereska/envkit.git
synced 2026-06-11 10:23:23 -05:00
feat: added support for lists
This commit is contained in:
@@ -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])));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user