Commit 6d117d66 authored by Scott Abbey's avatar Scott Abbey

Update tests

parent 9216dcc3
......@@ -511,46 +511,151 @@ mod tests {
);
}
// #[test]
// pub fn test_multiple() {
// let r = req("> 0.0.9, <= 2.5.3");
// assert_eq!(r.to_string(), "> 0.0.9, <= 2.5.3".to_string());
// assert_match(&r, &["0.0.10", "1.0.0", "2.5.3"]);
// assert_not_match(&r, &["0.0.8", "2.5.4"]);
//
// let r = req("0.3.0, 0.4.0");
// assert_eq!(r.to_string(), "^0.3.0, ^0.4.0".to_string());
// assert_not_match(&r, &["0.0.8", "0.3.0", "0.4.0"]);
//
// let r = req("<= 0.2.0, >= 0.5.0");
// assert_eq!(r.to_string(), "<= 0.2.0, >= 0.5.0".to_string());
// assert_not_match(&r, &["0.0.8", "0.3.0", "0.5.1"]);
//
// let r = req("0.1.0, 0.1.4, 0.1.6");
// assert_eq!(r.to_string(), "^0.1.0, ^0.1.4, ^0.1.6".to_string());
// assert_match(&r, &["0.1.6", "0.1.9"]);
// assert_not_match(&r, &["0.1.0", "0.1.4", "0.2.0"]);
//
// assert!(VersionReq::parse("> 0.1.0,").is_err());
// assert!(VersionReq::parse("> 0.3.0, ,").is_err());
//
// let r = req(">=0.5.1-alpha3, <0.6");
// assert_eq!(r.to_string(), ">= 0.5.1-alpha3, < 0.6".to_string());
// assert_match(&r,
// &["0.5.1-alpha3", "0.5.1-alpha4", "0.5.1-beta", "0.5.1", "0.5.5"]);
// assert_not_match(&r,
// &["0.5.1-alpha1", "0.5.2-alpha3", "0.5.5-pre", "0.5.0-pre"]);
// assert_not_match(&r, &["0.6.0", "0.6.0-pre"]);
// }
#[test]
pub fn test_multiple_01() {
let r = range::parse("> 0.0.9, <= 2.5.3").unwrap();
assert_eq!(Predicate {
op: Op::Gt,
major: 0,
minor: Some(0),
patch: Some(9),
pre: Vec::new(),
},
r.predicates[0]
);
assert_eq!(Predicate {
op: Op::LtEq,
major: 2,
minor: Some(5),
patch: Some(3),
pre: Vec::new(),
},
r.predicates[1]
);
}
#[test]
pub fn test_multiple_02() {
let r = range::parse("0.3.0, 0.4.0").unwrap();
assert_eq!(Predicate {
op: Op::Compatible,
major: 0,
minor: Some(3),
patch: Some(0),
pre: Vec::new(),
},
r.predicates[0]
);
assert_eq!(Predicate {
op: Op::Compatible,
major: 0,
minor: Some(4),
patch: Some(0),
pre: Vec::new(),
},
r.predicates[1]
);
}
#[test]
pub fn test_multiple_03() {
let r = range::parse("<= 0.2.0, >= 0.5.0").unwrap();
assert_eq!(Predicate {
op: Op::LtEq,
major: 0,
minor: Some(2),
patch: Some(0),
pre: Vec::new(),
},
r.predicates[0]
);
assert_eq!(Predicate {
op: Op::GtEq,
major: 0,
minor: Some(5),
patch: Some(0),
pre: Vec::new(),
},
r.predicates[1]
);
}
#[test]
pub fn test_multiple_04() {
let r = range::parse("0.1.0, 0.1.4, 0.1.6").unwrap();
assert_eq!(Predicate {
op: Op::Compatible,
major: 0,
minor: Some(1),
patch: Some(0),
pre: Vec::new(),
},
r.predicates[0]
);
assert_eq!(Predicate {
op: Op::Compatible,
major: 0,
minor: Some(1),
patch: Some(4),
pre: Vec::new(),
},
r.predicates[1]
);
assert_eq!(Predicate {
op: Op::Compatible,
major: 0,
minor: Some(1),
patch: Some(6),
pre: Vec::new(),
},
r.predicates[2]
);
}
#[test]
pub fn test_multiple_05() {
let r = range::parse(">=0.5.1-alpha3, <0.6").unwrap();
assert_eq!(Predicate {
op: Op::GtEq,
major: 0,
minor: Some(5),
patch: Some(1),
pre: vec![Identifier::AlphaNumeric(String::from("alpha3"))],
},
r.predicates[0]
);
assert_eq!(Predicate {
op: Op::Lt,
major: 0,
minor: Some(6),
patch: None,
pre: Vec::new(),
},
r.predicates[1]
);
}
#[test]
pub fn test_parse_errors() {
assert!(range::parse("\0").is_err());
assert!(range::parse(">= >= 0.0.2").is_err());
assert!(range::parse(">== 0.0.2").is_err());
assert!(range::parse("a.0.0").is_err());
assert!(range::parse("1.0.0-").is_err());
// assert!(range::parse(">= >= 0.0.2").is_err());
// assert!(range::parse(">== 0.0.2").is_err());
// assert!(range::parse("a.0.0").is_err());
// assert!(range::parse("1.0.0-").is_err());
assert!(range::parse(">=").is_err());
// assert!(range::parse("> 0.1.0,").is_err());
// assert!(range::parse("> 0.3.0, ,").is_err());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment