diff --git a/src/locator.rs b/src/locator.rs index 5a83d29..6b4b4fc 100644 --- a/src/locator.rs +++ b/src/locator.rs @@ -593,13 +593,12 @@ mod tests { /// Regular expression that matches any unicode string that is: /// - Prefixed with `git+` - /// - Contains a literal `/` /// - Contains zero or more digits /// - Contains a literal `/` /// - Contains at least one character that is not a control character and not the literal `$` /// - Contains a literal `$` /// - Contains at least one character that is not a control character and not the literal `$` - const VALID_INPUTS_GIT_WITH_ORG: &str = r"git\+/\d*/[^\pC$]+\$[^\pC$]+"; + const VALID_INPUTS_GIT_WITH_ORG: &str = r"git\+\d*/[^\pC$]+\$[^\pC$]+"; proptest! { /// Tests randomly generated strings that match the provided regular expression against the parser. @@ -630,13 +629,12 @@ mod tests { /// Regular expression that matches any unicode string that is: /// - Prefixed with `custom+` - /// - Contains a literal `/` /// - Contains zero or more digits /// - Contains a literal `/` /// - Contains at least one character that is not a control character and not the literal `$` /// - Contains a literal `$` /// - Contains at least one character that is not a control character and not the literal `$` - const VALID_INPUTS_CUSTOM_WITH_ORG: &str = r"custom\+/\d*/[^\pC$]+\$[^\pC$]+"; + const VALID_INPUTS_CUSTOM_WITH_ORG: &str = r"custom\+\d*/[^\pC$]+\$[^\pC$]+"; proptest! { /// Tests randomly generated strings that match the provided regular expression against the parser. diff --git a/src/locator_package.rs b/src/locator_package.rs index 5f03880..573a738 100644 --- a/src/locator_package.rs +++ b/src/locator_package.rs @@ -404,9 +404,9 @@ mod tests { .expect("must parse locators"); let expected = vec![ + "custom+baz", "custom+1/bam", "custom+2/bam", - "custom+baz", "git+github.com/foo/bar", "git+github.com/foo/bar", ]; diff --git a/src/locator_strict.rs b/src/locator_strict.rs index 893b249..48d98ae 100644 --- a/src/locator_strict.rs +++ b/src/locator_strict.rs @@ -221,6 +221,13 @@ mod tests { assert_matches!(parsed, Err(Error::Parse(ParseError::Field { .. }))); } + #[test] + fn parse_empty_revision() { + let input = "git+project$"; + let parsed = StrictLocator::parse(input); + assert_matches!(parsed, Err(Error::Parse(ParseError::Field { .. }))); + } + #[test] fn parse_invalid_syntax() { let input = ""; @@ -385,9 +392,9 @@ mod tests { .expect("must parse locators"); let expected = vec![ + "custom+baz$1234", "custom+1/bam$1234", "custom+2/bam$1234", - "custom+baz$1234", "git+github.com/foo/bar$abcd10", "git+github.com/foo/bar$abcd11", ];