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:
Pascal Scholz
2026-07-13 17:19:01 +02:00
committed by Rob Bradford
parent e32f8846c2
commit 840028c64f

View File

@@ -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]
fn test_split_commas_unbalanced_bracket() {
split_commas("[a,b").unwrap_err();