Browse Source

prepared for cargo watch

regex
Jim Infield 3 years ago
parent
commit
0857e0bd5d
  1. 31
      src/main.rs

31
src/main.rs

@ -2,19 +2,42 @@
fn main() { fn main() {
let args = vec![ let args = vec![
"string1",
"string2",
"01|15|59, 1|47|16, 01|17|20, 1|32|34, 2|17|17",
"02|15|59, 2|47|16, 02|17|20, 2|32|34, 2|17|17, 2|22|00, 2|31|41",
]; ];
println!(); println!();
for arg in args { for arg in args {
println!("{}",func(&arg));
println!("{:?}\n{:?}\n", arg, stati(arg));
}; };
println!(); println!();
} }
fn func(s: &str) -> String {
fn stati(s: &str) -> String {
s.into() s.into()
} }
#[cfg(test)]
mod tests {
use super::*;
fn dotest(strg: &str, exp: &str) -> () {
println!(" str: {:?};", strg);
let ans = stati(strg);
println!(" actual:\n{:?};", ans);
println!("expect:\n{:?};", exp);
println!(" {};", ans == exp);
assert_eq!(ans, exp);
println!("{};", "-");
}
#[test]
fn basic_tests() {
dotest("01|15|59, 1|47|16, 01|17|20, 1|32|34, 2|17|17",
"Range: 01|01|18 Average: 01|38|05 Median: 01|32|34");
dotest("02|15|59, 2|47|16, 02|17|20, 2|32|34, 2|17|17, 2|22|00, 2|31|41",
"Range: 00|31|17 Average: 02|26|18 Median: 02|22|00");
}
}
Loading…
Cancel
Save