Skip to content

Commit

Permalink
Add test that VersionReq::default() == VersionReq::STAR
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Feb 4, 2022
1 parent 86af565 commit 5efaf2c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use semver::Version;
use std::fmt::{self, Display};
use std::process::Command;

#[derive(Eq, PartialEq, Hash, Debug)]
#[derive(Default, Eq, PartialEq, Hash, Debug)]
pub(super) struct VersionReq(semver::VersionReq);

impl VersionReq {
Expand Down
9 changes: 8 additions & 1 deletion tests/test_version_req.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,20 @@ fn assert_match_none(req: &VersionReq, versions: &[&str]) {
}

#[test]
fn test_default() {
fn test_basic() {
let ref r = req("1.0.0");
assert_to_string(r, "^1.0.0");
assert_match_all(r, &["1.0.0", "1.1.0", "1.0.1"]);
assert_match_none(r, &["0.9.9", "0.10.0", "0.1.0", "1.0.0-pre", "1.0.1-pre"]);
}

#[test]
#[cfg(not(no_const_vec_new))]
fn test_default() {
let ref r = VersionReq::default();
assert_eq!(r, &VersionReq::STAR);
}

#[test]
fn test_exact() {
let ref r = req("=1.0.0");
Expand Down

0 comments on commit 5efaf2c

Please sign in to comment.