forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshared_helpers_tests.rs
More file actions
35 lines (31 loc) · 1.29 KB
/
Copy pathshared_helpers_tests.rs
File metadata and controls
35 lines (31 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//! The `shared_helpers` module can't have its own tests submodule, because that would cause
//! problems for the shim binaries that include it via `#[path]`, so instead those unit tests live
//! here.
//!
//! To prevent tidy from complaining about this file not being named `tests.rs`, it lives inside a
//! submodule directory named `tests`.
use crate::utils::shared_helpers::parse_value_from_args;
#[test]
fn test_parse_value_from_args() {
let args = vec![
"--stage".into(),
"1".into(),
"--version".into(),
"2".into(),
"--target".into(),
"x86_64-unknown-linux".into(),
];
assert_eq!(parse_value_from_args(args.as_slice(), "--stage").unwrap(), "1");
assert_eq!(parse_value_from_args(args.as_slice(), "--version").unwrap(), "2");
assert_eq!(parse_value_from_args(args.as_slice(), "--target").unwrap(), "x86_64-unknown-linux");
assert!(parse_value_from_args(args.as_slice(), "random-key").is_none());
let args = vec![
"app-name".into(),
"--key".into(),
"value".into(),
"random-value".into(),
"--sysroot=/x/y/z".into(),
];
assert_eq!(parse_value_from_args(args.as_slice(), "--key").unwrap(), "value");
assert_eq!(parse_value_from_args(args.as_slice(), "--sysroot").unwrap(), "/x/y/z");
}