summaryrefslogtreecommitdiff
path: root/src/rust
diff options
context:
space:
mode:
Diffstat (limited to 'src/rust')
-rw-r--r--src/rust/protover/protoset.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/rust/protover/protoset.rs b/src/rust/protover/protoset.rs
index 5cea03983a..a670f796bf 100644
--- a/src/rust/protover/protoset.rs
+++ b/src/rust/protover/protoset.rs
@@ -349,7 +349,7 @@ impl FromStr for ProtoSet {
if p.is_empty() {
continue;
} else if p.contains('-') {
- let mut pair = p.split('-');
+ let mut pair = p.splitn(2, '-');
let low = pair.next().ok_or(ProtoverError::Unparseable)?;
let high = pair.next().ok_or(ProtoverError::Unparseable)?;
@@ -540,6 +540,18 @@ mod test {
}
#[test]
+ fn test_versions_from_str_hyphens() {
+ assert_eq!(Err(ProtoverError::Unparseable), ProtoSet::from_str("--1"));
+ assert_eq!(Err(ProtoverError::Unparseable), ProtoSet::from_str("-1-2"));
+ assert_eq!(Err(ProtoverError::Unparseable), ProtoSet::from_str("1--2"));
+ }
+
+ #[test]
+ fn test_versions_from_str_triple() {
+ assert_eq!(Err(ProtoverError::Unparseable), ProtoSet::from_str("1-2-3"));
+ }
+
+ #[test]
fn test_versions_from_str_1exclam() {
assert_eq!(Err(ProtoverError::Unparseable), ProtoSet::from_str("1,!"));
}