mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
option_parser: Reject Tuple keys only consisting of whitespaace
We reject keys only consisting of whitespace as empty as it can occur as an input artifact. Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de> On-behalf-of: SAP pascal.scholz@sap.com
This commit is contained in:
committed by
Rob Bradford
parent
e32f8846c2
commit
840028c64f
@@ -966,6 +966,17 @@ mod unit_tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_tuple_reject_whitespace_as_empty_key() {
|
||||||
|
let expected_value = "@42";
|
||||||
|
let e = Tuple::<String, u64>::from_str(" @42").unwrap_err();
|
||||||
|
assert!(
|
||||||
|
matches!(e, TupleError::EmptyKey(ref s) if s == expected_value),
|
||||||
|
"Expected \"{:?}\"; got \"{e:?}\"",
|
||||||
|
TupleError::EmptyKey(expected_value.to_string()),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_split_commas_unbalanced_bracket() {
|
fn test_split_commas_unbalanced_bracket() {
|
||||||
split_commas("[a,b").unwrap_err();
|
split_commas("[a,b").unwrap_err();
|
||||||
|
|||||||
Reference in New Issue
Block a user