summaryrefslogtreecommitdiffstats
path: root/vendor/semver/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
commitef24de24a82fe681581cc130f342363c47c0969a (patch)
tree0d494f7e1a38b95c92426f58fe6eaa877303a86c /vendor/semver/tests
parentReleasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz
rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/semver/tests')
-rw-r--r--vendor/semver/tests/test_identifier.rs6
-rw-r--r--vendor/semver/tests/test_version.rs12
-rw-r--r--vendor/semver/tests/test_version_req.rs44
-rw-r--r--vendor/semver/tests/util/mod.rs17
4 files changed, 77 insertions, 2 deletions
diff --git a/vendor/semver/tests/test_identifier.rs b/vendor/semver/tests/test_identifier.rs
index dc888c9c1..40d859654 100644
--- a/vendor/semver/tests/test_identifier.rs
+++ b/vendor/semver/tests/test_identifier.rs
@@ -43,3 +43,9 @@ fn test_eq() {
assert_ne!(prerelease("aaaaaaaaa"), prerelease("bbbbbbbbb"));
assert_ne!(build_metadata("1"), build_metadata("001"));
}
+
+#[test]
+fn test_prerelease() {
+ let err = prerelease_err("1.b\0");
+ assert_to_string(err, "unexpected character in pre-release identifier");
+}
diff --git a/vendor/semver/tests/test_version.rs b/vendor/semver/tests/test_version.rs
index de3628fac..991087f7d 100644
--- a/vendor/semver/tests/test_version.rs
+++ b/vendor/semver/tests/test_version.rs
@@ -47,6 +47,18 @@ fn test_parse() {
let err = version_err("1.2.3-01");
assert_to_string(err, "invalid leading zero in pre-release identifier");
+ let err = version_err("1.2.3++");
+ assert_to_string(err, "empty identifier segment in build metadata");
+
+ let err = version_err("07");
+ assert_to_string(err, "invalid leading zero in major version number");
+
+ let err = version_err("111111111111111111111.0.0");
+ assert_to_string(err, "value of major version number exceeds u64::MAX");
+
+ let err = version_err("8\0");
+ assert_to_string(err, "unexpected character '\\0' after major version number");
+
let parsed = version("1.2.3");
let expected = Version::new(1, 2, 3);
assert_eq!(parsed, expected);
diff --git a/vendor/semver/tests/test_version_req.rs b/vendor/semver/tests/test_version_req.rs
index 98a03ac89..1ed2358a3 100644
--- a/vendor/semver/tests/test_version_req.rs
+++ b/vendor/semver/tests/test_version_req.rs
@@ -168,6 +168,9 @@ pub fn test_multiple() {
// https://github.com/steveklabnik/semver/issues/56
let err = req_err("1.2.3 - 2.3.4");
assert_to_string(err, "expected comma after patch version number, found '-'");
+
+ let err = req_err(">1, >2, >3, >4, >5, >6, >7, >8, >9, >10, >11, >12, >13, >14, >15, >16, >17, >18, >19, >20, >21, >22, >23, >24, >25, >26, >27, >28, >29, >30, >31, >32, >33");
+ assert_to_string(err, "excessive number of version comparators");
}
#[test]
@@ -332,7 +335,7 @@ pub fn test_pre() {
}
#[test]
-pub fn test_parse_errors() {
+pub fn test_parse() {
let err = req_err("\0");
assert_to_string(
err,
@@ -368,6 +371,45 @@ pub fn test_parse_errors() {
}
#[test]
+fn test_comparator_parse() {
+ let parsed = comparator("1.2.3-alpha");
+ assert_to_string(parsed, "^1.2.3-alpha");
+
+ let parsed = comparator("2.X");
+ assert_to_string(parsed, "2.*");
+
+ let parsed = comparator("2");
+ assert_to_string(parsed, "^2");
+
+ let parsed = comparator("2.x.x");
+ assert_to_string(parsed, "2.*");
+
+ let err = comparator_err("1.2.3-01");
+ assert_to_string(err, "invalid leading zero in pre-release identifier");
+
+ let err = comparator_err("1.2.3+4.");
+ assert_to_string(err, "empty identifier segment in build metadata");
+
+ let err = comparator_err(">");
+ assert_to_string(
+ err,
+ "unexpected end of input while parsing major version number",
+ );
+
+ let err = comparator_err("1.");
+ assert_to_string(
+ err,
+ "unexpected end of input while parsing minor version number",
+ );
+
+ let err = comparator_err("1.*.");
+ assert_to_string(err, "unexpected character after wildcard in version req");
+
+ let err = comparator_err("1.2.3+4ÿ");
+ assert_to_string(err, "unexpected character 'ÿ' after build metadata");
+}
+
+#[test]
fn test_cargo3202() {
let ref r = req("0.*.*");
assert_to_string(r, "0.*");
diff --git a/vendor/semver/tests/util/mod.rs b/vendor/semver/tests/util/mod.rs
index 5cc142c48..07d691fab 100644
--- a/vendor/semver/tests/util/mod.rs
+++ b/vendor/semver/tests/util/mod.rs
@@ -1,6 +1,6 @@
#![allow(dead_code)]
-use semver::{BuildMetadata, Error, Prerelease, Version, VersionReq};
+use semver::{BuildMetadata, Comparator, Error, Prerelease, Version, VersionReq};
use std::fmt::Display;
#[cfg_attr(not(no_track_caller), track_caller)]
@@ -24,11 +24,26 @@ pub(super) fn req_err(text: &str) -> Error {
}
#[cfg_attr(not(no_track_caller), track_caller)]
+pub(super) fn comparator(text: &str) -> Comparator {
+ Comparator::parse(text).unwrap()
+}
+
+#[cfg_attr(not(no_track_caller), track_caller)]
+pub(super) fn comparator_err(text: &str) -> Error {
+ Comparator::parse(text).unwrap_err()
+}
+
+#[cfg_attr(not(no_track_caller), track_caller)]
pub(super) fn prerelease(text: &str) -> Prerelease {
Prerelease::new(text).unwrap()
}
#[cfg_attr(not(no_track_caller), track_caller)]
+pub(super) fn prerelease_err(text: &str) -> Error {
+ Prerelease::new(text).unwrap_err()
+}
+
+#[cfg_attr(not(no_track_caller), track_caller)]
pub(super) fn build_metadata(text: &str) -> BuildMetadata {
BuildMetadata::new(text).unwrap()
}