Skip to content

Commit 2d34e8f

Browse files
committed
Touch up PR 299 test cases
1 parent 5e09329 commit 2d34e8f

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

tests/test_identifier.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -46,31 +46,31 @@ fn test_eq() {
4646

4747
#[test]
4848
fn test_comparator() {
49-
let compatator = comparator("4.4.5-44");
50-
assert_to_string(compatator, "^4.4.5-44");
49+
let parsed = comparator("1.2.3-alpha");
50+
assert_to_string(parsed, "^1.2.3-alpha");
5151

52-
let compatator = comparator("2.X");
53-
assert_to_string(compatator, "2.*");
52+
let parsed = comparator("2.X");
53+
assert_to_string(parsed, "2.*");
5454

55-
let compatator = comparator("2");
56-
assert_to_string(compatator, "^2");
55+
let parsed = comparator("2");
56+
assert_to_string(parsed, "^2");
5757

58-
let compatator = comparator("5.x.x");
59-
assert_to_string(compatator, "5.*");
58+
let parsed = comparator("2.x.x");
59+
assert_to_string(parsed, "2.*");
6060
}
6161

6262
#[test]
6363
fn test_prerelease() {
64-
let err = prerelease_err("88.6688.b.rrrrrrr8.b.6bbbbbbb66.66\0");
64+
let err = prerelease_err("1.b\0");
6565
assert_to_string(err, "unexpected character in pre-release identifier");
6666
}
6767

6868
#[test]
6969
fn test_comparator_err() {
70-
let err = comparator_err("4.4.4-012");
70+
let err = comparator_err("1.2.3-01");
7171
assert_to_string(err, "invalid leading zero in pre-release identifier");
7272

73-
let err = comparator_err("5.4.4+4.");
73+
let err = comparator_err("1.2.3+4.");
7474
assert_to_string(err, "empty identifier segment in build metadata");
7575

7676
let err = comparator_err(">");
@@ -79,15 +79,15 @@ fn test_comparator_err() {
7979
"unexpected end of input while parsing major version number",
8080
);
8181

82-
let err = comparator_err("4.");
82+
let err = comparator_err("1.");
8383
assert_to_string(
8484
err,
8585
"unexpected end of input while parsing minor version number",
8686
);
8787

88-
let err = comparator_err("4.*.");
88+
let err = comparator_err("1.*.");
8989
assert_to_string(err, "unexpected character after wildcard in version req");
9090

91-
let err = comparator_err("55444.4.45-6+6.4.5.45-5644ÿ");
91+
let err = comparator_err("1.2.3+4ÿ");
9292
assert_to_string(err, "unexpected character 'ÿ' after build metadata");
9393
}

tests/test_version.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ fn test_parse() {
4747
let err = version_err("1.2.3-01");
4848
assert_to_string(err, "invalid leading zero in pre-release identifier");
4949

50-
let err = version_err("5.1.5++");
50+
let err = version_err("1.2.3++");
5151
assert_to_string(err, "empty identifier segment in build metadata");
5252

5353
let err = version_err("07");
5454
assert_to_string(err, "invalid leading zero in major version number");
5555

56-
let err = version_err("75774777777757777757");
56+
let err = version_err("111111111111111111111.0.0");
5757
assert_to_string(err, "value of major version number exceeds u64::MAX");
5858

5959
let err = version_err("8\0");

tests/util/mod.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ pub(super) fn req_err(text: &str) -> Error {
2323
VersionReq::parse(text).unwrap_err()
2424
}
2525

26+
#[cfg_attr(not(no_track_caller), track_caller)]
27+
pub(super) fn comparator(text: &str) -> Comparator {
28+
Comparator::parse(text).unwrap()
29+
}
30+
31+
#[cfg_attr(not(no_track_caller), track_caller)]
32+
pub(super) fn comparator_err(text: &str) -> Error {
33+
Comparator::parse(text).unwrap_err()
34+
}
35+
2636
#[cfg_attr(not(no_track_caller), track_caller)]
2737
pub(super) fn prerelease(text: &str) -> Prerelease {
2838
Prerelease::new(text).unwrap()
@@ -42,13 +52,3 @@ pub(super) fn build_metadata(text: &str) -> BuildMetadata {
4252
pub(super) fn assert_to_string(value: impl Display, expected: &str) {
4353
assert_eq!(value.to_string(), expected);
4454
}
45-
46-
#[cfg_attr(not(no_track_caller), track_caller)]
47-
pub(super) fn comparator(text: &str) -> Comparator {
48-
Comparator::parse(text).unwrap()
49-
}
50-
51-
#[cfg_attr(not(no_track_caller), track_caller)]
52-
pub(super) fn comparator_err(text: &str) -> Error {
53-
Comparator::parse(text).unwrap_err()
54-
}

0 commit comments

Comments
 (0)