()
| 3526 | |
| 3527 | #[mz_ore::test] |
| 3528 | fn test_parse_options() { |
| 3529 | struct TestCase { |
| 3530 | input: &'static str, |
| 3531 | expect: Result<Vec<(&'static str, &'static str)>, ()>, |
| 3532 | } |
| 3533 | let tests = vec![ |
| 3534 | TestCase { |
| 3535 | input: "", |
| 3536 | expect: Ok(vec![]), |
| 3537 | }, |
| 3538 | TestCase { |
| 3539 | input: "--key", |
| 3540 | expect: Err(()), |
| 3541 | }, |
| 3542 | TestCase { |
| 3543 | input: "--key=val", |
| 3544 | expect: Ok(vec![("key", "val")]), |
| 3545 | }, |
| 3546 | TestCase { |
| 3547 | input: r#"--key=val -ckey2=val2 -c key3=val3 -c key4=val4 -ckey5=val5"#, |
| 3548 | expect: Ok(vec![ |
| 3549 | ("key", "val"), |
| 3550 | ("key2", "val2"), |
| 3551 | ("key3", "val3"), |
| 3552 | ("key4", "val4"), |
| 3553 | ("key5", "val5"), |
| 3554 | ]), |
| 3555 | }, |
| 3556 | TestCase { |
| 3557 | input: r#"-c\ key=val"#, |
| 3558 | expect: Ok(vec![(" key", "val")]), |
| 3559 | }, |
| 3560 | TestCase { |
| 3561 | input: "--key=val -ckey2 val2", |
| 3562 | expect: Err(()), |
| 3563 | }, |
| 3564 | // Unclear what this should do. |
| 3565 | TestCase { |
| 3566 | input: "--key=", |
| 3567 | expect: Ok(vec![("key", "")]), |
| 3568 | }, |
| 3569 | ]; |
| 3570 | for test in tests { |
| 3571 | let got = parse_options(test.input); |
| 3572 | let expect = test.expect.map(|r| { |
| 3573 | r.into_iter() |
| 3574 | .map(|(k, v)| (k.to_owned(), v.to_owned())) |
| 3575 | .collect() |
| 3576 | }); |
| 3577 | assert_eq!(got, expect, "input: {}", test.input); |
| 3578 | } |
| 3579 | } |
| 3580 | |
| 3581 | #[mz_ore::test] |
| 3582 | fn test_parse_option() { |
nothing calls this directly
no test coverage detected