@@ -246,6 +246,7 @@ impl Matcher for Box<dyn Matcher> {
246246 }
247247}
248248
249+ #[ derive( Debug , Eq , PartialEq ) ]
249250pub enum ComparableValue {
250251 MoreThan ( u64 ) ,
251252 EqualTo ( u64 ) ,
@@ -311,7 +312,7 @@ fn convert_arg_to_comparable_value(
311312 option_name : & str ,
312313 value_as_string : & str ,
313314) -> Result < ComparableValue , Box < dyn Error > > {
314- let re = Regex :: new ( r"^([+- ]?)(\d+)$" ) ?;
315+ let re = Regex :: new ( r"^([-+ ]?)[-+]? (\d+)$" ) ?;
315316 if let Some ( groups) = re. captures ( value_as_string) {
316317 if let Ok ( val) = groups[ 2 ] . parse :: < u64 > ( ) {
317318 return Ok ( match & groups[ 1 ] {
@@ -331,7 +332,7 @@ fn convert_arg_to_comparable_value_and_suffix(
331332 option_name : & str ,
332333 value_as_string : & str ,
333334) -> Result < ( ComparableValue , String ) , Box < dyn Error > > {
334- let re = Regex :: new ( r"([+- ]?)(\d+)(.*)$" ) ?;
335+ let re = Regex :: new ( r"([-+ ]?)[-+]? (\d+)(.*)$" ) ?;
335336 if let Some ( groups) = re. captures ( value_as_string) {
336337 if let Ok ( val) = groups[ 2 ] . parse :: < u64 > ( ) {
337338 return Ok ( (
@@ -1681,6 +1682,31 @@ mod tests {
16811682 }
16821683 }
16831684
1685+ #[ test]
1686+ fn convert_arg_to_comparable_value_test ( ) {
1687+ assert_eq ! (
1688+ convert_arg_to_comparable_value( "test" , "10" ) . unwrap( ) ,
1689+ ComparableValue :: EqualTo ( 10 ) ,
1690+ ) ;
1691+ assert_eq ! (
1692+ convert_arg_to_comparable_value( "test" , "+10" ) . unwrap( ) ,
1693+ ComparableValue :: MoreThan ( 10 ) ,
1694+ ) ;
1695+ assert_eq ! (
1696+ convert_arg_to_comparable_value( "test" , "-10" ) . unwrap( ) ,
1697+ ComparableValue :: LessThan ( 10 ) ,
1698+ ) ;
1699+
1700+ assert_eq ! (
1701+ convert_arg_to_comparable_value( "test" , "-+10" ) . unwrap( ) ,
1702+ ComparableValue :: LessThan ( 10 ) ,
1703+ ) ;
1704+ assert_eq ! (
1705+ convert_arg_to_comparable_value( "test" , "++10" ) . unwrap( ) ,
1706+ ComparableValue :: MoreThan ( 10 ) ,
1707+ ) ;
1708+ }
1709+
16841710 #[ test]
16851711 fn convert_exception_arg_to_comparable_value_test ( ) {
16861712 let exception_args = [ "1%2" , "1%2%3" , "1a2" , "1%2a" , "abc" , "-" , "+" , "%" ] ;
0 commit comments